0

I'd like to try out a few things with git and I don't want to screw anything up in the working repository.

To try to keep things safe, I've made a copy of the bare repo that I work from and from this repo I am intending to do all my pushes and tagging. I used:

cp --preseve -r original.git copy_of_original.git

Although I understand one can undo bad commits and whatnot, I don't want to leave the repo with all these reverted commits, nor do I want to do any refactoring, hence my desire to just work from a duplicate, bare repository.

The problem is, I execute the following:

git diff --name-only master@{"5 day ago"} master

and get back:

warning: Log for 'master' only goes back to Fri, 15 Feb 2013 20:42:43 -0500.

The original repo, which I don't want to touch, does indeed have files which were modified as of 5 days ago.

If I perform git log on my copied repo, the record of these 5 day old changes are all still there.

What is going on here?

Is there a better way to make an independent copy of the repository?

Update 1

I realized I was imprecise with my question. I had run:

git diff --name-only master@{"5 day ago"}

in the directory produced from:

git clone copy_of_original.git clone_of_copy
Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
EMiller
  • 2,792
  • 4
  • 34
  • 55

3 Answers3

1

The @{5 days ago} syntax relies on information from the reflog, as explained in the section of the git-rev-parse documentation quoted below. Reflogs are local to a repository, and never transferred by clone, fetch or push. This is not the information displayed by git log, unless the -g or --walk-reflogs option is used.

Bare repositories generally don't keep reflogs, so a copy of the repository wouldn't have that information either.

<refname>@{<date>}, e.g. master@{yesterday}, HEAD@{5 minutes ago}
    A ref followed by the suffix @ with a date specification enclosed in a brace pair
    (e.g.  {yesterday}, {1 month 2 weeks 3 days 1 hour 1 second ago} or {1979-02-26
    18:30:00}) specifies the value of the ref at a prior point in time. This suffix may
    only be used immediately following a ref name and the ref must have an existing log
    ($GIT_DIR/logs/<ref>). Note that this looks up the state of your local ref at a
    given time; e.g., what was in your local master branch last week. If you want to
    look at commits made during certain times, see --since and --until.
qqx
  • 18,947
  • 4
  • 64
  • 68
  • Then if I do a `git pull` on my local copy of a repository, will the result of running `git diff --name-only master@{"5 day ago"}` be using the date I did `git pull` instead of when people made commits? – EMiller Feb 16 '13 at 02:37
  • `@{time}` never uses time of commit. There isn't a way that could work in general since there can be multiple branches in the history and commits are not always in date order (either because of rearranging commits or somebody having a clock set incorrectly). – qqx Feb 16 '13 at 02:40
  • But isn't there a way to reliably query if any files in master have been updated, via a merge or commit, since a period of time? – EMiller Feb 16 '13 at 02:48
  • I'd advise asking that as a new question. It will attract more attention, and may be easier to answer without the limitations of using comments. – qqx Feb 16 '13 at 02:55
  • Done! http://stackoverflow.com/questions/14906503/git-how-can-i-reliably-query-if-any-files-in-master-have-been-updated-via-a-m Thanks for your response, btw. – EMiller Feb 16 '13 at 03:10
0

Each clone includes a full copy of the repository (in the case where you have a single branch, master), inside the .git directory. Each copy independent of the others, and gets modified by local commits, or when you pull from an other repository.

So a recursive copy is perfectly fine.

As for what you see, you need to provide more details, and a more complete list of commands you run.

Pascal Belloncle
  • 11,184
  • 3
  • 56
  • 56
0

If you clone, only part of the stuff is copied, if you copy, you have an identical version of the original repository. That works fine with git; can backup and restore, etc.

vonbrand
  • 11,412
  • 8
  • 32
  • 52