Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
636 views
in Technique[技术] by (71.8m points)

backing up project which uses git

I'm burning my stuff on a dvd, before a quick reinstall. Never done that with git, being a recent user. So I'm just checking with you guys. If I understood correctly, I just need to backup my project directory project_name (which has .git inside it) watching for hidden files along with it, and when I copy it onto the "new" machine, and install git again, I resume like nothing happened ? Correct ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you only want to backup project files (without history), you can use git archive (that way, I do not have to "watch for hidden file")

The script git-archive-all.sh will actually archive all git repositories and submodules in the current path.

Useful for creating a single tarfile of a git super-project that contains other submodules.


As Charles Bailey rightly mentions in the comments, git bundle is more appropriate, to preserve the history. (git bundle was introduced in February 2007).

See Backing up a git repository with git bundle

git bundle was designed to allow transfer of git commits when there is no direct connection between repositories (i.e.: offline) but using patches is not an option because of the large number of commits and multiple branches.
A git bundle is just one file which can be very easily created and again imported as it can be treated like another remote. A quick example:

jojo@dualtron:~/devel$ git bundle create ~/devel.bdl master test 

and a bundle is saved under ~/devel.bdl containing my master and test branches.
If I am now at repository B I just use jojo@dualtron:~$ git ls-remote devel.bdl which shows me the branches stored in the bundle.
To use the bundle I simple treat it like a remote, using git fetch (for example)

jojo@dualtron:~/git/repoB$ git fetch ~/devel.bdl refs/heads/*:refs/remotes/bundle/*

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...