Important GIT Commands




Below are the few important GIT commands:

Initialize new GIT repository

git init

Initialized empty Git repository in C:/git/.git/


Check GIT repository status

$ git status

On branch master 

No commits yet 

nothing to commit (create/copy files and use "git add" to track)


Add remote origin to GIT repository

$ git remote add origin "https://github.com/gittest/GitTest.git"


List all branches of GIT repository

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git branch -a

* master

  remotes/origin/main


Add remote origin to GIT repository

$ git pull origin master

fatal: couldn't find remote ref master

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git pull origin main

remote: Enumerating objects: 3, done.

remote: Counting objects: 100% (3/3), done.

remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0

Unpacking objects: 100% (3/3), 613 bytes | 51.00 KiB/s, done.

From https://github.com/gurpsing/GitTest

 * branch            main       -> FETCH_HEAD

 * [new branch]      main       -> origin/main


Check GIT repository status

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git status

On branch master

nothing to commit, working tree clean

 

After adding a file:

$ git status

On branch master

Untracked files:

  (use "git add <file>..." to include in what will be committed)

        Test.txt

 

nothing added to commit but untracked files present (use "git add" to track)


Adding files to the index

gsingh@ITEM-S1\ MINGW64 /c/git (master)

$ git add Test.txt


Check GIT repository status

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git status

On branch master

Changes to be committed:

  (use "git restore --staged <file>..." to unstage)

        new file:   Test.txt


Commit changes in GIT repository 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git commit -m "First Commit"

[master 2325d15] First Commit

 1 file changed, 1 insertion(+)

 create mode 100644 Test.txt

 

or

 

$ git commit -a -m "First Commit"

 

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git status

On branch master

nothing to commit, working tree clean

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git commit -m "Another Commit"

On branch master

nothing to commit, working tree clean

 

After adding three new files and modifying existing file:

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git status

On branch master

Changes not staged for commit:

  (use "git add <file>..." to update what will be committed)

  (use "git restore <file>..." to discard changes in working directory)

        modified:   Test.txt

 

Untracked files:

  (use "git add <file>..." to include in what will be committed)

        File1.txt

        File2.txt

        File3.txt

 

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



Adding multiple files to staging

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git add File1.txt File2.txt

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git status

On branch master

Changes to be committed:

  (use "git restore --staged <file>..." to unstage)

        new file:   File1.txt

        new file:   File2.txt

 

Changes not staged for commit:

  (use "git add <file>..." to update what will be committed)

  (use "git restore <file>..." to discard changes in working directory)

        modified:   Test.txt

 

Untracked files:

  (use "git add <file>..." to include in what will be committed)

        File3.txt


Remove all  files from staging

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git reset

Unstaged changes after reset:

M       Test.txt

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git status

On branch master

Changes not staged for commit:

  (use "git add <file>..." to update what will be committed)

  (use "git restore <file>..." to discard changes in working directory)

        modified:   Test.txt

 

Untracked files:

  (use "git add <file>..." to include in what will be committed)

        File1.txt

        File2.txt

        File3.txt

 

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


Adding all files to staging

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git add -A

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git status

On branch master

Changes to be committed:

  (use "git restore --staged <file>..." to unstage)

        new file:   File1.txt

        new file:   File2.txt

        new file:   File3.txt

        modified:   Test.txt


Remove multiple  files from staging

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git reset File2.txt File3.txt

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git status

On branch master

Changes to be committed:

  (use "git restore --staged <file>..." to unstage)

        new file:   File1.txt

        modified:   Test.txt

 

Untracked files:

  (use "git add <file>..." to include in what will be committed)

        File2.txt

        File3.txt

 

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git commit -m "New Commit"

[master d42ea62] New Commit

 4 files changed, 4 insertions(+), 1 deletion(-)

 create mode 100644 File1.txt

 create mode 100644 File2.txt

 create mode 100644 File3.txt

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git status

On branch master

nothing to commit, working tree clean


Checking the log of GIT repository

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git log

commit d42ea62f8758ee2540ce4fd53848d13063b999b0 (HEAD -> master)

Author: Gurpreet Singh <44372365+gurpsing@users.noreply.github.com>

Date:   Wed Jan 4 11:49:57 2023 +0530

 

    New Commit

 

commit 2325d15482a564cfa192053af0821c1c941839e4

Author: Gurpreet Singh <44372365+gurpsing@users.noreply.github.com>

Date:   Tue Jan 3 19:19:06 2023 +0530

 

    First Commit

 

commit 678bb857fcffae552fcb54a35cbbd291039862b7 (origin/main)

Author: Gurpreet Singh <44372365+gurpsing@users.noreply.github.com>

Date:   Tue Jan 3 14:55:17 2023 +0530

 

    Initial commit

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git reflog

d42ea62 (HEAD -> master) HEAD@{0}: commit: New Commit

2325d15 HEAD@{1}: reset: moving to HEAD

2325d15 HEAD@{2}: reset: moving to HEAD

2325d15 HEAD@{3}: commit: First Commit

678bb85 (origin/main) HEAD@{4}: initial pull


Reverting the commit

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git revert d42ea62

[master fb9b2ef] Revert "New Commit"

 4 files changed, 1 insertion(+), 4 deletions(-)

 delete mode 100644 File1.txt

 delete mode 100644 File2.txt

 delete mode 100644 File3.txt

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git status

On branch master

nothing to commit, working tree clean

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git log

commit fb9b2efd498df5c8951f4ba22f398ef6e7e57b2f (HEAD -> master)

Author: Gurpreet Singh <44372365+gurpsing@users.noreply.github.com>

Date:   Wed Jan 4 11:53:00 2023 +0530

 

    Revert "New Commit"

 

    This reverts commit d42ea62f8758ee2540ce4fd53848d13063b999b0.

 

commit d42ea62f8758ee2540ce4fd53848d13063b999b0

Author: Gurpreet Singh <44372365+gurpsing@users.noreply.github.com>

Date:   Wed Jan 4 11:49:57 2023 +0530

 

    New Commit

 

commit 2325d15482a564cfa192053af0821c1c941839e4

Author: Gurpreet Singh <44372365+gurpsing@users.noreply.github.com>

Date:   Tue Jan 3 19:19:06 2023 +0530

 

    First Commit

 

commit 678bb857fcffae552fcb54a35cbbd291039862b7 (origin/main)

Author: Gurpreet Singh <44372365+gurpsing@users.noreply.github.com>

Date:   Tue Jan 3 14:55:17 2023 +0530

 

    Initial commit

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git revert fb9b2efd498df5c8951f4ba22f398ef6e7e57b2f

[master a2306b8] Revert "Revert "New Commit""

 4 files changed, 4 insertions(+), 1 deletion(-)

 create mode 100644 File1.txt

 create mode 100644 File2.txt

 create mode 100644 File3.txt

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git status

On branch master

nothing to commit, working tree clean



Commit few files from tracked files

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git status

On branch master

Changes not staged for commit:

  (use "git add <file>..." to update what will be committed)

  (use "git restore <file>..." to discard changes in working directory)

        modified:   File1.txt

        modified:   File2.txt

        modified:   File3.txt

 

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

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git add -A

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git commit File1.txt File2.txt -m "Commit 04-Jan-2023"

[master a6b6021] Commit 04-Jan-2023

 2 files changed, 2 insertions(+), 2 deletions(-)

 

gsingh@ITEM-S1 MINGW64 /c/git (master)

$ git status

On branch master

Changes to be committed:

  (use "git restore --staged <file>..." to unstage)

        modified:   File3.txt

 


Comments

All Categories

Call Fusion BIP Report2 Change Password1 Code Combinations2 Compute Instance2 CTE1 Customer1 Data Aggregation2 Database5 Date Conversion1 DB Adapter2 Decryption1 Development1 EBS4 Encryption1 ESS Jobs3 Examine1 FBDI3 Fusion APIs1 Fusion BIP7 GIT2 GL3 GL Journals1 GL_DAILY_CONVERSION_TYPES1 GL_DAILY_RATES1 ICS1 Identity Domain1 Integrations1 Java1 Journal Import1 Keys1 Legal Entity1 LookupTypeLOV1 LOV1 LOVs1 MultiPartAPIs1 Networking1 NVL2 NVL in OIC2 OCI11 OCI Billing1 OCI Compute5 OCI Cost Management1 OCI Events Service1 OCI Free Tier3 OCI Notifification Service1 OCI Security3 OIC4 OIC Mapper2 Oracle26 Oracle ADF17 Oracle APEX1 Oracle Apps59 Oracle Apps R126 Oracle ATP1 Oracle BIP8 Oracle Cloud12 Oracle Cloud Free Tier1 Oracle cloud Infrastructure9 Oracle Cloud Security2 Oracle Cloud VM1 Oracle DB4 oracle ebs5 Oracle ERP4 Oracle ERP Adapter2 Oracle ERP Cloud7 Oracle financials2 Oracle Forms1 Oracle Fusion57 Oracle Fusion BIP4 Oracle Fusion ERP17 Oracle Fusion Financials18 Oracle Integration Cloud3 Oracle OAF17 Oracle OCI14 Oracle OIC22 Oracle SOA 12c10 Oracle SQL17 Oracle VBCS1 Oracle VBS2 Oracle Visual Builder Cloud Service1 Oracle Visual Builder Studio2 Oracle Workflow Notifications1 Others10 Payables2 Payables Import1 Properties1 R121 Register BIP as ESS Job1 Reset Password1 Responsibility1 REST4 Security List1 Site Map1 SOAP2 SOAP API2 SOAP UI3 SQL16 SQL Functions3 SQL Queries14 SQL Query8 SQL Tips3 SSH1 TCA1 Value Sets1 VBCS1 Virtual Machine2 Virtual Machines1 XML1 XSLT1
Show more