5

I created a PR for this issue, after a while the main repository is updated with new accepted PRs and my fork is behind the main repository.

So now I tried to synchronize my Forked Repositoy, but that's not the end of the problem I have to sync my commits or log with the main repository.

How do I synchronize my forked repository time-line/logs with the main repository.

2
  • Probably with a rebase on top of upstream/master. I am commuting right now, and on my phone. I will answer when I get back.
    – VonC
    Commented Jun 16, 2017 at 7:50
  • Oh okay...The problem is with the updated commits, they are glued into a single commit, which appears as a single commit(combo of 10 or more commits) in fork log. I just want to avoid re-fork, maybe separating each commit from the single 'merge' commit would work here.
    – Chinmaya B
    Commented Jun 16, 2017 at 7:54

1 Answer 1

4

The problem is with the updated commits, they are glued into a single commit, which appears as a single commit(combo of 10 or more commits) in fork log

That is expected, since you have pulled (fetch+merge)

I would advise you to locally remove to remove that merge commit, and rebase (ie replay your commits) on top of upstream/master (with upstream being the remote name for the original repo)

Plus, I would have isolated those changes in a dedicated branch, but since you have started the PR from master, let's stay on master.

Make sure you don't have any local work in progress.

cd /path/to/local/repo
git remote add upstream <Repository URL>

Check the output of git remote -v: you should see upstream and origin, with origin referencing your fork.

git log # make sure master HEAD is at the right commit
git fetch upstream
git rebase upstream/master
# test if everything is still working
git push --force
11
  • Is it going to affect my PR commit as that commit is more costly than all of this
    – Chinmaya B
    Commented Jun 16, 2017 at 19:12
  • @ChinmayaB No it will not: the push --force will re-upload your commits, and the PR in progress will automatically update itself with those new commits.
    – VonC
    Commented Jun 16, 2017 at 19:13
  • @ChinmayaB All you need to do before pushing (push --force) is make sure you do see locally your commits on top of the upstream repo up-to-date. If what you see is correct, and working, you can push --force to your fork, and the PR will take that into account automatically.
    – VonC
    Commented Jun 16, 2017 at 19:14
  • Git is not able to get upstream repository it says...fatal: 'upstream' does not appear to be a git repository fatal: Could not read from remote repository.
    – Chinmaya B
    Commented Jun 16, 2017 at 19:19
  • @ChinmayaB Sorry, I assumed you had upstream already. Let me edit the answer.
    – VonC
    Commented Jun 16, 2017 at 19:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.