我重命名了一个文件夹,git不再对其进行跟踪。我检查了我推送的远程仓库,奇怪的是,新名称的文件夹在那里,但没有内容。
我只是出于勤勉检查了我的.gitignore
,并且没有任何内容可以忽略此文件夹的内容。
我将其从web1
更改为web-domain
以更具描述性。
我使用此脚本推送
// pushes to am-godaddy
p-am-godaddy() {
git add -A .
git commit -m $a
git push am-godaddy master
}
答案 0 :(得分:2)
您对git add -A .
的使用将涵盖此案例。我对你正在经历的事情进行了模拟。重命名空文件夹将被忽略,文件夹名称更改(包含内容)将显示delete
并且未跟踪,直到您运行下一个git add -A .
更改为重命名事件:
➜ playing git:(master) ls -lah
total 72
drwxr-xr-x 16 basho staff 544B Jun 12 16:27 .
drwxr-xr-x 17 basho staff 578B Sep 3 03:44 ..
drwxr-xr-x 14 basho staff 476B Sep 6 13:16 .git
-rw-r--r-- 1 basho staff 68B Dec 25 2014 README.md
-rw-r--r-- 1 basho staff 4.5K Dec 25 2014 Vagrantfile
-rw-r--r-- 1 basho staff 0B Dec 25 2014 another
-rw-r--r-- 1 basho staff 0B Dec 25 2014 bob
-rw-r--r-- 1 basho staff 1.3K Jun 12 16:27 columns.md
-rw-r--r-- 1 basho staff 0B Dec 25 2014 file
-rw-r--r-- 1 basho staff 8B Dec 25 2014 junk
-rw-r--r-- 1 basho staff 60B Jan 1 2015 markdowntest.md
-rw-r--r-- 1 basho staff 141B Jan 17 2015 test.rb
-rw-r--r-- 1 basho staff 39B Dec 25 2014 vmware.stuff
-rw-r--r-- 1 basho staff 113B Dec 25 2014 vmware.stuff.orig
-rw-r--r-- 1 basho staff 0B Dec 25 2014 will-this-work
-rw-r--r-- 1 basho staff 0B Jan 1 2015 working
➜ playing git:(master) mkdir test
➜ playing git:(master) git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
➜ playing git:(master) ls
README.md another columns.md junk test vmware.stuff will-this-work
Vagrantfile bob file markdowntest.md test.rb vmware.stuff.orig working
➜ playing git:(master) touch test/file-in-test
➜ playing git:(master) ✗ ls
README.md another columns.md junk test vmware.stuff will-this-work
Vagrantfile bob file markdowntest.md test.rb vmware.stuff.orig working
➜ playing git:(master) ✗ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
test/
nothing added to commit but untracked files present (use "git add" to track)
➜ playing git:(master) ✗ git add .
➜ playing git:(master) ✗ git commit -m "adding folder with stuff in it"
[master 06996f3] adding folder with stuff in it
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test/file-in-test
➜ playing git:(master) git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
➜ playing git:(master) mv test/ other
➜ playing git:(master) ✗ ls
README.md another columns.md junk other vmware.stuff will-this-work
Vagrantfile bob file markdowntest.md test.rb vmware.stuff.orig working
➜ playing git:(master) ✗ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: test/file-in-test
Untracked files:
(use "git add <file>..." to include in what will be committed)
other/
no changes added to commit (use "git add" and/or "git commit -a")
➜ playing git:(master) ✗ git add -A .
➜ playing git:(master) ✗ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: test/file-in-test -> other/file-in-test
答案 1 :(得分:0)
使用文件夹层次结构时,请始终使用 git命令而不是正常的 bash命令。
这是使用 git mv 而不是 mv 。
如果你不这样做,Git会产生不期望的行为。当然记得Git跟踪文件而不是文件夹。