This post is a quick and dirty guide on how to use GIT on a day to day basis. When using source control one easy and lazy path to go down is to GUI application when working with GIT. Tools like SourceTree or GitKraken and great, however, they abstract the detail away for you. Sooner or later you'll bump into a project where only the command line will cut it. Maybe the repository uses sub-modules, or, maybe you need to run some pre-commit hooks beforehand and the tool doesn't support hooks. This loss of knowledge is limiting your growth as a software developer. It is time to change that! Learning to use GIT via the command prompt will make you more productive and give you fewer source control conflicts. Let's get at it!

Getting Started

Forcing yourself to use the command line, really is as simple as making the decision today not to use a tool. Uninstall it now. At first, it will take you longer and you will find yourself frustrated when you can't remember a command, or, you're not sure what you've done. After a fortnight you will have likely gone through the pain and mastered it. One way to speed this process up is by forcing yourself to try and figure out which command you need. If you use the --help flag against any GIT command you forget and figure out what you need to do yourself. This will help you to retain that information more completely.

Quickstart GIT commands

Ok, so the first command you need to use on every new project is checking out/cloning a branch from origin. Origin is simply an out the box alias that points to a remote repository. In your command prompt navigate to the directory you want to copy the code into and use the clone keyword:

Before you start work, it's probably easier to work in a new branch first. Also, due to political correctness using master is not cool anymore.

Next, you will need to add files and create a commit. A commit is a point in time snapshot of your latest changes since the last update:

If you bump into any issues, you can get yourself out of trouble with this command:  

You can also try:

If you work in a big team, it is likely that you will need to create pull requests to have people peer review your code before you can commit it into the main branch. This is done by creating a feature branch:

If you commit frequently without pushing to the origin, you should squash your commit messages into a single commit when you finish a feature. Let's say you've been working for a few hours and you have 6- commits with meaningless names like 'test, 'fix test', and kjkl. Merging this into the main branch will result in a really ugly and confusing commit history. Squashing your commits into a single commit will make your life a lot easier. Squashing is simple, you can use this command:

Now, you can create a feature branch and push it:  

Now, within GitHub, Dev-ops, BitBucket you can create a pull request and submit it. Lastly, if you have any issues or unsure about your current GIT status, you can use this command:


That covers all the basic commands you need to get going with GIT. These are the majority of the commands I use on a daily basis. Master these first, and learn the more complex bits later. Happy Coding 🤘