1
跟着Version Control with Git 2nd ed,沒有得到與本書相同的結果。我錯過了什麼嗎?這是本書的例子。.gitignore上的不同結果
$ cd /tmp/my_stuff
$ git init
$ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
$ echo "New data" > data
$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# data
nothing added to commit but untracked files present (use "git add" to track)
# Manually create an example junk file
$ touch main.o
$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# data
# main.o
$ echo main.o > .gitignore
$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
# data
但對我來說echo main.o > .gitignore
後,git status
是顯示main.o
不會被忽略,並呈現出在未跟蹤文件。
編輯:在這個例子中沒有提交所以git rm -r --cached .
,給我fatal: pathspec '.' did not match any files
。我也曾嘗試commiting data
,並main.o
,然後
>>touch .gitignore
>>git rm -r --cached .
>>git add .
>>git commit -m ".gitignore is stil not ignoring main.o"
嘗試清理項目的緩存。 'git rm -r --cached .' –
請顯示'.gitignore'文件內容 –
'$ echo main.o> .gitignore'正在創建'.gitingore'作爲文件內容'main.o'。我也編輯了問題,以反映我到目前爲止所嘗試的內容。 –