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 add
with-p
, usegit diff --cached
to 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 withgit show
(-w
ignores whitespace changes, just as ingit diff
).
✨ The best code review tip I have is: review your own code.
Your tools:
👉 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
--graph
argument 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.
Great post! I’ve started using the first command quite a bit.
The last command is nifty, although I tend to stick with SourceTree for visualizing branches.
Speaking of “Ctl+R” to search history, if you aren’t already using up/down arrow to search Bash history, then you should be. Check this out: http://stackoverflow.com/a/1030206/2726785
That’s a nice enhancement, thanks!