
This commit command is used to add any of the tracked files to staging area and commit them by providing a message to remember. Syntax: $ git commit -m "Add existing file" This command commits the staged changes to the local repository. This committing process is done by the use of git commit command. Committing changes from the Index Committing process is done in the staging area on the files which are added to the Index after git add command is executed. To add text files of entire project to staging area. To add all files in a particular directory(docs) to staging area. To add all text files of a particular directory(docs) to staging area. To add all text files of the current directory to staging area. To add all files of the current directory to a staging area. To add a specific list of files to the staging area.

This stages them for the commit process.ĭifferent ways to use add command: $ git add. git add command adds the file in the local repository. These changes need to be added to the Staging Area for further modification of the file. When the changes have been made in the Working Tree/Area. Committing the indexed changes into the repositoryĪdding changes to the Index This process is done by the use of git add command.Adding the changes to the Index(Staging Area).Adding to a RepositoryĪfter performing various modifications on a file in the Working Area, GIT needs to follow two more steps to save these changes in the local repository. These modifications will result in the creation of different versions of a project. These operations include the addition of files, creating new repositories, committing an action, deleting a repository, etc. Working with a RepositoryĪ GIT repository allows performing various operations on it to create different versions of a project. the file is modified but the change is not yet staged.Īfter the changes are done in the working area, the user can either update these changes in the GIT repository or revert the changes. Modified/Dirty: When the changes are made to the file i.e.Staged: In this stage, the file is ready to be committed and is placed in the staging area waiting for the next commit.Tracked: When the Git repository tracks a file, which means the file is committed but is not staged in the working directory.Untracked: In this stage, the Git repository is unable to track the file, which means that the file is never staged nor it is committed.There are a few stages of a file in the working tree of a repository: The user of the working tree gets to change the files by modifying existing files and removing or creating files. Only the files which are present in the working area are considered for commit operation. Whenever an operation is committed by the user, Git will look only for the files which are present in the working area, and not all the modified files. It helps in tracking the changes done by a specific user on one version of the repository. Working Area or Staging of a Git RepositoryĪ working tree in a Git Repository is the collection of files which are originated from a certain version of the repository. The cloning process by default creates a non-bare repository if any parameter is not specified during the clone operation. Non-bare Repositories: Non-bare repositories are user-friendly and hence allow the user to create new modifications of files and also create new versions for the repositories.A user is not allowed to modify this repository or create a new version for this repository based on the modifications done. Bare Repositories: These repositories are used to share the changes that are done by different developers.How to Set Git Username and Password in GitBash?.

