Git/branch: Difference between revisions
from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
actions |
Brief usage sketch |
||
| Line 12: | Line 12: | ||
* <code>git branch {{arg|name}}</code> creates a new branch called "name", pointing at the current {{l/same|HEAD}} revision | * <code>git branch {{arg|name}}</code> creates a new branch called "name", pointing at the current {{l/same|HEAD}} revision | ||
* <code>git {{l/same|checkout}} {{arg|name}}</code> moves {{l/same|HEAD}} to point to the branch called "name" | * <code>git {{l/same|checkout}} {{arg|name}}</code> moves {{l/same|HEAD}} to point to the branch called "name" | ||
The basic sequence of events for creating a new branch called "test", updating it, then reverting back to the original branch: | |||
* <code>git branch test</code> - create the branch | |||
* <code>git checkout test</code> - switch to it | |||
* {{l/sub|stage}} whatever changes you want to include in "test" | |||
** This can include adding any new files you've created for this branch. | |||
* <code>git commit -a -m 'made a change'</code> - commit the change to "test" | |||
* <code>git checkout master</code> - switch back to the main branch (removes new files, restores any you deleted) | |||
==Links== | ==Links== | ||
===Reference=== | ===Reference=== | ||
* [http://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell 3.1 Git Branching - Branches in a Nutshell] | * [http://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell 3.1 Git Branching - Branches in a Nutshell] | ||
Revision as of 19:45, 13 March 2015
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.
Commands
Information:
git branchlists local branchesgit branch -rlists the remote branchesgit branch -alists both local and remote branches
Actions:
git branch Template:Argcreates a new branch called "name", pointing at the current Template:L/same revisiongit Template:L/same Template:Argmoves Template:L/same to point to the branch called "name"
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 branchgit checkout test- switch to it- Template:L/sub 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)
