Reputation: 22887
I forked the biopython/biopython repository on GitHub to BioGeek/biopython.
I made some changes in my local repository, committed them, created a pull request and they were merged into the upstream biopython repository. So far, so good.
I make some further commits into my repository and in the mean time some other commits are made in the main biopython repository.
Now I want to update my local repository to pull in the changes from the main repository, so I do:
$ git pull upstream master
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 12 (delta 9), reused 10 (delta 7), pack-reused 0
Unpacking objects: 100% (12/12), done.
From https://github.com/biopython/biopython
* branch master -> FETCH_HEAD
06b6cd64d..6e41879ca master -> upstream/master
First, rewinding head to replay your work on top of it...
Applying: add header back to 1LCD.pdb file
Applying: actually check that the warning was raised instead of surpressing it
$ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 100 and 3 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
Untracked files:
(use "git add <file>..." to include in what will be committed)
../Doc/examples/tree1.nwk
nothing added to commit but untracked files present (use "git add" to track)
Next I want to update the master branch in my forked repository, so I do:
$ git push origin master
To https://github.com/BioGeek/biopython.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/BioGeek/biopython.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Hmm, rejected
. So I pull up the page Syncing a fork from GitHub help and follow the instructions from there:
$ git fetch upstream
$ git checkout master
Already on 'master'
Your branch and 'origin/master' have diverged,
and have 100 and 3 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
Hmm, I have to use git pull
, so I do that
$ git pull
First, rewinding head to replay your work on top of it...
Applying: MAF parser, intitial checkin. Passes unit tests
[... some 100 lines omitted ...]
Applying: Update test to match changed exception
Applying: Thank Jeroen for test_QCPSuperimposer.py update
Applying: Fix unit test, failed under PyPy 5.6.0
But now are the changes I made locally to the files 1LCD.pdb and test_SeqIO_PdbIO.py gone! I have commited them, so how do I bring them back and where did I go wrong so that I don't get this mess again in the future when I want to sync my fork.
Upvotes: 1
Views: 70
Reputation: 38116
You were not based the newest biopython master at the first time. After the commit Deprecate Bio.DocSQL
, there are still have multiple commits which you didn’t pull in your fork repo, so even the PR is merged in biopython master, but your fork repo is different.
So you can save the work you don't pushed in another branch, then delete your local master branch and treat the main biopython master as you local master branch, then merge the works in master and delete the temporary branch, detail steps as below:
git checkout -b temp
git branch -D master
git checkout upstream/master
git checkout -b master
git merge temp
git branch -D temp
Upvotes: 1