Memo git

Table des matières
Quelques commandes git utiles …
UNDO
Discard all local changes back to last commit
git reset --hard HEAD
Discard local changes in a specific file
git checkout HEAD <file>
Revert a commit (by producing a new commit with contrary changes)
git revert <commit>
Reset HEAD pointer to a previous commit …and discard all changes since then
git reset --hard <commit>
LOCAL CHANGES
Changed files in working directory
git status
Changes to tracked files
git diff
SEXY HISTORY
git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
COMMIT HISTORY
Show all commits, starting with newest
git log
Show changes over time for a specific file
git log -p <file>
UPDATE & PUBLISH
List all currently configured remotes
git remote -v
Show information about a remote
git remote show <remote>
Add new remote repository, named
git remote add <shortname> <url>
SUBMODULE
Add submodule
git submodule add -b master git@gitlab.maison.lan:automation/deploy_rocketchat.git
git submodule init
Update submodule
git submodule update --remote
Make an existing directory within a git repository a git submodule
➜ (master) ✗ git submodule add git@gitlab.maison.lan:automation/splunk-forwarder.git splunk-forwarder
Adding existing repo at 'provisioning/generic/splunk-forwarder' to the index
➜ (master) ✗ git submodule absorbgitdirs splunk-forwarder
Migrating git directory of 'provisioning/generic/splunk-forwarder' from
'[...]' to
'[...]'