How to check from git

Until now, being the only person in the project, I copied / pasted the folders of my project and renamed them (Ver1, Ver2, Ver3, etc.) as a version control scheme. Now I am trying to upgrade to Git.

This is what I did:
I initialized the .git folder and added the first version to the Git repository. Then I added all the other versions that are compiled into the Git repository and tagged. So, now I have all the versions in the main branch and as tags.

My question is:
How can I (I don’t know if the right word is), take any version from the Git repository and put it in an arbitrary folder without switching branches (or any other Git operation might seem like it should do)? Just copy the version (any version) from Git to a folder without any connection between the Git repository and the folder?

+4
source share
3 answers

Usually you look at historical versions directly in your normal working tree (you can check any commit as a "detached HEAD" / "unnamed branch") or indirectly view the history using git log (especially the -p option), git blame , etc.

But if you really need to completely unzip the old version, you can use the git archive command to create a tarball specific commit 1 (tag name, branch name (you will get its feedback), or commit object identifier (i.e. SHA hash value -1) will work to indicate commit). You can easily pass the archive to tar to extract it wherever you want.

From the directory of your repository:

 git archive --format=tar branch-or-tag-name-or-commit-id | (mkdir /path/to/destination && cd /path/to/destination && tar xf -) 

git archive will always work for local repositories. It can also be used with non-local repositories (or local repositories not based on your current working directory) with the --remote option; not all Git hosting services can allow archiving (they may not want to waste CPU time or bandwidth).


1 Actually, you can use git archive with any tree (i.e. the Root directory or any subdirectory represented in any commit), but this is most often used with branch hints, tags and commits.

+2
source

do:

 git clone (path to your repo) 

or if you don't need .git metadata:

 git archive (branch) 
+1
source

Your question:

How can I (I don’t know if verification is the right word) take any version from the GIT repository and put it in an arbitrary folder without switching branches (or any other GIT operation might think that it should be done)?

You want to use the GIT checkout command:

 git checkout myTag1.2.3 git checkout asdf81274982shjsks git checkout origin/develop 

The argument to check can be either a branch, or a tag, or a SHA1 hash.

You ALWAYS get a complete repository. You cannot check parts of it. Remember that GIT stores snapshots of the complete repository.

0
source

Source: https://habr.com/ru/post/1345071/


All Articles