A "branch" is a separate copy (of the files involved in a project) which can be worked on without affecting the original copy.
"Branching" is a concept basic to most version control systems.
git branchlists local branches
git branch -rlists the remote branches
git branch -alists both local and remote branches
git branch <name>creates a new branch called "name", pointing at the current HEAD revision
git checkout <name>moves HEAD to point to the branch called "name"
git checkout -b <name>accomplishes both of the above in a single command
git branch -d <branch name>to delete a branch
- Note: must be in a different branch
The basic sequence of events for creating a new branch called "test", updating it, then reverting back to the original branch:
git branch test- create the branch
git checkout test- switch to it
- stage whatever changes you want to include in "test"
- This can include adding any new files you've created for this branch.
git commit -a -m 'made a change'- commit the change to "test"
git checkout master- switch back to the main branch (removes new files, restores any you deleted)