Skip to main content
  1. Tech/

Git Simplified

·3 mins

One of the most common technologies that new professional developers struggle with is git.

Many junior developers are eager to start using all of the powerful commands of git and usually end up getting more confused.

Here are a few commands that I recommend to anyone learning git for the first time:

clone
#

This downloads the entire git repo from a remote server, usually. You will get all revision history and branches.

init
#

This initializes a new empty git repo in the current directory. As a junior developer you are unlikely to do this. Most likely you will be cloning an existing project.

Another caveat here is that when you initialize a git repo, you will need to set the remote destination to push your code changes. But let’s not worry about it yet.

checkout
#

Once you have cloned a repo on your machine, you can checkout a specific branch. By default when you clone, the master branch is checked out. Most likely you will be working in some other branch. So you will check it out by typing git checkout branch-name

pull
#

This command pulls changes from remote server into your local copy of the repo. If you are working on a branch that another developer created then that developer needs to push that branch to the remote server, then you can pull it. And finally you can check it out. I see many junior developers not pulling before checking out a new branch.

commit
#

This is simple make your changes and commit your code to the repo. When you issue this command, your changes are stored in your local copy of the repo. You will need to issue push command before your changes are pushed to the remote server and only then other developers can pull your changes.

push
#

This pushes your local repo with all local changes to the remote server.

Many times you will need to merge changes from remote into your local repo before you can push.

merge
#

This is where things get a bit confusing for new developers. There are likely 3 different cases when you are merging:

2 or more developers are working on same branch
#

This is the simplest case. You can simply issue git pull command and it will fetch and merge remote changes. Now this can result in conflicts, which will need to be resolved manually. I will talk about conflicts later.

New release went out
#

It is recommended to merge master (or default) branch into your branch often especially right after any major release. This avoids any conflicts later during the Continuous Integration pipeline.

You need a feature from another branch
#

This is probably the worst scenario to deal with because now your branch is dependent on another branch. I prefer to avoid this scenario unless the feature is in master. The reasons for avoiding this scenario are twofold, first code reviews get hard as it is hard to tell what was changed in your branch and what was pulled in from the other branch. And then many times my code got delayed because I was waiting on the other branch.

You may have to issue pull command before merging

git pull
git merge other-branch my-branch

Related

Tools of Trade

·2 mins
I use 13-inch MacBook Pro for personal projects and 15-inch for work. My personal MBP would be the last traditional laptop, hopefully. Since most of my work can easily be done on Linux VPS. I have been using a 10.5-inch iPad Pro with Blink shell for most of my side projects. I like the form factor of iPad Pro and I am getting better at Linux administration. Now I am also setting up Docker images so I can bring up new images as needed.

You don't need a web developer

·3 mins
Occasionally, when people find out I am a programmer, they ask me if I will build them a website or an app on the side. As I spend all day programming at my work, I rarely have the motivation to continue programming after work. However, talking to most people, I realize they don’t need a programmer; most of their needs can be met by a simple SaaS solution. Recently, I directed a few friends to WordPress.com, SmugMug, Shopify, etc. They all were happy with the results and ease of use. Also I am glad they talked to me because one guy was ready to spend a few thousands on a developer for a WordPress-based site.

WordPress vs Hugo

·4 mins
Managing WordPress can get time consuming. I have tried to move to static website several times but kept going back to WordPress. But there are several advantages of static site generators, so I finally moved for good. I am also advising a lot of my clients to use Hugo especially when they know that they will rarely ever update their sites. Here are some of the main advantages of Hugo (or other static site generators) vs WordPress and other CMS.