User Tools

Site Tools



MagicMonty's Bash prompt, Mint flavour

Github user magicmonty came up with a nice useful ​ bash git prompt. For people using Linux Mint (like me) and looking to keep the prompt as similar to the default one as possible (like me), you will want to add this to your .bashrc:

GIT_PROMPT_START="_LAST_COMMAND_INDICATOR_ ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[00m\]"
source ~/.bash-git-prompt/

MagicMonty's Bash prompt, Cygwin flavor

The same as above, just mimicking the Cygwin default prompt:

GIT_PROMPT_START="\n_LAST_COMMAND_INDICATOR_ \[\e]0;\w\a\]\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]"
source ~/.bash-git-prompt/

Notes from the Workshop

Basic commands

  • init
  • add
  • rm
  • commit
  • status
  • diff
  • log

Ignoring files

  • .gitignore
  • Ignoring tracked files: git update-index –assume-unchanged <file>


  • Ignoring changes of one file in workspace and index: git checkout HEAD <file>
  • Ignoring changes of all files in workspace and index: git reset –hard HEAD
  • Delete new files: git clean -f
  • Amend last commit: git add <file>; git commit –amend
  • Drop last commit: git reset [–hard | –soft]] HEAD^


  • Create: git branch <branchname> [<sha> | HEAD^ | <branchname>]
  • Make active: git checkout <branchname>
  • Delete: git branch -d|-D <branchname>
  • Merge: git commit; git checkout <dest-branch>; git merge <src-branch>
  • Resolve conflicts: Remove markers, git mergetool; git add <filename>; git commit
  • Abort merge: git reset –hard HEAD; git merge –abort
  • Undo merge: git reset –hard ORIG_HEAD
  • Check branch movements: git reflog

Decentralized Workflow

  • “Bare”: Repository without workspace to go with it
  • Clone: git clone <repo-url>
  • Remotes: Alias for external repo URL
  • Remote-Tracking-Branches: Read-only copies of branches from the remote repo, with the alias as prefix: origin/master
  • Create local “tracking” branch: git branch <branchname> <remote-branch>; git checkout <branchname>
  • Get all changesets from remote and update remote tracking branches: git fetch
  • Put all local changes / commits into the remote repo: git push (only if fast-forward possible in remote)
  • Fetch and merge: git pull
  • Create new remote branch: git branch new-local-branch; git checkout new-local-branch; git push –set-upstream origin local-branch
  • Delete remote branch: git push –delete origin <branchname>
  • git fetch –prune; git config –global fetch.prune true
software/git.txt · Last modified: 2022/09/02 21:26 by solar