What will happen if I delete the HEAD
and FETCH_HEAD
under directory .git?
I did delete these files and and made some changes to README.txt
tried pulling and pushing(without creating any branches). It worked fine.
Will it create problems if I do more serious things? like rebasing and resetting?
How Git keeps tracks of which current branch I am working on? I thought HEAD
and FETCH_HEAD
supposed to signify those things. What are all the files and directories under .git
that I can delete and still the git will continue to work?
In other words, what are the bare essential things under .git
necesssary for git to work locally and with remote flawlessly?
$ 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 git@gitlab.com: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