How can I move all my modification to a branch
I create a working repository in HG.
And I have modified some files.
How can i move my all my modification to a branch (a branch that I have not created)?
(kind of ‘git stash’ and the move the stash away change to a branch. Actually, I am not sure how I can do that in git either. If you know, I appreciate if you can tell me in git as well)
- Why does Git not store the branch name as part of the commit?
- Does SVN allow commit and push?
- How to deal with committer name change in Mercurial
- Ensuring a merge between branches happens in one direction
- Bitbucket authentication to use LibGit2Sharp
- Tips on upgrading CVS to git/hg?
2 Solutions collect form web for “How can I move all my modification to a branch”
First check to make sure that neither the ShelveExtension nor AtticExtension do exactly what you want.
If you’re doing it manually in mercurial I’d avoid a named branch, and just use another head. If for example, you already made the changes you want to “put away” for a little bit.
hg commit -m 'working on Xxx' # you created a new tip hg update -r -2 # switch to the revision before the tip
and now just start working there. You can find that anonymous branch later with
hg heads and merge it in with
For Git, if you have not yet committed your files, just type:
$ git checkout -b newbranch $ git commit -m "a message"
Every file staged at this point will be committed in the new branch.
For Mercurial, branches are not names by default, and a new branch only occurs (within one repo) if a commit has a parent which has already a child commit:
But you can create a new branch name for your next commit:
hg branch branch-1 # start a new branch name # modify something in the repository hg commit -m "branch-1" # the changeset has branch name "branch-1"
(See also a Guide to branching in Mercurial, and Git & Mercurial models)