[英]How can I synchronize github with a local repository?
I didn't find a clear answer to this one (many things are overwhelming to newbies at git): 我没有找到一个明确的答案(很多事情对git的新手来说是压倒性的):
I have a local repo and a remote at github consisting of files: A, B and C. 我在github上有一个本地仓库和一个远程文件夹,其中包含文件:A,B和C。
My draw depicts the files and their changes: 我的绘图描述了文件及其更改:
local remote
A -------> A
B <------- B
C <------> C
In the evening, I'm just staring the repos. 晚上,我只是盯着仓库。 Is there any chance to finish promptly?
有没有机会立即完成? Anyone?
任何人?
Commit all of your local changes first. 首先提交所有本地更改。 Make sure your working directory is clean:
确保您的工作目录是干净的:
$ git status
should return: nothing to commit, working directory clean
应该返回:
nothing to commit, working directory clean
Then, pull in the remote's changes: 然后,拉入遥控器的更改:
$ git pull remote-name branch-name
# it's probably git pull origin master
Then push your changes to share with the remote: 然后推送您的更改以与远程共享:
$ git push origin master
My local workfolw allows your to untie the pull and push stages properly, and it is the following: 我的本地工作流程可让您正确解开推拉阶段,具体步骤如下:
Store your local uncommitted changes with git stash
: 使用
git stash
本地未提交的更改:
git stash
Update your local repo with remote version one: 使用远程版本1更新本地存储库:
git pull
So you get: 这样就得到:
local remote B <------- B C <------- C
Apply local changes, and merge all inconsistiences, fix the files if any require, and add them into index, and commit merge: 应用本地更改,合并所有不一致之处,如有需要,修复文件,然后将其添加到索引中,然后提交合并:
git stash pop vim ... git add . git commit
Edit file C
, and commit it. 编辑文件
C
,然后提交。
vim C git add C git commit
Push changes into remove repo: 将更改推送到删除存储库中:
git push
So you'll get: 这样您将获得:
local remote A -------> B C -------> C
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.