Can't export whole repo as patches
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 <[email protected]> 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
Quoted 1 line · Peter Baumann
How can I get the inital commit as a patch?
format-patch is designed to get a patch to send to upstream, and does not handle the root commit. In your two revisions repository, you could do something like this:
$ git diff-tree -p --root master~1
Or more in general:
$ git rev-list master |
git diff-tree --stdin --root --pretty=fuller -pBTW, I've been meaning to add --pretty=patch to give format-patch compatible output to diff-tree, but haven't got around to actually do it. Another thing I've been meaning to do is "git log --diff" which is more or less "git whatchanged".
How to create independent branches
Quoted 12 lines · Junio C Hamano
Quoted 1 line · Peter Baumann
How can I get the inital commit as a patch?
format-patch is designed to get a patch to send to upstream, and does not handle the root commit. In your two revisions repository, you could do something like this:
$ git diff-tree -p --root master~1Or more in general:
Quoted 8 lines
$ git rev-list master | git diff-tree --stdin --root --pretty=fuller -pBTW, I've been meaning to add --pretty=patch to give format-patch compatible output to diff-tree, but haven't got around to actually do it. Another thing I've been meaning to do is "git log --diff" which is more or less "git whatchanged".
Ok. That did it.
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.
-Peter
Re: How to create independent branches
Quoted 8 lines · Peter Baumann
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>
Quoted 4 lines
... hack hack hack ...
git-commit -aI looked all over the docs, but can't find anything obvious.
My "todo" branch is not even part of my main git repository. I just have two independent repositories (git and todo) locally, and push into the same public repository.
Re: How to create independent branches
Dear diary, on Sat, Apr 08, 2006 at 10:49:04PM CEST, I got a letter where Junio C Hamano <[email protected]> said that...
Quoted 10 lines
Quoted 8 lines · Peter Baumann
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>
Quoted 8 lines
Quoted 4 lines
... hack hack hack ...
git-commit -aI looked all over the docs, but can't find anything obvious.
My "todo" branch is not even part of my main git repository. I just have two independent repositories (git and todo) locally, and push into the same public repository.
Wouldn't it be better to separate it to two distinct public repositories as well? It's confusing people and encouraging a practice that really isn't very feasible and practical in Git.
Signature · 4 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ Right now I am having amnesia and deja-vu at the same time. I think I have forgotten this before.
Re: How to create independent branches
Quoted 3 lines · Petr Baudis
Wouldn't it be better to separate it to two distinct public repositories as well? It's confusing people and encouraging a practice that really isn't very feasible and practical in Git.
That's mainly historical. I haven't bothered to check it recently, but /pub/scm/git was not writable by me on kernel.org machine, only /pub/scm/git/git.git/ was.
Re: How to create independent branches
In reply to Petr BaudisHi,
Quoted 10 lines · Petr Baudis
Dear diary, on Sat, Apr 08, 2006 at 10:49:04PM CEST, I got a letter where Junio C Hamano <[email protected]> said that...
Quoted 4 lines
My "todo" branch is not even part of my main git repository. I just have two independent repositories (git and todo) locally, and push into the same public repository.
Wouldn't it be better to separate it to two distinct public repositories as well? It's confusing people and encouraging a practice that really isn't very feasible and practical in Git.
How so? I find it highly practical, and do it myself. For example, I track a project which is not version-controlled at all. So I have a "branch" in git where I keep the tools to fake that version-controlling. And git makes it easy to just fetch the changes of both the project and my tools.
Ciao,
Dscho
Re: How to create independent branches
In reply to Peter BaumannQuoted 10 lines · Peter Baumann
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
Wouldn't it be better and more natural to go back to first commit, or even empty repository state at the beginning, and branch there? Or make separate repository?
Signature · 2 lines
Jakub Narebski Warsaw, Poland
Re: How to create independent branches
Quoted 10 lines · Jakub Narebski
Quoted 8 lines · Peter Baumann
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>
Quoted 4 lines
Quoted 2 lines
... hack hack hack ...
git-commit -aWouldn't it be better and more natural to go back to first commit? >
If I go back to the first commit, I'll get the following:
first / \ / \
master todo
That's not what I want, because in the near future I want to merge master and todo, but in my case, todo consists of only of one file (lets call it file_a), and the master branch has severeal files (file_{a..z}). If I go back to first, I have to delete all files file_{b..z}. Further file_a from todo and file_a from master are not equal, the share just the same name. But in the near future, they will be merged together, so they are equal.
If I go with the above branching, I'll _think_ (I may be wrong, please correct me if I am) I get a merge conflict or worse, all my other files file_a{b..z} are merged as "deleted", wich is wrong.
Quoted 1 line
Or even empty repository state at the beginning, and branch there?
This isn't possible because the repository already exists and I don't know how to go back to the empty repository state. Even
git-init-db
git branch todo master
didn't work.
Quoted 1 line
Or make separate repository?
Ok. You got it. In fact, the todo branch alread exists as a seperate repository and I'd like to integrate this in my master repository for easier handling (diff etc.)
To import todo as a subproject doesn't seem right, because it's not something really independent in the view of the master repo and I'am going to merge todo _into_ master in the near future.
Any further suggestions?
-Peter
Re: How to create independent branches
Quoted 51 lines · Peter Baumann
Quoted 10 lines · Jakub Narebski
Quoted 8 lines · Peter Baumann
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>Quoted 4 lines
Quoted 2 lines
... hack hack hack ...
git-commit -aWouldn't it be better and more natural to go back to first commit? >
If I go back to the first commit, I'll get the following:
first / \ / \master todo
That's not what I want, because in the near future I want to merge master and todo, but in my case, todo consists of only of one file (lets call it
file_a), and the master branch has severeal files (file_{a..z}). If I go back to first, I have to delete all files file_{b..z}. Furtherfile_afrom todo andfile_afrom master are not equal, the share just the same name. But in the near future, they will be merged together, so they are equal.If I go with the above branching, I'll _think_ (I may be wrong, please correct me if I am) I get a merge conflict or worse, all my other files file_a{b..z} are merged as "deleted", wich is wrong.
Quoted 1 line
Or even empty repository state at the beginning, and branch there?
This isn't possible because the repository already exists and I don't know how to go back to the empty repository state. Even
git-init-db
git branch todo masterdidn't work.
Quoted 1 line
Or make separate repository?
Ok. You got it. In fact, the todo branch alread exists as a seperate repository and I'd like to integrate this in my master repository for easier handling (diff etc.)
Quoted 6 lines
To import todo as a subproject doesn't seem right, because it's not something really independent in the view of the master repo and I'am going to merge todo _into_ master in the near future.
Any further suggestions?
Just in case nobody noticed, that's why I asked for exporting the whole repo with git-format-patch in the first place, because I'd like to import the patches with git-am in the totally independent branch.
Peter