Site icon TestingDocs.com

How to commit changes to Git Repository?

Overview

You can use Git commit command to commit changes to your Git repository using git bash. You can add a message by adding -m “Your commit message”. A meaningful log message to the commit that shows in the commit history.

 

Workflow

The normal workflow working to commit changes

Pull the changes.
You work on the changes and modifications. Modified files need to be staged.
Create new files as part of your work. At this point of time these are untracked. Add the files to staged changes.
Stage all the changes you wish to commit. Invoke git add in for the files.This stages those changes for the commit.
Call git commit command.
Push the changes to the repository.

In-case of merge conflicts, you may need to resolve the conflicts.

Sample git bash commands below:

$ git pull

$ 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: CodeExamples/pom.xml

Untracked files:
(use “git add <file>…” to include in what will be committed)

CodeExamples/MicrosoftWebDriver.exe
CodeExamples/geckodriver.exe

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

 

$ git add CodeExamples/geckodriver.exe

$ git commit -m “Adding browser executable and selenium dependencies to pom.xml”

$ git push

You can do the same things from a graphical user interface tools like Git GUI or popular IDE plugins like Eclipse , IntelliJ etc.

Commit History

You can see that the commit and the commit message in the commit history. In case if your reviewing commits made by other for review purpose, you can see all the changes made as part of the commit.

 

Exit mobile version