Notice: Undefined index: order_next_posts in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 194

Notice: Undefined index: post_link_target in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 195

Notice: Undefined index: posts_featured_size in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 196

14 Git commands every user needs to know

The Git command-line tool provides a large selection of useful features. find out more about the cream of the crop

The Git command-line tool provides a large selection of useful features. Find out more about the cream of the crop


1. Partial upgrade

Sometimes, an outdated local codebase needs just one or two specific changes. In that case, ‘git cherry-pick <id>’ is your friend – it applies just the changes specified under </id><id>.

2. Add a note

Commits can be documented with a note containing further information – unlike commit messages, they can be changed later. Note management is handled via the git notes command family.

3. Track down regressions

If old bugs suddenly show up again, ‘git bisect’ will track them down using a divide and conquer algorithm. Simply set the good and bad commit IDs, and test each of the codebases provided.

4. Emailing patches

If your team coordinates itself via a mailing list, patches can be sent automagically by using the git ‘send-email -to <recipient> <files>’ command sequence. File will accept wildcards such as 00**.

5. Send-email command

On most Unix-like operating systems, Git will not recognise the send-email command by default. This is due to the email package being hosted separately – install it via ‘apt-get install git-email’.

6. The blame game

Ever wanted to find out whose drunken coding spree caused the system to fail and mess up all your hard work? Use ‘git blame’ – it annotates your source file with information about each line’s change history along with the SHA ID of the individual commits.

7. Sign a tag

Developers working on highly sensitive code will be delighted to hear that Git provides a way to create tags by making use of a digital signature. If GnuPG is correctly wired into Git, then the process of signing a tag can be accomplished by simply passing -s to git tag.

8. Harness the shortcut

Entering frequently used Git commands over and over again is boring and tiresome. Use ‘git config –global alias.<shortcut> <forwhat>’ to create a time-saving reduced version of the command passed to </forwhat><forwhat>

9. Speed me up!

Git’s internal management structures can become messy as time goes by. Cleaning up can be accomplished by invoking the integrated garbage collector. Doing so is easy – all you have to do is just enter ‘git gc’.

10. Local copies

Use ‘git clone <url>’ to copy a remote repository. The command downloads the current state of the code and the metadata commonly found in the .git subfolder, thereby giving you a complete local copy.

11. List ignored files

Advanced users use .gitignore to block any unnecessary files from the version control system. Entering ‘git ls-files –other –ignored –exclude-standard’ lists all files which the version control system will not accept.

12. Remove a file

When a file is no longer needed you can make use of ‘git rm’ to inform the version control system that the element in question should not be contained in future checkouts.

13. The Git menu

Like most Unix command line utilities, Git is shipped with a compact help system. Enter ‘git –help’ in order to receive a list of commonly used commands along with a short description of the role of each.

14. Tell me more!

Invoking a subcommand with the –help parameter tends to yield loads of extra information on the parameters taken in. If you’ve done this but this still does not solve your problem, then rest assured that a quick Google session will provide you with all the help you need.