Reputation: 16276
I am working on a feature branch branch1
, my work is not done yet and still unstable, and I need to switch back to develop branch to create a new branch, branch2
for a new feature. How can I do that in a way to "freeze" branch1
as I am planning to get back to work on it. Is there any way to do that without committing branch1
? and what's the right name for that? Thanx.
Upvotes: 0
Views: 42
Reputation: 212298
You can stash
the changes, but there's no reason not to commit it. If you don't publish the commit, you can always reset it and remove it from the history. Using stash
is extremely convenient, but if "later" is a long time (30+ days), it can become frustrating to find the correct stash (assuming you stash often.) There really is nothing wrong with making a commit:
$ git commit -a -m "Temporary changes"
$ git checkout other-branch
$ ... # lots of work, but do not push original-branch
$ git checkout original-branch
$ git reset HEAD~ # Back to where you were with a dirty tree as modified before first commit
Upvotes: 3
Reputation: 1353
git stash is good for that (http://www.kernel.org/pub/software/scm/git/docs/git-stash.html)
But why do you fear commiting your changes locally? You can always edit your old commit in git or even revert it
Upvotes: 1
Reputation: 174329
You would stash the current state of your working directory:
git stash
That will reset your working copy to the state of HEAD and save the changes since then in the repository.
Upvotes: 1