I have a simple question about git.
I would like to know what is the common way to use branch.
Figure out you create a branch for authentication that you don't finish or where you will add other stuff later. Th开发者_如何学Pythonen you work on another branch, for example relationship.
If now, I finish what I have to do on relationship and I want to add my stuff about authentication. Did I have to switch to the authentication branch or do I have to create another one?
Thanks
Branches are for anything that is independent. Want to work on a new feature? Make a branch. Want to work on fixing a bug that will probably take more than a few minutes to fix? Make a branch. Want to toy around with different configurations? Make a branch.
Branches in Git are very lightweight, so never be afraid to branch out and do something. When you want to bring changes back together, you simply use the git merge
command to merge changes from one branch back into another.
you swtich to authentication branch and merge in your relationship branch
It is as easy as merge authentication into relationship while in authentication, no need to switch. This will create a commit in relationship that brings your changes from authentication to relationship (conflicts might occur and you might need to resolve them)
git merge authentication
Other solution if you want to keep your history lineal, is o rebase, you would rebase relationship over authentication, this will go through all your commits adding them in order. In this case you might also experience conflicts. Here you have an explanation of the difference between them:
When do you use git rebase instead of git merge?
精彩评论