Re: git branch --switch?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Apr 17, 2007, at 9:36 AM, Rene Herman wrote:

Is it possible to switch the current branch without checking it out? Not really essential, but I'm happily flaundering around with git and still start from scratch fairly regularly; to speed this up I've found the -n switch to git clone useful and would like something similar when reconstructing my "branch hierarchies".

Upto now I only know about "git checkout" (with or without -b) to switch the current branch. As said it's not really essential, but I was expecting there would be something like a "branch --switch". Did I overlook it?

Perusing git-checkout points me to git-symbolic-ref to update the HEAD ref to a new branch:

git symbolic-ref HEAD refs/heads/<branch>

However, I'm somewhat confused as to why you'd want HEAD and the working directory to get out of sync. It would cause any further commits to have broken history information. If you want to make the content of one branch ($branchA) the same as the other ($branchB), you should do something like:

git checkout -b temp $branchB    # Get content from branchB
git merge -s ours $branchA # Merge history (not content) from branchA
git branch -M $branchA           # Make this new merge branchA

This would be significantly simpler if there was a "theirs" merge strategy "git checkout $branchA; git merge -s theirs $branchB", but there isn't. Should be simple to write if you really need it though.

~~ Brian
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]