Friday, June 2, 2017

github - keep your fork in sync



Keep your fork in sync. with original master :


# Now, you are in your local cloned copy of original GitHub repo:

git checkout master


You wish to update master to be in sync with original GitHub repo.



# First, add github location  as "remote"  (1)  - here *upstream* is the name provided by us:

git remote add upstream  https://github.com/original-repo-from-where-you-cloned.git



# fetch all branches - see we are using name provided above :)  (2)

git fetch upstream


# apply all changes from original github location to your branch and then play your changes on top (3)

git rebase upstream/master

Now your fork is in sync with original repo :)



=========================================================
Notes:

(1)  git-remote  add

Adds a remote named <name> for the repository at <url>. The command git fetch <name> can then be used to create and update remote-tracking branches <name>/<branch>.

(2) git-fetch - Download objects and refs from another repository

(3)  git-rebase - Reapply commits on top of another base tip

===============================================================

No comments:

Post a Comment