Re: [git-users] Re: How to "move" the master?
Hi, > If it's just a local repository (probably not) you can just rename the > branches, I'll use the branch name dev_branch to stand in for your > feature branch: > > git branch -m master old_master > git branch -m dev_branch master How about if I have shell access to the server where the project lives? Can I just log into the server and do these simple renames there? Thanks, David Bruce -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To post to this group, send email to git-us...@googlegroups.com. To unsubscribe from this group, send email to git-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/git-users?hl=en.
Re: [git-users] Re: How to "move" the master?
On Fri, Aug 13, 2010 at 2:44 PM, David Bruce wrote: > Hi, > > Along these lines, we are in a somewhat similar situation. Basically, > we have had a major feature branch for a GSoC project, and this branch > has now substantially diverged from master. However, the divergence > is almost completely due to equivalent work that was done first in > master, and then re-done "by hand" in the feature branch because it > was too hard to merge (we are git noobs). So, we want to make master > point to the new branch, and rename master to something like > old_master for safekeeping. So it looks like we should first create a > branch (or tag) to save the tip of master, and then hard reset master > to the tip of the feature branch. > If it's just a local repository (probably not) you can just rename the branches, I'll use the branch name dev_branch to stand in for your feature branch: git branch -m master old_master git branch -m dev_branch master If the branches are remote you should be able to rename and end up with tracking branches with something like this: First rename the current master branch git push origin master:refs/heads/old_master Create the branch old_master in the origin repository by copying the current master branch. git fetch origin Fetch updates from the remote repository git branch --track old_master origin/old_master create a tracking branch git checkout old_master git push origin :refs/heads/master Delete the remote master branch, remember that a branch is just a pointer to a commit, and deleting it doesn't delete the commit or any other commits git branch -d master Delete the local master branch Now rename the dev_branch to be the new master branch: git checkout dev_branch git push origin master:refs/heads/dev_branch git fetch origin git branch -track master origin/master git checkout master git push origin :refs/heads/dev_branch git branch -d dev_branch The last two steps (which delete the remote and local dev_branch are optional) There may be more efficient ways to do this. I use the grb ruby gem to handle tasks like this and this is how it approaches renaming a remote branch. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To post to this group, send email to git-us...@googlegroups.com. To unsubscribe from this group, send email to git-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/git-users?hl=en.
Re: [git-users] Re: How to "move" the master?
Hi, Along these lines, we are in a somewhat similar situation. Basically, we have had a major feature branch for a GSoC project, and this branch has now substantially diverged from master. However, the divergence is almost completely due to equivalent work that was done first in master, and then re-done "by hand" in the feature branch because it was too hard to merge (we are git noobs). So, we want to make master point to the new branch, and rename master to something like old_master for safekeeping. So it looks like we should first create a branch (or tag) to save the tip of master, and then hard reset master to the tip of the feature branch. DSB -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To post to this group, send email to git-us...@googlegroups.com. To unsubscribe from this group, send email to git-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/git-users?hl=en.
Re: [git-users] Re: How to "move" the master?
On Thu, Aug 12, 2010 at 1:09 PM, jd wrote: > On Aug 12, 3:18 am, Konstantin Khomoutov wrote: >> >> That's because you created a situation known as "detached HEAD". >> >> > How can I fix this? I want "master" to point to the same place as HEAD. >> >> Record the name of the commit HEAD points at, checkout master and >> "hard reset" it to that commit. The simplest way to do that is via a >> branch or tag: >> $ git tag foo >> $ git checkout master >> $ git reset --hard foo >> $ git tag -d foo > > Thank you for the help, that seems to have fixed the problem. > > One question: why is the "git checkout master" needed? (What would > have happened if I had done the hard reset when the "detached head" > was checked out?) Note that there is a HEAD for each branch, it points to the commit at the tip of that branch. The command git reset changes which commit HEAD points to for the current branch. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To post to this group, send email to git-us...@googlegroups.com. To unsubscribe from this group, send email to git-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/git-users?hl=en.