Tag Archives: Git


git add is a Git command used to stage changes made to a working directory, before committing them. Staging is an intermediate step that allows you to control which changes are included in the next commit and which are not.

Here is an example:

Suppose you made changes to two files named file1.txt and file2.txt. You want to include the changes to file1.txt in your next commit, but not the changes to file2.txt.
To do so, first navigate to the project directory in the terminal and execute:

git add file1.txt

This command stages the changes made to the file file1.txt. You can now review the changes staged by executing:

git status

You should see that file1.txt has been staged.
Now you can commit the staged changes by running:

git commit -m "Added new feature to file1.txt"

The commit will include only the changes to file1.txt since file2.txt was not staged.


The git commit command is used in Git to save changes to a local repository. It creates a new commit object with a unique identifier based on the changes made, along with a message that describes the changes. This allows you to keep track of changes made to your code over time and makes it easy to revert to previous versions if necessary.

Here’s an example of how to use git commit:

  1. After making changes to your files, add them to the staging area with git add.
  2. Once you’ve added all the changes you want to commit, run the git commit command followed by a -m flag and a message inside quotes describing the changes made. For example:
git commit -m "Added new feature to login page"

  1. The commit is now saved to your local repository with a unique identifier, allowing you to easily track and revert to previous versions of your code.

It’s important to note that committing changes locally only saves them to your local Git repository. To share the changes with others or push them to a remote repository, you’ll need to run git push after committing.

Here are some links that you may find helpful:


The git status command displays information about the current status of the working directory and staging area in your Git repository. It tells you which files are currently being tracked, which changes have been staged, and which changes still need to be staged.

Let’s say you’re working on a new feature for your website and you’ve made some changes to your code. You can use git status command to see which files have been edited on your local copy:

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout --<file>..." to discard changes in working directory)
        modified:   index.html

no changes added to commit (use "git add" and/or "git commit -a")

In this example, Git is reporting that the index.html file has been modified but not yet staged. This means that Git is aware of the changes you have made, but they have not yet been added to the next commit.

I hope that helps! Let me know if you have any other questions.


git init is a command in Git that creates a new Git repository. It sets up all the necessary files and directories that Git needs to begin tracking changes to your project. This command creates a new subdirectory named .git that contains all of the necessary repository files.

Here is an example:

Let’s assume you have a folder on your desktop named “project”. Open a terminal/command prompt in that directory and enter git init. This will create a new subdirectory named .git in your “project” folder.

$ cd ~/Desktop/project
$ git init
Initialized empty Git repository in /Users/USER/Desktop/project/.git/

This command only needs to be run once per repository. After running git init, you can start tracking changes to your project using Git commands like git add and git commit.

Git: Delete Last Commit

Many times like you, even professional programmers do mistakes. A lot of times it happens that you commit something junk in hurry and then you start looking out for reverting it back. Like you even I have done such mistakes many times and finally I thought to write down a few useful git commands which will help me to revert back to stable copy of project.

Using ‘git reset’

So, if you have committed something junk, not useful but you have not pushed it to remote repository then you can go with

git reset --soft HEAD~1

git reset‘ command will reset your current commit. The ‘HEAD~1‘ mentioned here is nothing but shorthand for your last commit and the ‘–soft’ option specified in the command will keep all the changes in working copy.
Continue reading Git: Delete Last Commit

Git – Autocorrect spelling

Git is but of course one of the most powerful DVCS client and it is used by millions of developers worldwide. Git do provides a lots of features to work with different versions of your software. Some of those features are well known but others are not that much popular. One of such non popular feature is Git Autocorrect.

Git do have capability to check whether the commands you are firing at git console are correct or not. If the commands are not correct then Git can suggest you corrections. In fact git can auto correct your wrong command.

Let’s take an example. You are in hurry and you misspelled “Git Push” as

git pusj

and pressed enter. Git will generate following error message…

git: ‘pusj’ is not a git command. See ‘git –help’.
Did you mean this? push

and will wait for your input.

Continue reading Git – Autocorrect spelling