我是git的新手,我一直在尝试理解为什么git一直在显示我在另一个分支中的一个分支中所做的更改,当我运行git checkout在分支之间切换时,首先我试着不使用git add,但没有起作用。然而,我随后尝试使用git add,但没有解决这个问题。我还没有使用git commit。
这基本上就是我要做的:
$ git clone <a_repository>
$ git branch
* master
$ git branch testing
$ git checkout testing
...edit a file, add a new one, delete...
$ git status
# On branch testing
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: file1.txt
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# file2.txt
no changes added to commit (use "git add" and/or "git commit -a")
$ git branch
master
* testing
$ git checkout master
D file1.txt
Switched to branch 'master'
$ git status
# On branch master
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: file1.txt
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# file2.txt
no changes added to commit (use "git add" and/or "git commit -a")
我认为,当使用分支时,无论你在一个分支中做什么,它对所有其他分支都是不可见的。这不就是创建分支的原因吗?
我尝试使用"git add“,但更改在两个分支中都可见。在分支之间切换之前,我需要运行"git commit“来避免这种情况吗?
https://stackoverflow.com/questions/5531362
复制相似问题