git pull(仅更新本地文件)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11085882/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git pull (update local file only)
提问by LynAs
i just want to update my local files with git. but every time i try to pull i get and error saying that i need to commit certain file first. what is the way to update local file without using commit??
我只想用 git 更新我的本地文件。但是每次我尝试拉我时都会出错,说我需要先提交某个文件。在不使用提交的情况下更新本地文件的方法是什么?
here is the error message
这是错误信息
$ git pull Enter passphrase for key '/c/Users/me/.ssh/id_rsa': Updating 4dsdSe6e..70fb5b6 error: Your local changes to the following files would be overwritten by merge: grails-app/conf/DataSource.groovy Please, commit your changes or stash them before you can merge. Aborting
$ git pull Enter passphrase for key '/c/Users/me/.ssh/id_rsa': Updating 4dsdSe6e..70fb5b6 error: 您对以下文件的本地更改将被合并覆盖:grails-app/conf/DataSource.groovy请在合并之前提交您的更改或隐藏它们。中止
回答by bilalq
If you don't want to commit, you'll need to stash your changes. This sounds like what you're looking for:
如果您不想提交,则需要隐藏您的更改。这听起来像你在找什么:
git stash save "Changes I don't want to commit yet"
git pull
git stash pop
The first line stashes your changes onto a stack and reverts your code to the last commit. From there, you can pull like normal. Once you've pulled, pop the changes in your stash back onto your code. This let's you do a pull without committing your code. You can learn more about stashing here.
第一行将您的更改存储到堆栈中,并将您的代码恢复到最后一次提交。从那里,你可以像往常一样拉。拉取后,将存储中的更改弹回到代码中。这让您可以在不提交代码的情况下进行拉取。您可以在此处了解有关隐藏的更多信息。
Hope that helped!
希望有所帮助!
回答by vgonisanz
You are trying to pull some files that will delete your changes. First, commit your changes with:
您正在尝试提取一些将删除您的更改的文件。首先,提交您的更改:
git commit -a -m "I have changed XXXX"
then pull others:
然后拉别人:
git pull
If no problems to solve, you can push your changes:
如果没有问题需要解决,您可以推送您的更改:
git push