Re: erratic behavior commit --allow-empty
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Oct 3, 2012, 11:07 UTC
- Message-ID
- <vpqvcer4xvo.fsf@grenoble-inp.fr>
- In-Reply-To
- <CAB9Jk9DFb2s4s00yCNUytxFdrOQKPEKZGsXpKzwZDo5WAOdXaQ@mail.gmail.com>
Angelo Borsotti <angelo.borsotti@gmail.com> writes:
>> You still didn't tell us where the problem was. > > I described it few mails above. I wanted to create an orphan branch.
And you did. The branch happens to point to the same commit as another existing commit, but this is a very common situation. Try this:
# do arbitrary hacking and commit on branch master git checkout -b new-branch gitk
You will see branches "master" and "new-branch" pointing to the same commit (but you HEAD points to new-branch, as "git branch" will tell you).
You still did not describe a _problem_. Up to now, the only "problem" I see is that you have twice the same sha1 showing up, but you did not describe somethine concrete that you wanted to do and did not work.
> However, the branch is not actually created until a commit is done on > it.
Right, but the definition of "done" in your sentence includes "reusing an object in the object database".
I just tried this:
rm -fr test git init test cd test date > foo.txt git add . git commit --allow-empty -m foo git checkout --orphan new-branch git commit --allow-empty -m foo
I ended up with a branch "master" and a branch "new-branch", both pointing to the same commit. The new branch _is_ created.
(BTW, --allow-empty is useless here as you have no parent)
-- Matthieu Moy http://www-verimag.imag.fr/~moy/