Helpful Git Commands
Learn how to pull up a help menu, clone a repository, and more.
Table of contents
Introduction
In the previous article, you learned how to branch in Git.
Now that you know how to branch, you can learn some random and helpful commands.
In this article, I'll teach you some assorted commands to use in Git. This is less of a lesson than it is a cheat sheet of sorts.
NOTE: You might want to be at a computer or laptop (to get the full experience).
git diff
The first command to note is git diff
. Calling this command on an updated and saved file prior to the two-stage commit process will show the difference between your previously committed version and your current version.
git help
Use this command like so:
git help <command>
This pulls up a help manual (in your default browser) on <command>
.
To get help for all commands, use git help --all
instead.
Copying Remote Repositories
The last thing to note is how to copy a repository from GitHub to your local machine. This is typically used in a team, but it can also be utilized for personal use.
There are actually two commands to learn here: git clone
and git pull
. Use git clone
to copy a remote repository to your local machine for the first time. After that, it's preferable to use git pull
for updating your local copy.
Here's how to use git clone
:
git clone <remote-location> <clone-name>
...and here's how to use git pull
:
git pull origin <branchname>
Conclusion
In this article, you learned some assorted commands, including:
- git diff (used for showing file differences)
- git help (used for pulling up help manuals)
- git clone (used for copying remote repositories)
- git pull (used for updating local repositories)
Great job on completing the ninth part of the series!
This is the 9th part of a 10 part series to teach Windows users about Git Bash. This series includes:
how to install Git Bash
how to change your file system
how to set up Git and GitHub
how to connect Git and GitHub
how to keep up good practices in Git
how to backtrack in Git
how to branch in Git
...and more!!