How to Make Fork Changes Reflect with The Master When Updated

How to make fork changes reflect with the master when updated?

Beside the fact you should make any evolution in a dedicated feature branch, you should not pull directly (that merges upstream/master into your master)

You should pull --rebase (which replays your local commits on top of the updated upstream/master), and then git push --force back to your fork.

You should get back your markers after re-applying your commits in the updated README.

How do I update or sync a forked repository on GitHub?

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

# Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

# Fetch all the branches of that remote into remote-tracking branches

git fetch upstream

# Make sure that you're on your master branch:

git checkout master

# Rewrite your master branch so that any commits of yours that
# aren't already in upstream/master are replayed on top of that
# other branch:

git rebase upstream/master

If you don't want to rewrite the history of your master branch, (for example because other people may have cloned it) then you should replace the last command with git merge upstream/master. However, for making further pull requests that are as clean as possible, it's probably better to rebase.


If you've rebased your branch onto upstream/master you may need to force the push in order to push it to your own forked repository on GitHub. You'd do that with:

git push -f origin master

You only need to use the -f the first time after you've rebased.

Git:Why after Re-basing still my fork is behind the original repo master?

When you were doing

$ git branch --set-upstream-to=origin progress

you told git that your local branch progress is tracking origin/progress thus

$ git pull --rebase

is rebasing on origin/progress and not on jwasham:master as you wish.

You need to fetch the changes from jwasham:master into your local clone and then you can do the rebase.

E.g:

$ git remote add jwasham <URL>
$ git fetch --all
$ git rebase jwasham/master

then you can push to your github-clone - most likely with --force if you previously published your branch.

synced fork with upstream master, but still says it needs to still be synced

Okay so as I was thinking about what could have been wrong, it looks like when you want to merge commits from an upsteam master using a new branch you created, you get three option:

  1. Create a merge commit
  2. Squash and merge
  3. Rebase and merge (which isn't really an option)

After redoing the sync, I found that the way that it properly recognized that I had synced with the upstream master is when I did a merge commit, so that the individually commits showed up in my commit history instead of them being squashed into one.

After I did it this way, "Fetch upstream" showed that there were no new commits to fetch.

Why does my github repository fork not shows the changes I made that were accepted?

0 commits ahead and 0 commits behind master

That is behind the last known state of master from the original repo.

You should locally:

git checkout master
git pull upstream
git push

Assuming that:

  • upstream is the name of the remote referencing the original repo.

    See more at "Pull new updates from original Github repository into forked Github repository".
  • you didn't work on master (in which case, a git pull will simply add new commits from upstream/master)

upstream vs. fork

How do I reset the git master branch to the upstream branch in a forked repository?

You can reset your local master branch to the upstream version and push it to your origin repository.

Assuming that "upstream" is the original repository and "origin" is your fork:

# ensures current branch is master
git checkout master

# pulls all new commits made to upstream/master
git pull upstream master

# this will delete all your local changes to master
git reset --hard upstream/master

# take care, this will delete all your changes on your forked master
git push origin master --force

(You can define the original repo as "upstream" with git remote add upstream /url/to/original/repo.)

How to use the forked repo and still track updates from the original source

This is a basic Git how-to question which has nothing to do with Python in particular.

Assuming you've git clone-d the library into a local repository, then git pull will fetch remote changes and then merge them into your local changes.

In many cases, what you really want to do is git pull --rebase which will "replay" your local changes on top of the remote changes.

Here's a pretty good blog post introducing the different ways you might want to sync your local repository with the remote source: http://blog.mikepearce.net/2010/05/18/the-difference-between-git-pull-git-fetch-and-git-clone-and-git-rebase/



Related Topics



Leave a reply



Submit