User Tools

Site Tools


software:git

git

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\]"
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 <file>

Changes

  • 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^

Branches

  • 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

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
software/git.txt · Last modified: 2024/02/05 10:18 by 127.0.0.1

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki