如何使用 git 签出功能?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14370693/
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
How do I checkout a feature with git?
提问by Luigi R. Viggiano
I created a feature a few weeks ago with git and did some work on it and had to stop. Now I want to start working on it again but each time I use git branch -a
to get the name of the available branches I can see it as
几周前我用 git 创建了一个功能,并做了一些工作,不得不停下来。现在我想再次开始处理它,但是每次我git branch -a
用来获取可用分支的名称时,我都可以将其视为
remotes/origin/feature/upgrade-free-premium
but when I run git checkout upgrade-free-premium
I get the following error.
但是当我运行时git checkout upgrade-free-premium
出现以下错误。
error: pathspec 'upgrade-free-premium' did not match any file(s) known to git.
Could someone help me solve this?
有人可以帮我解决这个问题吗?
回答by Luigi R. Viggiano
Try this:
尝试这个:
git checkout -b upgrade-free-premium origin/feature/upgrade-free-premium
In your case, the branch is a remote one. You need to specify from which branch you want to checkout: so the correct branch name is origin/feature/upgrade-free-premium
. This, because other origins can have the same branch name, so you need to specify the full name.
在您的情况下,分支是远程分支。您需要指定要从哪个分支结帐:因此正确的分支名称是origin/feature/upgrade-free-premium
. 这个,因为其他origin可以有相同的分支名,所以需要指定全名。
The -b
is necessary to create a local branch to track the remote branch.
在-b
有必要创建一个本地分支追踪远程分支。
回答by Jonah
Your branch is named feature/upgrade-free-premium
('/' can be part of the branch name).
您的分支已命名feature/upgrade-free-premium
(“/”可以是分支名称的一部分)。
Run git checkout feature/upgrade-free-premium
instead.
运行git checkout feature/upgrade-free-premium
代替。
回答by ayushman das
I assume you have your feature branch from develop 1. git checkout develop 2. git pull 3. git checkout 4. git pull
我假设你的特性分支来自 develop 1. git checkout develop 2. git pull 3. git checkout 4. git pull
回答by Agile Nerd
I had the same problem and I solved it by doing git pull
first and then git checkout <feature>
:)
我遇到了同样的问题,我通过先做git pull
然后再做来解决它git checkout <feature>
:)