Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - to fork or not to fork

Tags:

git

github

New to Git and still a little perplexed. I have forked a project on github and would like to bring in/merge some recent changes made by the project owner on the original to my fork. Is this possible? The project is read only but basically, I'd like to get myself to a point where I can make edits and add code and then also bring in any changes in from the original/master.

Maybe I don't need to make a fork, and should just clone the master to my local hard drive. Any help much appreciated,

like image 667
Chin Avatar asked Dec 29 '22 04:12

Chin


2 Answers

Yes, you can add the original repository as a remote to your local repository

$ git remote add upstream http://.....

and then you can

$ git fetch upstream
$ git merge upstream/any-changes

to get that data into your local branches (which you can then push back to your github fork)

like image 154
Gareth Avatar answered Jan 13 '23 12:01

Gareth


You might also want to consider git rebase. This undoes all your commits, fast forwards you to the latest commit on the upstream repository, then applies your commits one by one.

like image 22
nimrodm Avatar answered Jan 13 '23 14:01

nimrodm