0

My network from work doesn't let me clone any repository via Windows Git tool by command line git clone therefore I just download the repository.

My problem now is, I need to checkout by git checkout ###### but I cannot figure out how I can do that on my Windows 7. I have installed GitBash tool and Git Desktop, but as I said my network doesn't allow me to do much.

Annalix
  • 470
  • 2
  • 6
  • 17
  • 1
    If you have copied the repository to your local pc you can just use `git checkout BRANCH_NAME` and work in that branch. Git is keeping all the information in the repositories folder and coping is creating one to one copy of the repository on your local pc. But if you need to push commits you will need to add remotes. – Samvel Petrosov Feb 26 '19 at 09:41
  • 1
    Ask your system administrator how to work with git in the environment. Working around restrictions might land you in serious trouble. – vonPryz Feb 26 '19 at 09:43
  • @SamvelPetrosov thanks. I am trying to use - git checkout ### - in the same folder of the repository I downloaded, but I have the error -- fatal: not a git repository (or any of the parent directories): .git -- – Annalix Feb 26 '19 at 10:06
  • @vonPryz Thanks a lot. Actually I am having :). Trying to understand at which point. – Annalix Feb 26 '19 at 10:07
  • @Annalix are you sure that you are calling `git checkout` in the correct folder? The message is signaling that the folder from where you are calling `git checkout` is not git repository – Samvel Petrosov Feb 26 '19 at 10:10
  • @SamvelPetrosov I am in the same folder of the repository I downloaded (I couldn't clone). I think this the only folder where I can work – Annalix Feb 26 '19 at 10:31
  • What you downloaded was probably a bare repo, so you have to turn it into a regular sandbox. Can you clone locally? `git clone downloaded.git sandbox` does not do any downloading, so it should work, creating a copy you can work in. – joanis Feb 26 '19 at 12:17
  • Another option is to reverse the operation documented here: https://stackoverflow.com/questions/2199897/how-to-convert-a-normal-git-repository-to-a-bare-one I don't have time to test now, but reversing the steps described for regular -> bare might bring you back to regular. – joanis Feb 26 '19 at 12:20

1 Answers1

1

Option 1: local clone

Making a local clone should be your easiest option: it does not involve clone anything from the web so your administrator rules might allow it.

I'll assume you downloaded the remote into workspace/downloaded-bare.git:

cd workspace
git clone downloaded-bare.git sandbox

now you should be ready to work in workspace/sandbox.

Option 2: turn the bare into a working sandbox

If the local clone does not work, you can do the equivalent steps manually:

mkdir sandbox
cp -ar downloaded-bare.git sandbox/.git
cd sandbox
git init

and again, sandbox is now ready for normal work.

joanis
  • 10,635
  • 14
  • 30
  • 40
  • From the git page top right, I download a zip file that just unzip and have a folder. I don't have any git file. Where should I get it? – Annalix Feb 26 '19 at 14:31
  • So, if you clicked on Download ZIP in GitHub, what you have is not a Git repo at all, but just the code from the branch or commit you were viewing when you downloaded it, so no Git operations will work for you. However, you can navigate the the commit you're interested in on GitHub and download that as a different zip file. The 8th answer here discusses how to download a specific tag as a zipball: https://stackoverflow.com/questions/2751227/how-to-download-source-in-zip-format-from-github . – joanis Feb 26 '19 at 15:07
  • To answer your question more directly, the only way I know to get the `.git` file from GitHub is by using `git clone`. If that's not allowed on your network, you need to download the right zip ball from GitHub as per my previous comment. – joanis Feb 26 '19 at 15:09