ฉันใหม่มากสำหรับคอมไพล์และฉันพยายามทำความเข้าใจว่าทำไมคอมไพล์จึงแสดงสิ่งที่ฉันเปลี่ยนแปลงในสาขาหนึ่งในอีกสาขาหนึ่งเมื่อฉันเรียกใช้ git checkout เพื่อสลับไปมาระหว่างสาขาก่อนอื่นฉันพยายามไม่ใช้ git add และไม่ได้ผล อย่างไรก็ตามฉันลองใช้ git add แล้ว แต่ไม่สามารถแก้ไขปัญหาได้ ฉันยังไม่ได้ใช้คอมมิตคอม
นี่คือสิ่งที่ฉันกำลังทำอยู่:
$ 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" แต่การเปลี่ยนแปลงสามารถมองเห็นได้ในทั้งสองสาขา ฉันต้องเรียกใช้ "คอมมิต" ก่อนที่จะสลับไปมาระหว่างสาขาเพื่อหลีกเลี่ยงปัญหานี้หรือไม่