将项目导入Git时,如何保留连续版本的日期? [英] How can I preserve the dates of the successive versions while importing a project into Git?

查看:139
本文介绍了将项目导入Git时,如何保留连续版本的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的桌面上有一个文件夹,内容如下:

  SABS / 
| -SABS v0。 1b /
| -sabs.sh
| -SABS v0.2b /
| -sabs.sh
| -SABS v0.3b /
| -sabs sh
| -SABS v0.4b /
| -sabs.sh
| -SABS v0.5b /
| -sabs.sh

这些文件夹中的每一个都是一个脚本文件。每个脚本文件与他们有不同的日期。



我开始使用这个脚本,然后才能使用Git。我的问题是:是否可以保留使用Git创建文件的历史记录和时间并导入它们?



这样当您查看 sabsv0.1 它将显示创建日期,但不显示将其导入到Git的日期。

解决方案


[...]是否可以保留使用Git创建文件的历史和时间,导入他们?


默认情况下, git commit 将当前系统日期结果提交。但是,您可以使用 - date 标记覆盖该行为。



因此,您可以


  1. 创建名为 SABS_git (例如)和 cd ;

  2. 通过运行

    初始化Git回购

      git init 


  3. 复制 SABS v0.1b / sabs。 sh into SABS_git /


  4. stage sabs.sh ,并提交所需的日期:

      git add sabs.sh 
    git commit --date =< desired-date>

    其中<期望日期> 可以例如,$ code> 2014/01/01


  5. 写一个描述性的提交消息。 p>


  6. 将步骤3-5应用到下一个版本的 sabs.sh 直到耗尽。

如果您有很多版本,您可能需要编写一个shell文件来自动执行其中的一些步骤;你可能希望每次写一个有意义的提交信息,但不能自动化。


I have a folder on my desktop with the following contents:

SABS/
|-SABS v0.1b/
  |-sabs.sh
|-SABS v0.2b/
  |-sabs.sh
|-SABS v0.3b/
  |-sabs.sh
|-SABS v0.4b/
  |-sabs.sh
|-SABS v0.5b/
  |-sabs.sh

Inside each of these folders is a script file. Each script file has a different date associated with them.

I started working on this script before realizing I could use Git.

My question is: is it possible to keep the history and the times when the files were created using Git and import them? That way when you look at sabsv0.1 it will show the date in which it was created, but not the date in which it was imported to Git.

解决方案

[...] is it possible to keep the history and the times when the files were created using Git and import them?

By default, git commit bakes the current system date into the resulting commit. However, you can override that behavior with the --date flag.

Therefore, you could

  1. create a folder called SABS_git (for instance) and cd to it;
  2. initialise a Git repo by running

    git init
    

  3. copy SABS v0.1b/sabs.sh into SABS_git/.

  4. stage sabs.sh, and commit with the desired date:

    git add sabs.sh
    git commit --date=<desired-date>
    

    where <desired-date> can be, for instance, 2014/01/01.

  5. write a descriptive commit message.

  6. apply steps 3-5 to the next version of sabs.sh until exhaustion.

If you have many versions, you might want to write a shell file for automating some of those steps; you probably want to write a meaningful commit message each time, though, which cannot be automated.

这篇关于将项目导入Git时,如何保留连续版本的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆