简体   繁体   English

GIT 分支结帐文件未更新

[英]GIT branch checkout files not updated

I have a branch testbranch created from master via GIT GUI.我有一个通过 GIT GUI 从 master 创建的分支 testbranch。 Currently I am on master on GIT command line.目前我在 GIT 命令行上掌握。

when I say "git branch -b testbranch" and "git checkout testbranch" , it says it switched to the testbranch but the files are not updated.当我说"git branch -b testbranch""git checkout testbranch" ,它说它切换到testbranch但文件没有更新。 I don't know why this strange behavior.我不知道为什么会有这种奇怪的行为。

Also what is difference between git branch testbranch and git branch -b testbranch .另外git branch testbranchgit branch -b testbranch之间有什么区别。

That is why the old obsolete and confusing git checkout command has been replaced by:这就是为什么旧的过时且令人困惑的git checkout命令已被替换为:

In your case, if the files are not correctly updated after a checkout, you can force them with:在您的情况下,如果文件在结帐后未正确更新,您可以使用以下命令强制它们:

git restore --source=HEAD --staged --worktree hello.c

(assuming you don't have any work in progress) (假设您没有任何正在进行的工作)

I have found out the answer.我已经找到了答案。

I just did below.我只是在下面做的。 Simple.简单的。

rm -rf reporsitory
git clone repository
git checkout testbranch.

It worked.!有效。!

Git is supposed to make life simple.. But it is making it complex instead with ambiguous keywords and commands. Git 应该让生活变得简单.. 但它使生活变得复杂,而不是用模糊的关键字和命令。 Why the hell on the earth can't we clone only a branch rather than the whole repo.为什么我们不能只克隆一个分支而不是整个 repo。 And why do we have two seperate commands to switch the branch and checkout the branch.为什么我们有两个单独的命令来切换分支和检出分支。

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

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