How to stage all changes in git

How to stage all changes in git, In the previous post, we had discussed the various stage of our file. If you haven’t read the previous post, then GitHub for Beginners Part1

This is the second post of Git for beginners. Ok, let’s continue our reading.

How to stage all the changes in the current directory?

Using the “git add .”, it will add all files with changes to a stage.

To see the changes, we made, here all the files are stated that is why I am using “git diff –cached“.

How to undo all the changes using git?

How “git commit” works?

In every commit operation, an entry in history will be created. By default, when we clone the repo in our local machine, HEAD references will post to the recent commit.

When we perform a certain operation and imagine that we have version “Beta v5”, then the Head pointer will move from V4 to V5. It is also possible that we can move the HEAD references.

How do git manager version details?

In reality, there is not versioning concept as such git uses, a hash algorithm (SHA: – Secure Hash algorithm ) to generate the checksum that represents the content in the state. It generates 40 character identifiers based on the current data.

The identifier which is generated is called “Commit Hash”. Every time we perform the “git commit”, the hash gets generated. Using the HASH let’s say HASH ID we can move between different states.

Also, it is impossible to change the content of any file or directory without knowing GIT.

Using the git log you can see the details down below I have already specified.

Error:- .git/.COMMIT_EDITMSG.swp” already exists!

As a beginner, your editor may be notepad. So at the time of git commit, you may receive some error which I have specified below. To solve this error write the code in Git Bash.

git config --global core.editor "notepad"
git commit

The window will be pop up in notepad form. Here you need to specify the commit message.

It is always a good practice to specify the commit message as in the development field we are working in a group.

The SHA was created and the command was completed successfully.

How to work with the editor “vi”?

First, understand the navigation features.

  1. L Key: – Right
  2. K Key: – Up
  3. H Key: – Left
  4. J Key: – Down
  5. I Key: – Insert Mode

Change the data inside the editor. To save we need to convert into command line form. For that press, ESC Button, and then write the code as I have specified down below.


W: – write

Q: – Quit

That is why it is good practice to use notepad as your text editor. To make notepad already code is specified above.

How “.git” folder work?

  1. This folder contains all the information about the repository and you don’t necessarily need an internet connection to perform some operation with GIT.
  2. When you are in offline mode, you can navigate to a different version.
  3. It is the place where GIT stores all about your project, including DATABASE.

How to open “.git” folder?


Change the path based on your system and you will the list of all the folders as I have specified in the image below.

This folder contains all the configuration and project details, also keep the track of all the changes.

Git Log

using “git log”, we see all the commits in the repository.

Check out the HEAD, it is currently pointing to the latest commit we just made.

How to revert the changes we made just now?

git reset 60f61eb 

60f61eb can be anything.

Git Configuration Level

git allows 3 level different configuration settings.

  1. System: – Here configuration applied to all users on your computer and all their repo.
  2. Global:- It will be applied to all the repositories on your computer for the current user.
  3. Local:- It will be applied ONLY to the current repository.

How to connect the remote master branch with the local master branch?

git remote -v

If nothing is shown in the terminal means you have to connect with the remote.

git remote add origin
git push origin -u master

How to change the remote URL?

git remote set-url origin COPY-URL

See you in next GIT POST… GitHub for Beginner Part3

Till then interested to read regarding LEARN ANGULAR STEP VY STEP

Leave a Comment