![](/img/trans.png)
[英]How can I synchronize my local repositories with the central one on GitHub?
[英]How can I synchronize github with a local repository?
我沒有找到一個明確的答案(很多事情對git的新手來說是壓倒性的):
我在github上有一個本地倉庫和一個遠程文件夾,其中包含文件:A,B和C。
我的繪圖描述了文件及其更改:
local remote
A -------> A
B <------- B
C <------> C
晚上,我只是盯着倉庫。 有沒有機會立即完成? 任何人?
首先提交所有本地更改。 確保您的工作目錄是干凈的:
$ git status
應該返回: nothing to commit, working directory clean
然后,拉入遙控器的更改:
$ git pull remote-name branch-name
# it's probably git pull origin master
然后推送您的更改以與遠程共享:
$ git push origin master
我的本地工作流程可讓您正確解開推拉階段,具體步驟如下:
使用git stash
本地未提交的更改:
git stash
使用遠程版本1更新本地存儲庫:
git pull
這樣就得到:
local remote B <------- B C <------- C
應用本地更改,合並所有不一致之處,如有需要,修復文件,然后將其添加到索引中,然后提交合並:
git stash pop vim ... git add . git commit
編輯文件C
,然后提交。
vim C git add C git commit
將更改推送到刪除存儲庫中:
git push
這樣您將獲得:
local remote A -------> B C -------> C
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.