7. BRANCHES Flashcards
¿WHAT DOES BRANCHES DO?
Branches let you create different versions of your code so that you can play around with adding new features, without worrying about messing up what stable.
GIT BRANCH COMMAND
Branch lets you take a look at all the branches and your repository.
GIT CHECKOUT command
Usage: git checkout [branch name]
This command is used to switch from one branch to another.
GIT SWITCH COMMAND
Usage: git-switch - Switch branches
Typically what you want to do is make a copy of an existing branch. You can do that with the git switch command. It’ll have the same history as the current branch.
GIT MERGE COMMAND
Usage: git merge [branch name]
This command merges the specified branch’s history into the current branch.
¿WHAT SHOULD HAPPEN TO THE BRANCH YOU DON’T NEED?
So when you’re done with a feature or a fix, it’s a good idea to delete the branch that you no longer need.
GIT BRANCH -D COMMAND
Usage: git branch -d [branch name]
This command deletes the feature branch.
¿WHAT IS GITFLOW?
GitFlow is a branching model for Git, created by Vincent Driessen. It has attracted a lot of attention because it is very well suited to collaboration and scaling the development team.
EX: This sequence of doing things is what we call git flow. You create a new branch, that’s usually a feature or a fix branch. You make changes to that branch. Then you merge that branch back to master, and then you delete the old branch.
BRANCHING AND COLLABORATION
When you collaborate with other people, everyone leaves the main branch alone. You can see that things would get really messy if everybody was trying to work on the same branch. So everybody creates a new branch. Then you make a change and you follow this structure. This will make working with others a lot easier.