簡短的回答是使用git fetch origin
隨後git merge origin/develop
從當地的開發分支
git pull
就像是一個git fetch
接着是git merge
在當地分行的發展。雖然您的本地副本是來自您的起源/開發HEAD的前一個提交,但您當前存儲庫中的起源/開發將與您當地的開發分支不匹配。撥打git push origin develop
更新您當地的起源/發展,當git意識到變化已經在遠程git回購。
這裏就是你在本地看到你的機器上沒有變化:
macbook:test joel$ git push origin master
Everything up-to-date
macbook:test joel$ git status
# On branch master
nothing to commit (working directory clean)
macbook:test joel$
在另一臺計算機的其他用戶進行了更改,提交它,並將其推到原點/主:
otherPerson-pc:test bob$ git status
# On branch master
nothing to commit (working directory clean)
otherPerson-pc:test bob$ echo "ddd" >> newfile.txt
otherPerson-pc:test bob$ git add newfile.txt
otherPerson-pc:test bob$ git commit --message "added to newfile in master remotely"
[master d14b77e] added to newfile in master remotely
1 files changed, 1 insertions(+), 0 deletions(-)
otherPerson-pc:test bob$ git push origin master
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 314 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To /Users/joel/Desktop/test/test.git
2cfa7d4..d14b77e master -> master
otherPerson-pc:test bob$
回到我的本地副本,我沒有做出任何改變。我從產地主拉從別人那裏得到改變,並出現一個承諾未來!:
macbook:test joel$ git status
# On branch master
nothing to commit (working directory clean)
macbook:test joel$ git pull origin master
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /Users/joel/Desktop/test/test
* branch master -> FETCH_HEAD
Updating 2cfa7d4..d14b77e
Fast-forward
newfile.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
macbook:test joel$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
macbook:test joel$
我的本地主有從遙控器上的主應用的變化,但我出身/主副本爲1提交之後,以便混帳說我」即使我是最新的,我也可以在本地提前完成。 git push origin master
本地更新origin/master,消息消失。
您可以通過使用git fetch
和git merge
,而不是git pull
的其他開發人員避免這種情況可能會再次做到這一點:
otherPerson-pc:test bob$ git status
# On branch master
nothing to commit (working directory clean)
otherPerson-pc:test bob$ echo "gggg" >> newfile.txt
otherPerson-pc:test bob$ git add newfile.txt
otherPerson-pc:test bob$ git commit --message "added gggg newfile in master remotely"
[master 677d031] added eeee newfile in master remotely
1 files changed, 1 insertions(+), 0 deletions(-)
otherPerson-pc:test bob$ git push origin master
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 321 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To /Users/joel/Desktop/test/test.git
d14b77e..677d031 master -> master
otherPerson-pc:test bob$
本地我的git獲取所有來源,然後手動合併產地/掌握到我的合併副本。
macbook:test joel$ git status
# On branch master
nothing to commit (working directory clean)
macbook:test joel$ git fetch origin
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /Users/joel/Desktop/test/test
5e335fa..2dae61c master -> origin/master
macbook:test joel$ git status
# On branch master
# Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
#
nothing to commit (working directory clean)
macbook:test joel$ git merge origin/master
Updating 5e335fa..2dae61c
Fast-forward
newfile.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
macbook:test joel$ git status
# On branch master
nothing to commit (working directory clean)
macbook:test joel$
我通常做一個提取然後合併,因爲你可以在你使用git diff合併之前檢查衝突。