git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Can't export whole repo as patches
@ 2006-04-07 18:47 Peter Baumann
  2006-04-07 19:18 ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Baumann @ 2006-04-07 18:47 UTC (permalink / raw)
  To: git

I'd like to export the whole history of a project of mine via patches
but I can't get the inital commit.

How can I get the inital commit as a patch?

That's what I tried:

  git --version
  git version 1.2.4				# debian sarge

  mkdir /tmp/testrepo && cd /tmp/testrepo
  git-init-db
  echo a > a_file.txt
  git-add a_file.txt
  git-commit -a -m "a_file added"
  echo b >> a_file.txt
  git-commit -a -m "a_file modifed"
  xp:/tmp/testrepo git-format-patch master~1
  0001-a_file-modified.txt
  cat 0001-a_file-modified.txt
  From nobody Mon Sep 17 00:00:00 2001
  From: Peter Baumann <peter.baumann@gmail.com>
  Date: Fri Apr 7 12:20:54 2006 +0200
  Subject: [PATCH] a_file modified

  ---

   a_file.txt |    1 +
   1 files changed, 1 insertions(+), 0 deletions(-)

  d8ceeed82a29004c066a98e0d390818e65fa9da7
  diff --git a/a_file.txt b/a_file.txt
  index 7898192..422c2b7 100644
  --- a/a_file.txt
  +++ b/a_file.txt
  @@ -1 +1,2 @@
   a
  +b
  --
  1.2.4


As you can see, there is only a patch of the second commit. But it seems that
this behaviour is correct, because I asked for the diff between master^..master

Obviously, I wanted a way to get the diff of master~2..master.

Trying harder:

  git-format-patch master~2
  Not a valid rev master~2 (master~2..HEAD)

Any hint to the correct way is appreciated.

</me thinking loudly>
The best would be if git would have an implicit tag or branch called "init"
(name doesn't really matter) which is the root of an empty repository. In that case
one can do git-format-patch root..master and it would the right thing.

Greetings,
  Peter Baumann

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: How to create independent branches
@ 2006-04-08 23:15 colin
  0 siblings, 0 replies; 11+ messages in thread
From: colin @ 2006-04-08 23:15 UTC (permalink / raw)
  To: peter.baumann; +Cc: git

  669  git-symbolic-ref HEAD refs/heads/slave
  670  echo "ref: refs/heads/master" > .git/HEAD
  671  git-symbolic-ref HEAD refs/heads/slave
  672  git add bar

> Another question. I'd like to create a totaly independent branch (like
> the "todo" branch in git). Is there a more user friendly way than doing
> 
> git-checkout -b todo
> rm .git/refs/heads/todo
> rm .git/index
> rm <all_files_in_your_workdir>
> 
> ... hack hack hack ...
> git-commit -a
> 
> I looked all over the docs, but can't find anything obvious.

If I undertstand, you basically want to create a second
initial commit, so you have two trees in your repository.

Well, an initial commit is just a commit object with no parents.

Try:
- Set up the workdir the way you want.  You have to git-add
  any newly added files, but git-update-index (called by
  git-commit -a) will remove from the index any files
  removed from the working directory, so you don't have to
  worry about those.
- Make sure refs/heads/todo doesn't exist
- "git-symbolic-ref HEAD refs/heads/todo"
  This makes HEAD a symlink (well, symref) to refs/heads/todo,
  which doesn't exist.
- git-commit -a
  Since the HEAD link doesn't exist, this does an initial
  commit.

It's not supremely user friendly, because multiple initial commits can
lead to problems down the road trying to merge, so you'd better know what
you're doing.

Another option is to just set up a second working directory, with a
shared object store, and do the checkin from there.  You can have the
.git/refs directories shared (via a symlink) or not.  If they're not
shared, you can later make them shared by copying over the relevant refs.


Oh, yes, note that if you fat-finger the "git-symbolic-ref HEAD" command,
any attempts to fix it will complain "not a git repository".
That's because a reference to refs/heads/ in HEAD is how git
identifies a repository.  "echo ref: refs/heads/master > .git/HEAD"
will fix it.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-04-09  8:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-07 18:47 Can't export whole repo as patches Peter Baumann
2006-04-07 19:18 ` Junio C Hamano
2006-04-08 18:02   ` How to create independent branches Peter Baumann
2006-04-08 18:28     ` Jakub Narebski
2006-04-09  8:11       ` Peter Baumann
2006-04-09  8:22         ` Peter Baumann
2006-04-08 20:49     ` Junio C Hamano
2006-04-08 20:57       ` Petr Baudis
2006-04-08 21:00         ` Junio C Hamano
2006-04-08 22:09         ` Johannes Schindelin
  -- strict thread matches above, loose matches on Subject: below --
2006-04-08 23:15 colin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).