Tom Blaymire

Git Commands For Developers

What is version control?

Version control in a nutshell allows you to update, share and track code from a centralised location. It is a perfect way for you to contribute your changes to a shared codebased with a team of other developers all working on the same project.

The most used version control system or VCS for short is Git. Git has been around for years origionally created in 2005 it allows developers to share code in an effective way and is well supported by various different code editors such as VSCode and Sublime Text.

Is it hard to learn Git?

I believe that version control should be one of the first things you learn as you are persuing a career as a Web Developer. Most teams use Git so it is essential that you at least understand the basic commands and can commit, merge and push your changes up to a remote repository.

We at Learnstability are currently in the process of building our first ever Git course that will contain everything you need to know to get up and running with the tool fast! You can subscribe tody to recieve an exlusive pre-sale discount when we go live.

What Git commands do I need to know as a Web Developer? To help you on your way we have listed below some of our top commands to get you up and running with git. Don't worry you don't have to memorize them all but they may serve as a useful reference in the future.

How to create a git repo?

git init

How to remove a git repo?

rm -rf .git

How to add a file to the repo?

git add

How to commit a change?

git commit -m “message”

How to edit a commit message?

git commit -amend -m

How to change user config?

git config global edit add dashes

How to commit all changes same line?

git commit -a -m “”

How to view the status of a project?

git status

How to log all git commit history?

git log

How to log all git commit on one line?

git log — oneline

How to display a fancy graphical view of commits?

git log — graph — decorate — pretty=oneline — abbrev-commit

How to see the code from a commit?

git checkout 7cb4e

How to see the changes to a specific file?

git cat filename

How to go back to branch master (latest)?

checkout master

How to see the difference between versions?

git diff 7cb4e 98541

How to undo when a file is wrong (staged)?

git reset HEAD css/custom.css

How to undo when a file is wrong (committed)?

git checkout HEAD^ css/custom.css

How to show what has changed from last time?

git diff

Commit message top tip:

Be sure to commit your work often and use relevant short commit messages explaining what your changes are. When writing a commit message ask yourself:

Does this message make sense to someone who has not been working on my current task?

Branching Commands

A branch in Git is simply a lightweight movable pointer to an individual commit. You could for example branch off from your colleagues branch and make your own changes to thier work!

How to create a branch?

git branch branch_name

How to switch to the new branch?

git checkout branch_name

How to see the commit log of new branch?

git log

How to create a branch and switch to it?

git checkout -b branch_name

How to list all branches?

git branch -a

How to delete a branch? (must switch to different branch first)

git branch -D bar_feature

Merging Commands

Like the opposite of branching, merging will bring all changes and commits into one timeline.

How to merge a branch?

git merge foo_feature

How to edit conflicted file?

nano file 1 (will show both changes)

How to combine conflicted files?

nano file 1 (simply add a comma between changes)

After conflict changed?

git add file1 then git commit

Remote Repositories

This is where you can essentially clone (copy) a centralised repo to then work on a specific task within that project.

This could be a repository created by someone at the other side of the world that you can then get access to and contribure your changes.

How to clone a repo to your local machine?

git clone http:// repo_url.git or local folder

Show all remotes available?

git remote -v (origin the original copy)

How to manually add a remote repo?

git remote add /path

How to push a commit to the remote repo? (remote needs to know name branch)

git push 

How to push a commit with a branch?

git push origin new_feature (branch name)

Conclusion

These are just a snippet of some of the Git commands that I find myself using often. Git is one of those tools that you gradually pick up over time so don't worry too much if it all don't make sense right now.

Git also comes with a fantastic documentation you can find this here: Git Documentation

© Tom Blaymire 2025. All rights reserved.