-
Notifications
You must be signed in to change notification settings - Fork 0
GIT Branching and Merging
Scenario: You have an existing project, and wish to add a feature (or modify it in some substantial way), but don't want it to affect the production project until you've got it complete and tested. Branching and Merging may just be what you are looking for.
If you want to see what branches currently exist, then type the following command:
$ git branch
The 'master' branch is the 'main thread' for the repository.
$ git branch foo
In this case, we are calling our new branch 'foo'. Generally, the branch name should be descriptive of what you are trying to do.
$ git checkout foo
Now you are in your new branch, and can implement your changes without worrying about any adverse impact to the mainline of the project.
One you have implemented all your changes, and are ready to merge then back into the mainline of the project.
$ git add .
$ git commit -m "Comment describing changes implemented"
$ git checkout master
$ git merge foo
Now all the changes you made will be added to the mainline of the project.
It was useful, but now that you have merged your changes back into the 'master' branch it is probably a good idea to remove the branch you created in Step 1.
$ git branch -d foo