2017-02-14 81 views
1

我將GitHub上的biopython/biopython存儲庫分叉爲BioGeek/biopython嘗試同步分叉GitHub存儲庫後恢復本地文件

我在本地存儲庫中做了一些更改,其中committed他們創建了pull request,他們將merged插入上游biopython存儲庫。到現在爲止還挺好。

我將一些further commits放入我的存儲庫,同時還在主biopython存儲庫中製作了一些other commits

現在我想更新我的本地庫從主存儲庫中的變化來拉,所以我做的:

$ 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) 

接下來,我想在我的分叉庫更新主分支,所以我做的:

$ 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. 

嗯,rejected。所以,我從GitHub幫助拉起Syncing a fork的頁面,並按照指示從那裏:

$ 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) 

嗯,我不得不使用git pull,所以我這樣做,

$ 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 

但現在我所做的更改本地文件1LCD.pdbtest_SeqIO_PdbIO.py已不見了!我已經提交了他們,那麼我該如何將他們帶回來,以及我在哪裏出錯,以便將來當我想同步我的分支時不會再陷入混亂。

回答

1

你不是第一次使用最新的biopython master。在提交Deprecate Bio.DocSQL之後,仍然有多個提交,您沒有在您的fork repo中提交,因此即使PR在biopython master中合併,但您的fork repo也不同。

enter image description here

這樣可以節省你沒有另外一個分支推的工作,然後刪除您的本地master分支和治療的主要biopython主,你本地的master分支,然後合併工作在主站和刪除臨時分支,詳細步驟如下:

git checkout -b temp 
git branch -D master 
git checkout upstream/master 
git checkout -b master 
git merge temp 
git branch -D temp