Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a git uncheckout?

With git clone there is the option -n wich prevents a checkout of HEAD after the repository is cloned. Is there a possibility to do this manually?

Edit I think the option -n reads better in the manual than it actually is: After cloning with -n all my tools show that I still reside on the master branch; the only difference being that all files are shown as deleted. It’s not really the same situation that I would call ‘not checked out’.

So maybe I should just delete HEAD?

like image 579
Debilski Avatar asked Feb 22 '10 15:02

Debilski


People also ask

Can I revert a git checkout?

Git Checkout FileIf you stage and commit the checked-out file, this has the effect of “reverting” to the old version of that file. Note that this removes all of the subsequent changes to the file, whereas the git revert command undoes only the changes introduced by the specified commit.

What is git checkout master?

The git checkout command lets you navigate between the branches created by git branch . Checking out a branch updates the files in the working directory to match the version stored in that branch, and it tells Git to record all new commits on that branch.


1 Answers

The simplest solution would be to clone it bare:

git clone --bare your_repo bare_repo

(and delete your checked out repo)

Basically, you need to transform your repo into a bare one, which, according to this question, could be done manually with:

  • changing the .git/config file to have bare = true instead of bare = false
  • removing the contents of your_repo/* other than the .git file
  • moving the .git dir contents into your_repo/ and removing the .git dir

See also Git: Convert normal to bare repository, as mentioned by MikeSep in the comments.

If you need to uncheckout, keep bare to false, and simply remove everything but the .git. That should be like a git clone -n.

like image 120
VonC Avatar answered Sep 28 '22 02:09

VonC