There are many public repositories which at times we want to fork and continue our path. However, at the same time, we want to keep pulling the changes from the original repository also. In this post, we will look into how to fork a repository and how to pull the changes in the future.
Forking
Let's say we want to fork a repository
https://github.com/lalitmcb/rms
This is an actual repository so you use it to try it out.
First clone the repository locally
git clone https://github.com/lalitmcb/rms.git
Now let's say you want to make a new repo with your username at some location. For example purpose, we will assume GitHub and we want to create the repo with name "copy".
Go to rms folder.
cd rms
git push --mirror https://github.com/<your username>/copy.git
Delete the rms folder and you can clone the new copy repository for further work. You can rename copy in copy.git and the repo will be created with the given name.
Merging from the original repo
Usually, you want to do it in the master branch. Synching the master of the original repo with the fork.
Check out the master
git checkout master
Pull the changes from original repo to the local master branch
git pull https://github.com/lalitmcb/rms.git master
Push the changes to your repo. There might be conflicts that need to be resolved.
git push origin master
Once the changes are in master's in your repo. you can pull those changes in the other working branches.
No comments:
Post a Comment