Basic Git commands

Here’s a set of quick Git commands to get started that I created as notes for myself.


Creating a repository

Initializes an empty repository in the current directory.

git init

Adding files

Adding the files, either one at a time or all the files

git add *
git add file-name

Current status of Git

Details on current repository, whether any files needs to be checked in, etc.

git status

Committing changes

Persisting the changes to repository

git commit -m "message"

Committing changes

Persisting the changes to repository

git commit -m "message"

Listing all changes to repository

git log

Show current branch information

List details of the current repository branch.

git branch -a

Create a new branch

This will create a new branch. If a branch already exists, it simply throws an error.

git checkout -b development

Switch branch

git checkout development

Merge a branch

Assuming the user wants to merge “development” to “master”, this will work. The “–no-ff” option will

git merge development --no-ff

Listing the tags

Lists all the existing tags

git tag

Creating a simple tag

This will create a tag but have no information about it.

git tag tag1

Creating an annotated tag

This will add more info when creating the tag.

git tag -a v1 -m "Version 1.0 release"

Show the details of a tag

This will show the last committed details and the files that are present in a tag.

git show tag1

I am still learning about the git push and git pull commands. I’ll update once I learn more

Author: akshayrangananth

CDN Specialist, Web performance evangelist, and SEO tinkerer.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s