There is much confusion faced by newcomer users of Git. You may feel stuck while doing your project. But we are at your service. Not only have we answered your doubt but also we have let you understand it all in detail.
It is because that is the only way to understand it as well as remember it. Simply mugging up the steps will never be of any use to you. So, let us first begin by answering your doubt and further proceed with the explanation of Git.
To undo git add before committing, run git reset to undo your changes. In older versions of Git, the commands were git reset HEAD and git reset HEAD, respectively. This has changed in Git 1.8.2
Some information about Git
Here is some background information about Git. Understanding the three sections of a Git project will make it more feasible for you. The Git project has three main sections:
- Git directory
- Working directory (or working tree)
- Stage area
In the Git directory (YOURPROJECTPATH / .git /), Git stores everything you need to carefully monitor your project. This includes metadata and an object database that contains a compressed version of the project file.
User makes local changes to a project in the working directory. The working directory gets the project file from the object database in the Git directory and saves it on the user’s local computer.
The staging area is a file (also known as an index, stage, or cache) that stores information about what goes into the next commit. Commit is telling Git to save the gradual changes. Git takes a snapshot of the file as is and saves the snapshot permanently in the Git directory.
There are three sections and there are three main states where a file can exist at any time. Commit, modify, or mount. Every time you change a file in your working directory, you change the file. Then move to the staging area and it will be expanded. Eventually, it will be committed after committing.
Git. install
Ubuntu: sudo aptget install git
Windows: Download
Mac download
Configure a Git environment
Git has Git configuration tools that you can use to customize your Git environment. You can change the look and behaviour of Git by setting specific configuration variables. Run these commands from your computer’s command-line interface. (Terminal for Mac, Command Prompt, Powershell for Windows).
There are three levels at which these configuration variables are stored.
#1. System:
Located in / etc / gitconfig, it applies the default settings to all users on the computer. To make changes to this file, use the system option with the gitconfig command.
#2. Users:
Located in ~ / .gitconfig or ~ / .config / git / config, apply the settings to a single user. To make changes to this file, use the global options with the gitconfig command.
#3. Project:
Located in YOURPROJECTPATH / .git / config, it applies the settings only to the project. Use the gitconfig command to make changes to this file. If the settings conflict with each other, the project-level configuration overrides the user-level configuration and the user-level configuration overrides the system-level configuration.
Note to Windows users: Git looks for a user-level configuration file (.gitconfig) in the $ HOME directory (C: \ Users \ $ USER). Git also searches / etc / gitconfig, but is related to the MSYS root that you choose to install Git on your Windows system when you run the installer.
If you are using version 2.x or later of Git for Windows, there is also a systemlevel config file at C:\Documents and Settings\All Users\Application Data\Git\config on Windows XP, and in C:\ProgramData\Git\config on Windows Vista and newer. It is only possible to alter the config file through git config f FILE as an admin.
Add Your Name and Email
Git includes the user name and email as part of the information in a commit. You`ll want to set this up under your userlevel configuration file with these commands:
git config global user.name “My Name”
git config global user.email “myemail@example.com”
Scroll forward with these key shortcuts.
- f or spacebar
- b scroll back
- q Stop
Hence, these are the ways to undo a Git add. We hope that the background knowledge of Git will prove helpful to you in the understanding of Git Add.