Here’s one for Monday morning. A few Git commands that you might want to add to your toolbox as well:
- Partial repository download:
Need to quickly download a single module from a large remote Git repository? git archive –remote=<repo_url> <branch> <path> | tar xvf –
— Fabian Schmengler (@fschmengler) 24. März 2015
- Review your code during
git diff --cachedto see the full diff of the currently staged files with HEAD, i.e. only what you have added, and show the details of the latest commit with
-wignores whitespace changes, just as in
✨ The best code review tip I have is: review your own code.
👉 git add -p
👉 git diff –cached
👉 git show -w
— tom✨ (@tgvashworth) 7. Juni 2016
- Who hasn’t ever used something like “Initial commit” as commit message? It can make sense to start with an empty commit while you are at it:
Git Pro Tip: Make a initial empty commit (git commit –allow-empty -m "Initial (empty) commit."). It'll make rebasing master so much easier.
— Ben Alman (@cowboy) 16. April 2015
- And I have to add my favorite Git command of all time. If you don’t know the
--graphargument yet, try it out and be amazed:
git log --graph --oneline --decorate --all --color
You might want to add it as alias like “tree”, but for me it is enough to always find it in the bash history with Ctrl–R “git log” quickly.
Git is an endless source of new tricks to learn, expect more “5 Minute Tips” on Git to come.