Linus Torvalds <[email protected]> writes:
>> I accidently committed this to an up-to-date master branch, as
>> I forgot to check out the temporary branch I was going to commit
>> it on. Swapping the sums from .git/refs/heads/{master,read_mostly}
>> wouldn't break anything, if the only different between the two was
>> this commit, right?
>
> Correct. The branch head files really are just plain ascii references to
> the top commit, you can rename branches by just renaming the file (and
> thus switch branches by just cross-renaming them, ie just switching the
> contents).
Careful.
If one of the swapped branches is your current branch
(i.e. pointed at by .git/HEAD), you need to remember to
switch that as well.
For example, after making the mistake of committing to "master":
$ git commit ;# oops, to the master
$ git show-branch origin master read_mostly
! [origin] latest update from Linus
* [master] latest for read_mostly
! [read_mostly] last update from Linus
---
+ [master] latest for read_mostly
+++ [origin] last update from Linus
Then swap heads:
$ read_mostly_head=`cat .git/refs/heads/master`
$ cat .git/refs/heads/read_mostly >.git/refs/heads/read_mostly
$ echo "$read_mostly_head" >.git/refs/heads/read_mostly
At this point:
* Your index file still matches $read_mostly_head
* Your working tree matches your index file
* Your .git/HEAD is pointing at .git/refs/heads/master
Essentially, you are (you want to be) in read_mostly branch, but
your .git/HEAD incorrectly says you are on the master branch.
So you would need:
$ git symbolic-ref HEAD refs/heads/read_mostly
after swapping. Then you would be on read_mostly branch.
$ git show-branch origin master read_mostly
! [origin] latest update from Linus
! [master] last update from Linus
* [read_mostly] latest for read_mostly
---
+ [read_mostly] latest for read_mostly
+++ [origin] last update from Linus
BTW, would people object if I made the show-branch output like
this?
$ git show-branch origin master read_mostly
! [origin] latest update from Linus
! [master] last update from Linus
* [read_mostly] latest for read_mostly
---
* [read_mostly] latest for read_mostly
++* [origin] last update from Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]