save old git repository versions
Asked Answered
C

2

1

For the project I'm working on, I need to save all the files of a specific version of a git repository. I've looked through a fair amount of information regarding git checkout but I can't figure out what that does to the files in the directory I have, let alone save the version of that specific commit. Does anyone know a way to get the files of a git repository at a specific commit? Thanks.

Contiguity answered 12/6, 2012 at 17:40 Comment(0)
F
2

Do a "git export" (like "svn export")?

git checkout [commit sha]
git archive --format zip --output /full/path/to/zipfile.zip master

However, I don't know, why. Usually one use a vcs exactly because it saves every state, so why don't you just tag it and check it out, when you need it?

Frohman answered 12/6, 2012 at 17:52 Comment(2)
Is there any way to get the files without sending them to a .zip? I need them unpacked and if I were to unpack them all, I'd be here forever.Contiguity
Can't you unpack a whole archive? :? Must say: Sounds curious to me. However: After the checkout you have all files in the workspace. If you want to separate the checkout from the workspace you can use the first example in the link I provided (git archive master | tar -x -C /somewhere/else), or just make a local clone, checkout and remove git (git clone /local/path/to/repo /another/path; cd /another/path; git checkout [SHA]; rm -Rf .git;)Frohman
R
0

I think tag will help. Every time you like to save all the current files, type something like git tag -a v1.4 -m 'version 1.4'. So once you want those files back, commit or stash changes first, then type git checkout v1.4, the files will rollback to the time you tagged. Check these link for further infomation: how to tag and how to get them back.

Rounding answered 12/6, 2012 at 17:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.