开发者

GIT: Do I need to commit my branch before checking out another branch, what about stashing?

开发者 https://www.devze.com 2022-12-16 01:06 出处:网络
I\'m new to Git and a bit confused. 开发者_运维百科 I have a Master branch and have created a second feature branch.

I'm new to Git and a bit confused. 开发者_运维百科 I have a Master branch and have created a second feature branch.

If I make changes in my feature branch and then switch to Master, will my changes be lost if I don't commit?

Where does stash come into play, is it something you do before you switch branches (but don't want to commit) or is it to simply revert some changes so you can get back to previous code temporarily?


You can't change to another branch unless you clean your tree. This is done by committing your changes, reverting them or saving them to the stash.


You probably don't want to use stash for this purpose.

If you really want to be developing on the master and a feature branch at the same time, I suggest cloning your repository, working in the clone and the master, and then using push and pull to move changes between them.

If you are switching frequently between them, I suggest checking in before you switch; there's nothing wrong with checking in garbage; git makes it easy to sort this out later on.

0

精彩评论

暂无评论...
验证码 换一张
取 消