GIT:以下未跟踪的工作树文件将被 checkout 覆盖

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12323128/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:28:13  来源:igfitidea点击:

GIT: The following untracked working tree files would be overwritten by checkout

gitgit-checkout

提问by Matthew Colley

I have two branches one is called master the other is called dev I am currently in the master branch and I want to go to the dev branch to move a file to the development server. however when I perform a

我有两个分支,一个称为 master,另一个称为 dev 我目前在 master 分支,我想转到 dev 分支将文件移动到开发服务器。但是当我执行一个

$ git checkout dev

I get the message:

我收到消息:

The following untracked working tree files would be overwritten by checkout:

pages/memclub/images/subheaders/leadership.png
pages/memclub/images/subheaders/male.png
pages/memclub/images/subheaders/marketing.png
pages/memclub/images/subheaders/training.png

以下未跟踪的工作树文件将被 checkout 覆盖:

pages/memclub/images/subheaders/leadership.png
pages/memclub/images/subheaders/male.png
pages/memclub/images/subheaders/marketing.png
pages/memclub/images/subheaders/training.png

I dont want to commit the files to the master, they are not ready to be pushed.

我不想将文件提交给主人,他们还没有准备好被推送。

回答by Ethan Brown

First you'll want to add the files in question so that they're tracked by Git (you don't have to commit any changes, but Git needs to know about the files):

首先,您需要添加有问题的文件,以便 Git 跟踪它们(您不必提交任何更改,但 Git 需要了解这些文件):

git add pages/memclub/images/subheaders/leadership.png pages/memclub/images/subheaders/male.png 
git add pages/memclub/images/subheaders/marketing.png pages/memclub/images/subheaders/training.png

Then you can stash your changes:

然后你可以隐藏你的更改:

git stash 

When you're ready to start working on the files again, you can use:

当您准备好再次开始处理文件时,您可以使用:

git stash pop