Terminology

Branch A series of commits representing development on one set of functionality in parallel with other sets of functionalities.

git branch -a List all local and remote branches.

git branch -d <branch> definition: 'Delete a branch.'
ety: ''
variants: ''

git branch -f <branch> <commit> definition: 'Move (by force) the designated branch to the designated commit.'
ety: ''
variants: ''

git branch -m <oldname> <newname> definition: 'Rename a branch.'

git branch —merged List branches that are already merged into current branch.

git branch <name> definition: 'Create a new branch.'
ety: ''
variants: ''

git branch —no-merged List branches that have not been merged into current branch.

git branch -r List only remote branches.

git branch -v definition: 'List branches with last commit.'
ety: ''
variants: ''

git checkout -b <branch> <remote>/<remotebranch> Create local branch <branch> as tracking branch of <remote> branch <remotebranch>.

git checkout —track <remote>/<remotebranch> Create local branch <remotebranch> as tracking branch of <remote> branch <remotebranch>.

git push <remote> :<remotebranch> Delete branch from remote repositiory.

git show <branch> Show information on the last commit on the branch.

git show <branch>:<filepath> Show a file as it exists in a particular branch.

HEAD Pointer to the current branch.

Local branch definition: 'What you see when you type git branch.'

Remote-tracking branch definition: 'What you see when you type git branch -r; i.e. branches named <remote>/<branch> that your local instance of git is tracking.'

tracking branch A local branch that has a direct relationship to a remote branch.

Facts, Thoughts and Opinions

git newbranch

Creates a branch, checks it out, and pushes it to the git server in one command.

!f(){ git branch $1 && git checkout $1 && git push -u origin $1; };f

parse_git_dirty

Returns the name of the current git branch.

function parse_git_branch () {
       git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}

Rename a remote branch.

git branch -m <oldname> <newname> # Rename the branch in your local repository.
git push <remote> :<oldname>      # Remove the branch name you want to change on the remote.
git push <remote> <newname>       # Push the new local branch name to the remote.

Images

[[/div]]
  •   Subtopics

  •   Writings

  Sources & Bookmarks