# Git Useful git commands and workflow. ## Workflow For a good workflow with branches, [see this article](https://nvie.com/posts/a-successful-git-branching-model/). ## Configuration `git config --global user.email "contact@jovian-hersemeule.eu"` `git config --global user.name "DricomDragon"` `git config --global core.editor "vim"` `git config --global push.followTags true` `git config --global diff.tool vimdiff` You can replace `--global` by `--local` to configure a specific project. ## Useful commands ### Staging `git status -s` `git diff` for difference against unstaged files `git diff --staged` or `git diff --cached` for difference against staged files `git rm --cached ` remove a file from git but keep this file on drive ### Stashing `git stash -u -m 'Experiment optimized code` `-u` is used to stash _untracked files_ ### Diff tool `git difftool` use a tool like _vimdiff_ `git difftool --tool-help` see availble git diff tools See **config** for setting his own git tool for diff. ### Powerful history `git commit -v` see diff while committing `git log -p` see diff for every commit `git log --graph` see branches history `git log --stat` see numbers of modifs on each file for every commit ### Remote `git remote show ` show useful information about remote `git push --delete ` delete a remote branch ## GitAhead Open-source cross-platform Git GUI https://gitahead.github.io/gitahead.com/ ### Global config `Tools > Config` You can disable _fetch every 10 min_ for instance. ### Global gitignore in Windows Use same config file as GitBash. Use in gitbash : `git config --global core.excludesfile '~/.gitignore'` Do not forget to copy your `.gitignore` at the right place.