This post is a quick and dirty guide of how to use GIT on a day to day basis.  Over the years I've been using source control and one easy and lazy path to go down is to use a tool point and click tool - like SourceTree or GitKraken - to get the work done for you.  

On simple projects, tools can make your life easier, however, the chances are highly likely that sooner or later you'll bump into a project where only the command line will cut it.  Maybe the repo uses sub-modules, maybe you need to run some pre-commit hooks beforehand and the tool doesn't like, maybe you always need to do a rebase instead of webhooks.  Whatever the reason for learning to use GIT via the command prompt will make you more productive and give you less source control conflicts.

Getting Started

Forcing yourself to use the command line, really is as simple as making the decision now not to use a tool.  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, but like learning a second language, if you're forced to use it as your only way of communicating you will learn it much quicker. 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 command and figure out what you need to do yourself, you will retain that information more completely.

Quickstart GIT commands

Ok, so the first command is checking out/cloning a branch.  In your command prompt navigate to the area you want to pull to and use the 'clone' keyword:

Before you start work, it's probably easier to work in a new branch first.

Next, you will need to add files and commit them

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

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. To push a commit, you want to first get all the latest changes from master.

You should also squash your commits. Let's say as you've been working, you have 6- commits with meaningless names like 'test, 'fix test'. Instead of checking this all in as you have a really ugly and confusing commit history, squashing your commits into a single commit will make your life a lot easier. You can do this by:

Now, you can create your pull-request and push it:  

Now, you can create your pull-request and push it:

Lastly, if you have any issues or unsure about your current GIT status, you can use these commands: