如果我刪除目錄.git下的HEAD
和FETCH_HEAD
會發生什麼?如果我在.git下刪除HEAD和FETCH_HEAD將會發生什麼
我確實刪除了這些文件,並對README.txt
進行了一些更改,嘗試了拉和推(不創建任何分支)。它運行良好。
如果我做更嚴肅的事情,它會產生問題嗎?像重新設置和重置?
Git如何保持跟蹤我正在使用的當前分支?我認爲HEAD
和FETCH_HEAD
應該表示這些事情。 .git
下的所有文件和目錄是什麼,我可以刪除,但仍然會繼續工作?
換句話說,根據.git
,git在本地工作和遠程完美工作必不可少?
$ pwd
/home/arulmozhi/_/remote-repo/.git
$ rm HEAD
$ cd ..
$ git pull
Already up-to-date.
$ cat README.md
this stuff is from dummy branch
First file in repo which is to be synced across multiple remotes - gitlab and github
$ emacs -nw README.md
$ git commit -am "what happens when we rename/delete .git/HEAD"
[master 34d647b] what happens when we rename/delete .git/HEAD
1 file changed, 2 insertions(+), 1 deletion(-)
$ 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
$ git push
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 401 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
To [email protected]:remote-repo/remote-repo.git
fa76250..34d647b master -> master
$ uname -arn
Linux koparakesari 3.19.0-31-generiC#36~14.04.1-Ubuntu SMP Thu Oct 8 10:21:08 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ ls -1 .git
branches
COMMIT_EDITMSG
config
description
hooks
index
info
logs
objects
packed-refs
refs
如果你想讓所有的東西都能夠完美地工作,假設你不應該碰自己的'.git'。任何完全記錄任何手動更改結果的答案對於堆棧溢出來說都太廣泛了。 – chepner
這意味着你必須在'/ home/arulmozhi/_'或'/ home/arulmozhi'中有另一個.git文件夾:'remote-repo'文件夾可以是一個嵌套的git倉庫。 – VonC