Don’t Be Scared of git Commands

You just need to master a few of them

Software developers use git for version control most of the time. It’s something we deal with every day. If time rolled back, one of the top tips that I would like to share with my younger self is the usage of git commands.

Image By Author: Sample git commands

I remember, in the early days of my developer career, I was reluctant to use git commands because they looked so difficult to use. If you looked at the documentation, each command could accept many parameters, which looked overwhelming to me. I did try to use git commands occasionally, but sometimes I could be stuck at a certain mistake, then spent a long time searching on StackOverflow for a solution. I could easily go back to my comfort zone, using git GUI software like SourceTree.

A few years ago, I started to use git commands more and more, then I found it’s not so hard actually and it made me more productive. With GUI software, it often takes more time to execute what you want to do because it usually issues several commands under the hood. Sometimes, I had an error box pop up with the git GUI software, but it could be executed successfully with the git command. git command is direct and just do what it’s asked to.

There are many git commands and it looks scary, but you usually use only a few of them for daily work. You can focus on mastering these frequently used commands. I list some 11 common commands I use daily as below. Some are different use cases for the same command, e.g. `git checkout existing_branch` and `git checkout -b new_branch`, so it’s less than 10 commands actually.

1. git checkout existing_branch
2. git pull
3. git checkout -b new_branch
4. git add .
5. git commit -m "commit message"
6. git push -u origin new_branch
7. git merge another_branch
8. git push
9. git branch -d new_branch
10. git stash
11. git stash pop

That’s it, not many. However, I didn’t know this and I was worried that I would need to spend a long time learning many git commands. Look at the list above, how long do you think you need to master them? Maybe, a week or two. Not years definitely. It’s worth it to spend time mastering them as they will make you more productive. Master the tools, then you will do the job faster.

As a side note, I still use SourceTree to review the changed files when the commit is relatively big before committing. GUI is easier to use than a command line for this particular task.



Experienced software developer, and now learning AI and Robotics.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cullen Sun

Experienced software developer, and now learning AI and Robotics.