如何手动将项目的备份副本导入Git?

时间:2011-12-20 03:01:40

标签: windows git version-control

手动制作我的小项目的分支和副本后,我终于尝试使用没有经验的git。如何导入所有这些手册副本?

1 个答案:

答案 0 :(得分:2)

如果您认为将所有旧历史导入Git是值得的,那么就可以这样做。但是,手动导入历史记录可能非常繁琐,尤其是对于多个分支。有些人已编写脚本将现有VCS中的代码导入Git,但显然这不会直接适用于您的手动副本。

我会考虑你是否真的需要 Git中的所有历史副本。如果没有,那么就开始使用当前代码的基本Git操作,并从现在开始向前移动。

如果您仍想手动导入历史记录,请按以下方式执行此操作:

# create a new repository in the current directory
git init

# get snapshot #1 from files1
cp ~/backup/files1/* .
git add .
git commit -m "files1 snapshot"

# get shapshot #2 from files2
cp ~/backup/files2/* .
git add .
git commit -m "files2 snapshot"

# get snapshot in files_test into test_branch
git checkout test_branch
cp ~/backup/files_test/* .
git add .
git commit -m "files_test snapshot on branch test_branch"

如果您在修订版之间删除了文件,则还必须使用git rm以及git add来完整记录历史记录。高级使用上述功能可以让您将提交日期和时间从当前时间更改为您喜欢的任何时间戳。