我在分支「feature
」。在我做了所有改變之後,我決定在這個分支上進行我的工作。Git commit在我的情況下
我首先檢查我已經通過執行命令所做的所有修改:
git status
以上的git命令打印出如下結果:
On branch feature
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: MyApp/src/Main.java
# modified: MyApp/src/Model.java
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# MyApp/src/other/file1
# MyApp/src/other/file2
正如你看到的上面,有兩個未追蹤檔案file1
和file2
。我不想讓他們在我的git倉庫中。但由於某些原因我忘了這兩個文件&直接提交我的變化是:
git add .
git commit -m "Some changes"
在這一點上,所有的變化,包括file1
& file2
上犯下。現在,我怎麼能救自己排除file1
& file2
但仍然保持其他修改的變化被提交?
(請不要建議我刪除file1
& file2
從磁盤,我需要他們在我的本地磁盤上)
請參閱撤消在https://www.kernel.org/pub/software/scm/git/docs/git-reset.html中的commti和redo請參閱 – dekdev