我想在我的存儲庫中包含源文件(在有人克隆存儲庫時提供它),但默認情況下已將其更改忽略。git包含文件但未更改其內容
git update-index --assume-unchanged ...
不起作用,因爲它只適用於本地索引。我希望所有用戶都可以在默認情況下忽略文件。
.gitignore
不起作用,因爲如果我通過git add -f ..
跟蹤文件,則會跟蹤對其的更改。
我試圖實現會發生什麼,如果我svn add
編輯文件,然後svn:ignore
編輯它。
編輯:
看起來這恰恰是不可能的Git和我改變了源文件組織和構建在這個古老的顛覆行爲依賴。
例子:
$ git clone [email protected]:gsmith/sandbox.git
snip...
$ cd sandbox/
$ ls -a
. .. .git .gitignore gitignored tracked
$ cat .gitignore
gitignored
$ echo foo >> gitignored
$ git status
# On branch master
# 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: gitignored
#
no changes added to commit (use "git add" and/or "git commit -a")
我想這個文件被忽略。
$ git reset --hard HEAD
HEAD is now at 34b1f3d initial setup
$ git rm gitignored
rm 'gitignored'
$ git commit -m "test"
[master cd8199d] test
1 files changed, 0 insertions(+), 1 deletions(-)
delete mode 100644 gitignored
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
$ ls -a
. .. .git .gitignore tracked
$ echo foo >> gitignored
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
現在它被忽略。但是,克隆存儲庫的人將無法獲得gitignored
的內容。
沒有'.svnignore',只有svn:忽略屬性 – manojlds
@manojlds,謝謝,我已經糾正了這個問題。 –