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
deleting a branch |
renaming a branch |
||
| Line 28: | Line 28: | ||
** [https://git-scm.com/docs/git-branch git-branch - List, create, or delete branches] | ** [https://git-scm.com/docs/git-branch git-branch - List, create, or delete branches] | ||
** [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] | ||
===How To=== | |||
* '''2019-10-07''' [https://linuxize.com/post/how-to-rename-local-and-remote-git-branch/ How To Rename a Local and Remote Git Branch] | |||
** Note: if the branch is not in the local repository, then you just need to [[git fetch]] it after the <code>git checkout <old_name></code>. | |||
Revision as of 15:09, 19 January 2020
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"- Note:
git Template:L/same -b Template:Argaccomplishes both of the above in a single command
- Note:
git branch -d Template:Argto 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 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)
Links
Reference
How To
- 2019-10-07 How To Rename a Local and Remote Git Branch
- Note: if the branch is not in the local repository, then you just need to git fetch it after the
git checkout <old_name>.
- Note: if the branch is not in the local repository, then you just need to git fetch it after the
