简体   繁体   English

如何在github上的主仓库中获取与本地文件同步的本地仓库?

[英]How to I get my local repo in sync wit ha file in master repo on github?

I am looking a file in master on git hub. 我正在git hub上的master中查找文件。

I am looking at the same file on my local repo but it is not reflect changes in the master file on the repo committed by someone else. 我正在查看本地存储库中的同一文件,但未反映其他人提交的存储库中主文件中的更改。

I tried git pull git fetch and merge. 我尝试了git pull git提取并合并。

What else to I have to do? 我还要做什么?

If there are no changes that you want to keep in your working folder, and assuming you did run fetch successfully, you can 如果没有要保留在工作文件夹中的更改,并且假设您确实成功运行了访存,则可以

git stash -u # safely clean up your working folder

Then point master to the remote's version (assuming your remote is called origin): 然后将master指向遥控器的版本(假设您的遥控器称为Origin):

git merge --ff-only origin/master # if master is checked out

or 要么

git push . origin/master:master # if master is not checked out

If you get an error with the last 2, you can add the --force option but remember to save the master to another branch or tag before doing so with 如果最后2个错误,则可以添加--force选项,但在执行此操作之前,请记住将主服务器保存到另一个分支或标签。

git branch temp master
git push origin yourname/temp

or 要么

git tag -m "last master" temp
git push origin yourname/temp

the "yourname" part of the remote branch or tag is to let others know that it's your branch and you don't necessarily believe it to be valuable to others. 远程分支或标记的“您的名字”部分是让其他人知道它是您的分支,而您不一定认为它对其他人有价值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM