====== git ====== ===== MagicMonty's Bash prompt, Mint flavour ===== Github user magicmonty came up with a nice useful ​[[https://github.com/magicmonty/bash-git-prompt | 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\]" GIT_PROMPT_END=" $ " source ~/.bash-git-prompt/gitprompt.sh ===== 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\]" GIT_PROMPT_END=" \n$ " source ~/.bash-git-prompt/gitprompt.sh ===== Notes from the Workshop ===== ==== Basic commands ==== * init * add * rm * commit * status * diff * log ==== Ignoring files ==== * ''.gitignore'' generated/ /temp/ *.bak * Ignoring tracked files: ''git update-index --assume-unchanged '' ==== Changes ==== * Ignoring changes of //one// file in workspace and index: ''git checkout HEAD '' * Ignoring changes of //all// files in workspace and index: ''git reset --hard HEAD'' * Delete new files: ''git clean -f'' * Amend last commit: ''git add ; git commit --amend'' * Drop last commit: ''git reset [--hard | --soft]] HEAD^'' ==== Branches ==== * Create: ''git branch [ | HEAD^ | ]'' * Make active: ''git checkout '' * Delete: ''git branch -d|-D '' * Merge: ''git commit; git checkout ; git merge '' * Resolve conflicts: Remove markers, ''git mergetool; git add ; 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 '' * 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 ; git checkout '' * 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 '' * ''git fetch --prune; git config --global fetch.prune true'' ==== git config ==== git config --global pretty.gim "%C(blue)%ar%x09%C(yellow)%h%x09%C(cyan)%aN%x09%C(reset)%s%x09%C(auto)%d" git config --global format.pretty gim