* Why does 'git branch -d' act differntly after clone?
@ 2015-08-20 12:10 Konstantin Hollerith
2015-08-20 15:49 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Konstantin Hollerith @ 2015-08-20 12:10 UTC (permalink / raw)
To: git
Hi,
I created a simple repository.
If i create a new branch from master and commit some changes and
then delete it with
git branch -d neuerTestBranch
I'll get a error:
error: The branch 'neuerTestBranch' is not fully merged.
I like that error, it reminds me, that i forgot to merge.
However, if i don't delete this branch and clone the Repository somewhere
else, i don't get the error anymore. When i delete the branch now, i get
this message:
warning: deleting branch 'neuerTestBranch' that has been merged to
'refs/remotes/origin/neuerTestBranch', but not yet merged to HEAD.
And the Branch is deleted right away.
Why does git branch -d acts differently after a clone?
Is this behavior maybe a Bug?
Is it possible to force a behavior like the first in cloned repositories,
too?
I use 'git version 2.5.0.windows.1'.
Cheers,
Konstantin
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Why does 'git branch -d' act differntly after clone?
2015-08-20 12:10 Why does 'git branch -d' act differntly after clone? Konstantin Hollerith
@ 2015-08-20 15:49 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2015-08-20 15:49 UTC (permalink / raw)
To: Konstantin Hollerith; +Cc: git
Konstantin Hollerith <khollerith@gmail.com> writes:
> Why does git branch -d acts differently after a clone?
In the former case, that branch is the only thing that knows about
the commits near the tip of it. Immediately after you clone that
repository, you have a copy of that branch as a remote-tracking
branch for origin/neuerTestBranch. You didn't say how you got a
local copy of it in there, but I'd imagine that in the clone you did
something like:
$ git checkout neuerTestBranch
which is a short-hand for
$ git checkout -b neuerTestBranch origin/neuerTestBranch
and then went back to a branch other than that branch when you asked
the branch to be removed, e.g.
$ git checkout master
$ git branch -d neuerTestBranch
without building any further history on neuerTestBranch.
Now, your local neuerTestBranch is a mere unmodified copy of the
remote-tracking branch origin/neuerTestBranch; the commits on the
former will not become unreachable if you remove neuerTestBranch,
because they are all reachable via origin/neuerTestBranch. And that
is why the deletion of it has less severe potential of information
lossage, compared to the original case where you attempt to remove
the only copy.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-20 15:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-20 12:10 Why does 'git branch -d' act differntly after clone? Konstantin Hollerith
2015-08-20 15:49 ` Junio C Hamano
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.