This article shows how to fork your own repository on Gitlab. This will work with GitHub and Bitbucket.
- Create a new repository on GitLab (let’s call it Child). Let’s assume your repo that you want to fork is called Parent
- Clone the Child repository to your local machine
git clone
https://github.com/<username>/child.git
- CD into your Child repo
cd child
- Create a new ‘project-work’ branch
git checkout -b project-work
- Add the Parent repo as an Upstream Remote
git remote add upstream
https://github.com/<username>/parent.git
- Pull the Parent repo into your Child repo
git pull upstream master --allow-unrelated-histories
You may get the error, fatal: refusing to merge unrelated histories - be sure to add ‘–allow-unrelated-histories’ to the upstream command
- Merge your work into your Child master branch
git checkout master
git merge project-work
- Finally, finish your work. Add and commit your work and push to your Child repo.
git push origin master
Comments