2015-02-10 106 views
2

我在Github上有一個項目,但我正在努力從它獲取到我的本地機器的更改。我最近部署了一個使用Fortrabbit的應用程序,其中包括創建一個新的遠程回購以將所有文件推送到 - 現在(我是noob)我正努力回到拉動和推動對origin的更改。在Git中更改遠程分支

如果我運行git status

On branch master 
Your branch is up-to-date with 'fortrabbit/master'. 

nothing to commit, working directory clean 

如果我跑git fetch origin我沒有得到任何錯誤,只是回到命令行。

如果我跑git status再次我仍然得到

On branch master 
Your branch is up-to-date with 'fortrabbit/master'. 

nothing to commit, working directory clean 

我想這樣說Your branch is up-to-date with 'origin/master'.

git remote -v給了我兩個回購(我想?)

fortrabbit [email protected]:app.git (fetch) 
fortrabbit [email protected]:app.git (push) 
origin https://github.com/djave/app.git (fetch) 
origin https://github.com/djave/app.git (push) 

我只需要到git change repo origin什麼的?我如何告訴git我想回到與原始同步?

回答

3

你應該能夠使用git branch --set-upstream master origin/master來解決這個問題,它基本上說你當前的本地分支應該與原始分支對應。

+0

我愛你。當你知道如何時很容易。最後一點,我得到以下內容:'--set-upstream標誌已被棄用,並將被刪除。考慮使用--track或--set-upstream-來設置分支主設備,以便從原點跟蹤遠程分支主設備。「 - 將來我只需要使用'git branch --set-upstream-master master/master'? – Djave 2015-02-10 12:14:07

+1

那麼,你可以使用'git push -u remote branch',以便從那個分支上的那個點被跟蹤到你推送到的遠程分支(只需用你想要的遠程和分支名稱替換遠程和分支) 。在第一次推後,你可以使用git push,它會自動推送到該特定分支上的遠程。有關更多信息,請參閱[git-push文檔](http://git-scm.com/docs/git-push)。 – 2015-02-10 12:17:53

+1

另外,是的,將來你可以使用'git branch --set-upstream-master master/master'來代替'--set-upstream'。請注意,您只需在每個分支中執行一次該操作(或者在首次將該分支推送到遠程時使用'git push -u')。 – 2015-02-10 12:19:09