Git is a distributed revision control and source code management tool.
- Pro Git (book is free,but if you use ,please buy it)
- How to set the state of your project back to a previous commit, but keep the history of all the preceding changes.
- How to add undo functionality to Git
- Great article about branching model to Git
Useful command and command combos:
- Change name of current branch:
- git branch -m newname
- where newname is name of the branch
- Unmodify modified file
- git checkout -- pathToFile
- where pathToFile is a file (path to file,that should be deleted (git status display all modified file or actually path to them,just copy it and use as pathToFile )
- How change message from last commit in Git?
- git commit --amend -m "A new corrected commit message"
- more details: http://dominiksymonowicz.blogspot.co.uk/2012/11/how-change-message-from-last-commit-in.html
- use -force-with-lease instead -force-force-with-lease effectively only allows you to force-push if no-one else has pushed changes up to the remote in the interim.
- How to remove all untracked files
- git clean -df
- Nice shortcut for quick commit , where you add all files and commit them with message.
- git commit -a - m "Describe your job or title from Jira "
- How to cancel and undo merge ,if you have conflict problems
- git merge --abort
- Delete all uncommitted changes
- git checkout -- .
- How to recover from shit happens like lost commit ? Use Reflog which is shortcut for Reference logs.
- git reflog
- How to clean in optimise repository. (-- aggressive should be use once per few hundreds commit)
- git gc --aggressive
- How Using command line but prefer to have more readable output of commits ? Use this:
- git log --graph --pretty=format:'%C(bold blue)%an%Creset %C(green)%cr %C(red)[%H]%Creset -%C(dim yellow)%d%Creset%n %C(ul magenta)%s%Creset ' --abbrev-commit --date=relative