這是很簡單的,如果你有,如果你改變一個特定的分支將被修改的文件更改。
例子:
$ git init
Initialized empty Git repository in /tmp/asadfasd/.git/
$ echo 1 > bar
$ git commit -am "commit 1 master"
[master (root-commit) 55da003] commit 1
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 bar
$ git co -b testbranch
Switched to a new branch 'testbranch'
$ git co master
Switched to branch 'master'
$ echo 2 >> bar
$ git commit -am "commit 2 master"
[master c6dc6d9] commit 2 master
1 files changed, 1 insertions(+), 0 deletions(-)
$ git co testbranch
Switched to branch 'testbranch'
$ echo 3 >> bar
$ git co master
error: Your local changes to the following files would be overwritten by checkout:
bar
Please, commit your changes or stash them before you can switch branches.
Aborting
如果你想修改它的工作,因爲該文件將無法進行修改的文件之前重訂上主testbranch。
另一種方式來說,如果分支分歧,你修改分歧的文件它將無法正常工作。
@Alok - 這個問題是重複所有權利,但不是你鏈接到的那個! – manojlds