简体   繁体   English

使用 Github 存储库更新本地存储库

[英]Update local repo with Github repo

I committed to my github repo form one machine, I also work on the same project on another machine.我承诺在一台机器上使用我的 github 回购,我也在另一台机器上从事同一个项目。 How can I update my local repo to be current to the latest version on Github?如何将我的本地存储库更新为 Github 上的最新版本?

I tried git pull origin master but I get Please commit your changes or stash them before you merge. Aborting我试过git pull origin master但我得到Please commit your changes or stash them before you merge. Aborting Please commit your changes or stash them before you merge. Aborting

Thanks for any help谢谢你的帮助

Quick action!!快速行动!!

You can use stash command of git.您可以使用 git 的stash命令。

Perform the following steps.执行以下步骤。

  1. git stash git 存储
  2. git pull origin master git 拉原点主控
  3. git stash apply git 存储应用

You have made changes in the working directory which you are trying to update to the latest version that's available in the remote repo (Github).您已在工作目录中进行了更改,您尝试将其更新为远程存储库 (Github) 中可用的最新版本。

Your working tree has to be clean for you to pull in any changes from the remote repo.您的工作树必须是干净的,您才能从远程存储库中提取任何更改。

So stash your work (which will save your work but will remove it from your working directory so that you can use it later) using git stash first.因此,首先使用git stash存储您的工作(这将保存您的工作,但会将其从您的工作目录中删除,以便您以后可以使用它)。

Then pull in the changes from the remote repo using git pull origin master .然后使用git pull origin master从远程仓库中提取更改。

Now you can reapply the stashed changes that you had made in your working directory by using git stash apply or git stash pop .现在,您可以使用git stash applygit stash pop重新应用您在工作目录中所做的隐藏更改。

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

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