Git Common Commands

Mentor Konnect
14 min readMay 29, 2021

--

In one of the earlier blogs, we went through the basics of Git ,and how to get started with Git. We also saw some of the commands to create repositories, add and commit files, etc. In this blog, we will go through the most common and frequently used Git commands.

Git has more than a hundred commands ! Check them out here.

Git terminologies

There are 3 main components in Git

  • Working Area → Directory where one is currently working on.
  • Staging Area (Index) → The commits are prepared here before they are pushed to the repository.
  • Repository → Main container where all the commits ( along with the full change history) are maintained.

The files from the working area are first moved to the staging area before they can be pushed to the actual repository.

What is a HEAD ?

HEAD is a special reference or a pointer that points to the commit that a person is currently working on. It usually points to the tip or head of the currently active branch, which is represented in the .git/HEAD

$ cat .git/HEAD
ref: refs/heads/master

When you use the git checkout command, HEAD is changed to point to the head of the newly checked out branch. So if you run the command git checkout develop, the HEAD file will be changed as shown below

$ git checkout develop$ cat .git/HEAD
ref: refs/heads/develop

In case one checkouts a particular commitID or a tag, the HEAD will get detached (no longer in a Git branch). This places Git into a state called detached HEAD, which means that HEAD is not currently pointing to a branch head. In this state, you can view and edit any files in the repository, exactly as they were in that commit. To come out of this state, there are multiple options

  • Checkout into a different branch [ but you will lose the changes though ]
  • Create a move to a new branch, by doing so, HEAD will start pointing to the tip of the new branch. The new branch can be later merged into the desired branch

Try the below command to show the head current details

git show head

main or master is a name commonly given to the main branch

origin is a name commonly given to the main remote. The repository could exist on a git hosting provider like Github or Gitlab, etc.

Once you have git installed on your local system, you should first set the global configs to avoid repeated entry of the same details while performing the git operations.

Setting global configs like username and emailIds

git config —global

#Setting global configs
$ git config --global user.name "Mentor Konnect"
$ git config --global user.email xxxxxxxx@gmail.com
#Let's check the config now
$ git config --list --show-origin
file:/Library/Developer/CommandLineTools/usr/share/git-core/gitconfig
credential.helper=osxkeychain
file:/Users/mentorkonnect/.gitconfig user.name=Mentor Konnect
file:/Users/mentorkonnect/.gitconfig user.email=xxxxxxx@gmail.com

Git common commands

To create a new local repository

git init

$ mkdir git-test-dir
$ cd git-test-dir/
$ git init
Initialized empty Git repository in /Users/mentorkonnect/MK/git/git-test-dir/.git/

To clone a remote repository

git clone <remote-repository>

$ git clone <https://github.com/mentorkonnect/SparkStreaming.git>
Cloning into 'SparkStreaming'...
Username for '<https://github.com>': xxxxxxx@gmail.com
Password for '<https://xxxxxxx@gmail.com>@github.com':
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
# let's check the files in the cloned repository
$ cd SparkStreaming/
$ ls -l

total 8
-rw-r--r-- 1 mentorkonnect 16 May 29 16:13 [README.md](<http://readme.md/>)

To pull the latest updates from the repository, use the git pull command. It basically fetches and merges the latest updates into the working directory.

git pull

To check the current and all the created branches

git branch

git branch -a

# Displays local branches 
$ git branch
* main
# Displays remote and local branches
$ git branch -a
* main
remotes/origin/HEAD -> origin/main
remotes/origin/main

To check the commit logs so far

git log

git log --oneline

$ git log
commit 06455854cb8473c899d4f1c9b8da524e20 (HEAD -> main, origin/main, origin/HEAD)
Author: mentorkonnect [82513869+mentorkonnect@users.noreply.github.com](<mailto:82513869+mentorkonnect@users.noreply.github.com>)
Date: Fri May 28 22:01:32 2020 +0530
Initial commit

To create a new branch

git branch <branch-name>

#creating a new branch `develop`
$ git branch develop

To checkout a particular branch

git checkout <branch-name>

# let's checkout the develop branch [ current working branch ]
$ git checkout develop
Switched to branch 'develop'
# the '*' against the branch name indicates that its the current branch
$ git branch -a
* develop
main
remotes/origin/HEAD -> origin/main
remotes/origin/main

To check the status

git status

# create a test file names 'SparkTest.java'
$ touch SparkTest.java
$ ls -l
total 8
-rw-r--r-- 1 mentorkonnect 16 May 29 16:13 [README.md](<http://readme.md/>)
-rw-r--r-- 1 mentorkonnect 0 May 29 17:20 SparkTest.java
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
SparkTest.java
nothing added to commit but untracked files present (use "git add" to track)

Committing the code

git add or git add <filename>

git commit

git push

Before we commit some code, let’s create a new branch (for later demonstration) and add files in it

# Creating a new branch named 'master'$ git branch master
$ git checkout master
Switched to branch 'master'
$ git branch -a
develop
main
*master
remotes/origin/HEAD -> origin/main
remotes/origin/main
# creating a new test file 'SparkStreamingTest.java' in master branch
$ touch SparkStreamingTest.java
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
SparkStreamingTest.java
SparkTest.java
nothing added to commit but untracked files present (use "git add" to track)

To add the uncommitted files ..

Adding the files

# git add -A adds all the uncommitted files, one can use git add <filename> to add specific files$ git add -A$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: SparkStreamingTest.java
new file: SparkTest.java

Committing the files (Staging Area)

$ git commit -m "First commit"
[master dbab4bf] First commit
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 SparkStreamingTest.java
create mode 100644 SparkTest.java
$ git status
On branch master
nothing to commit, working tree clean
$ ls -l
total 8
-rw-r--r-- 1 mentorkonnect 16 May 29 16:13 [README.md](<http://readme.md/>)
-rw-r--r-- 1 mentorkonnect 0 May 29 17:28 SparkStreamingTest.java
-rw-r--r-- 1 mentorkonnect 0 May 29 17:28 SparkTest.java

You will encounter the below issue if it is the first time you are committing a new branch $ git push fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin <branch-name>

There are 2 ways in which you can push the commit to the remote repository

git push -u origin

git push --set-upstream origin <branch-name>

$ git push -u origin master
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 333 bytes | 333.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote:
remote: Create a pull request for 'master' on GitHub by visiting:
remote: [<https://github.com/mentorkonnect/SparkStreaming/pull/new/master>](<https://github.com/mentorkonnect/SparkStreaming/pull/new/master>)
remote:
To [<https://github.com/mentorkonnect/SparkStreaming.git>](<https://github.com/mentorkonnect/SparkStreaming.git>)
[new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
$ git log
commit dbab4bf912311601c7b7f685fee7c4c9768220c6 (HEAD -> master, origin/master)
Author: Mentor Konnect [mentorkonnects@gmail.com](<mailto:mentorkonnects@gmail.com>)
Date: Sat May 29 17:25:53 2021 +0530
First commit
commit 06455854cb8473c899d4f1c99cdfa9b8da524e20 (origin/main, origin/HEAD, main,
develop)
Author: mentorkonnect [82513869+mentorkonnect@users.noreply.github.com](<mailto:82513869+mentorkonnect@users.noreply.github.com>)
Date: Fri May 28 22:01:32 2021 +0530
Initial commit

Switching back to the ‘develop’ branch that was created earlier for further demonstration

$ git checkout develop
Switched to branch 'develop'
$ ls -l
total 8
-rw-r--r-- 1 mentorkonnect 16 May 29 16:13 [README.md](<http://readme.md/>)
#Creating new files 'TestDevelop.java' and 'TestDevelopNew.java'
$ touch TestDevelop.java
$ touch TestDevelopNew.java
$ ls -l
total 8
-rw-r--r-- 1 mentorkonnect 16 May 29 16:13 [README.md](<http://readme.md/>)
-rw-r--r-- 1 mentorkonnect 0 May 29 17:29 TestDevelop.java
-rw-r--r-- 1 mentorkonnect 0 May 29 17:34 TestDevelopNew.java
$ git log
commit 06455854cb8473c899d4f1c99cdfa9b8da524e20 (HEAD -> develop, origin/main,
origin/HEAD, main)
Author: mentorkonnect [82513869+mentorkonnect@users.noreply.github.com](<mailto:82513869+mentorkonnect@users.noreply.github.com>)
Date: Fri May 28 22:01:32 2021 +0530
Initial commit
$ git status
On branch develop
Untracked files:
(use "git add <file>..." to include in what will be committed)
TestDevelop.java
TestDevelopNew.java
nothing added to commit but untracked files present (use "git add" to track)

To add a tag before a commit

git tag -a <tag_name> -m <message>

$ git tag -a v1.0 -m 'First commit to branch develop'

To commit the ‘develop’ branch

$ git add -A$ git status
On branch develop
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: TestDevelop.java
new file: TestDevelopNew.java
$ git commit -m 'First commit in branch develop'
[develop 598bb4d] First commit in branch develop
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 TestDevelop.java
create mode 100644 TestDevelopNew.java
$ git status
On branch develop
nothing to commit, working tree clean
$ git log
commit 598bb4d7066f5b9c57957f3449c38e5ca0562e9e (HEAD -> develop)
Author: Mentor Konnect [mentorkonnects@gmail.com](<mailto:mentorkonnects@gmail.com>)
Date: Sat May 29 17:37:38 2021 +0530
First commit in branch develop
commit 06455854cb8473c899d4b8da524e20 (tag: v1.0, origin/main, origin/HEAD, main)
Author: mentorkonnect [82513869+mentorkonnect@users.noreply.github.com](<mailto:82513869+mentorkonnect@users.noreply.github.com>)
Date: Fri May 28 22:01:32 2021 +0530
Initial commit

Pushing the ‘develop’ branch to the remote repository for the first time

$ git push -u origin develop
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 344 bytes | 344.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote:
remote: Create a pull request for 'develop' on GitHub by visiting:
remote: [<https://github.com/mentorkonnect/SparkStreaming/pull/new/develop>](<https://github.com/mentorkonnect/SparkStreaming/pull/new/develop>)
remote:
To [<https://github.com/mentorkonnect/SparkStreaming.git>](<https://github.com/mentorkonnect/SparkStreaming.git>)
[new branch] develop -> develop
Branch 'develop' set up to track remote branch 'develop' from 'origin'.
$ git log
commit 598bb4d7066f5b9c57957f3449c38e5ca0562e9e (HEAD -> develop, origin/develop)
Author: Mentor Konnect [mentorkonnects@gmail.com](<mailto:mentorkonnects@gmail.com>)
Date: Sat May 29 17:37:38 2021 +0530
First commit in branch developcommit 06455854cb8473c899d4f1c99cdfa9b8da524e20 (tag: v1.0, origin/main,
origin/HEAD, main)
Author: mentorkonnect [82513869+mentorkonnect@users.noreply.github.com](<mailto:82513869+mentorkonnect@users.noreply.github.com>)
Date: Fri May 28 22:01:32 2021 +0530
Initial commit$ git branch -a
*develop
main
master
remotes/origin/HEAD -> origin/main
remotes/origin/develop
remotes/origin/main
remotes/origin/master

Let’s see how to delete files

#Creating one more file 'Test3.java' which can be deleted later
$ touch Test3.java
$ ls -l
total 8
-rw-r--r-- 1 mentorkonnect 16 May 29 16:13 [README.md](<http://readme.md/>)
-rw-r--r-- 1 mentorkonnect 0 May 29 17:29 TestDevelop.java
-rw-r--r-- 1 mentorkonnect 0 May 29 17:34 TestDevelopNew.java
-rw-r--r-- 1 mentorkonnect 0 May 29 17:34 Test3.java
$ git add -A$ git commit -m 'Second commit in branch develop'
[develop c9ec99e] Second commit in branch develop
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 Test3.java
$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 245 bytes | 245.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To <https://github.com/mentorkonnect/SparkStreaming.git>
598bb4d..c9ec99e develop -> develop
$ git log
commit c9ec99ed5ab711d135d14eb898654747f13b01e4 (HEAD -> develop, origin/develop)
Author: Mentor Konnect <mentorkonnects@gmail.com>
Date: Sat May 29 17:40:29 2021 +0530
Second commit in branch developcommit 598bb4d7066f5b9c57957f3449c38e5ca0562e9e
Author: Mentor Konnect <mentorkonnects@gmail.com>
Date: Sat May 29 17:37:38 2021 +0530
First commit in branch developcommit 06455854cb8473c899d4f1c99cdfa9b8da524e20 (tag: v1.0, origin/main,
origin/HEAD, main)
Author: mentorkonnect <82513869+mentorkonnect@users.noreply.github.com>
Date: Fri May 28 22:01:32 2021 +0530

To remove a file

git rm <filename>

$ git rm Test3.java
rm 'Test3.java'
$ git status
On branch develop
Your branch is up to date with 'origin/develop'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: Test3.java
#Commit the changes for the delete to go through$ git commit -m 'Deleting file Test3.java from the branch develop'
[develop a15c844] Deleting file Test3.java from the branch develop
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 Test3.java
$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 259 bytes | 259.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To <https://github.com/mentorkonnect/SparkStreaming.git>
c9ec99e..a15c844 develop -> develop
$ git log
commit a15c8445b78635f0853f8ec196a2567250a530a5 (HEAD -> develop, origin/develop)
Author: Mentor Konnect <mentorkonnects@gmail.com>
Date: Sat May 29 17:42:04 2021 +0530
Deleting file Test3.java from the branch developcommit c9ec99ed5ab711d135d14eb898654747f13b01e4
Author: Mentor Konnect <mentorkonnects@gmail.com>
Date: Sat May 29 17:40:29 2021 +0530
Second commit in branch developcommit 598bb4d7066f5b9c57957f3449c38e5ca0562e9e
Author: Mentor Konnect <mentorkonnects@gmail.com>
Date: Sat May 29 17:37:38 2021 +0530
First commit in branch developcommit 06455854cb8473c899d4f1c99cdfa9b8da524e20 (tag: v1.0, origin/main,
origin/HEAD, main)
Author: mentorkonnect <82513869+mentorkonnect@users.noreply.github.com>
Date: Fri May 28 22:01:32 2021 +0530
Initial commit

To revert back to a particular commit

git revert <commitId>

$ git revert 598bb4d7066f5b9c57957f3449c38e5ca0562e9e
Removing TestDevelopNew.java
Removing TestDevelop.java
$ ls -l
total 8
-rw-r--r-- 1 mentorkonnect 16 May 29 16:13 [README.md](<http://readme.md/>)
$ git log
commit a15c8445b78635f0853f8ec196a2567250a530a5 (HEAD -> develop, origin/develop)
Author: Mentor Konnect [mentorkonnects@gmail.com](<mailto:mentorkonnects@gmail.com>)
Date: Sat May 29 17:42:04 2021 +0530
Deleting file Test3.java from the branch developcommit c9ec99ed5ab711d135d14eb898654747f13b01e4
Author: Mentor Konnect [mentorkonnects@gmail.com](<mailto:mentorkonnects@gmail.com>)
Date: Sat May 29 17:40:29 2021 +0530
Second commit in branch developcommit 598bb4d7066f5b9c57957f3449c38e5ca0562e9e
Author: Mentor Konnect [mentorkonnects@gmail.com](<mailto:mentorkonnects@gmail.com>)
Date: Sat May 29 17:37:38 2021 +0530
First commit in branch developcommit 06455854cb8473c899d4f1c99cdfa9b8da524e20 (tag: v1.0, origin/main,
origin/HEAD, main)
Author: mentorkonnect [82513869+mentorkonnect@users.noreply.github.com](<mailto:82513869+mentorkonnect@users.noreply.github.com>)
Date: Fri May 28 22:01:32 2021 +0530
Initial commit

To find out the difference between 2 commits

git diff <commit1> <commit2>

You can use the ‘difftool’ for comparing differences

git difftool <commit1> <commit2>

$ git diff a15c8445b78635f0853f8ec1250a530a5 c9ec99ed5ab898654747f13b01e4
diff --git a/Test3.java b/Test3.java
new file mode 100644
index 0000000..e69de29
$ git log
commit a15c8445b78635f0853f8ec196a2567250a530a5 (HEAD -> develop, origin/develop)
Author: Mentor Konnect [mentorkonnects@gmail.com](<mailto:mentorkonnects@gmail.com>)
Date: Sat May 29 17:42:04 2021 +0530
Deleting file Test3.java from the branch develop
commit c9ec99ed5ab711d135d14eb898654747f13b01e4
Author: Mentor Konnect <mentorkonnects@gmail.com>
Date: Sat May 29 17:40:29 2021 +0530
Second commit in branch developcommit 598bb4d7066f5b9c57957f3449c38e5ca0562e9e
Author: Mentor Konnect <mentorkonnects@gmail.com>
Date: Sat May 29 17:37:38 2021 +0530
First commit in branch developcommit 06455854cb8473c899d4f1cda524e20 (tag: v1.0, origin/main, origin/HEAD, main)
Author: mentorkonnect <82513869+mentorkonnect@users.noreply.github.com>
Date: Fri May 28 22:01:32 2021 +0530
Initial commit

If things are in a messy state and you want to switch branches for a bit to work on something else. The problem is, you don’t want to do a commit of half-done work just so you can get back to this point later. The answer to this issue is the git stash command.

Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time (even on a different branch).

Ref: https://git-scm.com/book/en/v2/Git-Tools-Stashing-and-Cleaning

git stash

git stash list

To re-apply the recently stashed files

git stash apply

$ git stash
Saved working directory and index state WIP on develop:
a15c844 Deleting file Test3.java from the branch develop

To merge 2 branches

git merge <branch-name>

$ git branch
* develop
main
master
# Merges the 'master' branch into the current 'develop' branch
$ git merge master
Merge made by the 'recursive' strategy.
SparkStreamingTest.java | 0
SparkTest.java | 0
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 SparkStreamingTest.java
create mode 100644 SparkTest.java

$ git log --oneline
a017a81 (HEAD -> develop) Merge branch 'master' into develop Merging develop and
master
a15c844 (origin/develop) Deleting file Test3.java from the branch develop
c9ec99e Second commit in branch develop
598bb4d First commit in branch develop
dbab4bf (origin/master, master) First commit
0645585 (tag: v1.0, origin/main, origin/HEAD, main) Initial commit

Let’s check the content of the git ref files in the working directory

$ cat .git/refs/heads/master 
dbab4bf912311601c7b7f685fee7c4c9768220c6
$ cat .git/refs/heads/develop
a017a814c19738491c892b374f527419c9da8d44

Git Reset

To undo changes, one can use git reset. Use one of the below 3 options while doing a git reset.

  • Soft → The Staging Area and the Working Directory are left untouched.
  • Mixed → This is the default mode. The Staging Area is reset to the state of the mentioned commit. And the changes undone from the Staging Area are moved to the Working Directory.
  • Hard → This is quite commonly used, but comes with the risk of losing the uncommitted changes. The Staging Area and Working Directory are reset to the specified commit and all the uncommitted files are lost.

For further reading, visit this link

# creating a new file 
$ touch NewFile1.java
# Editing an existing file
$ echo "Message ABC" > SparkTest.java
$ git status
On branch develop
Your branch is ahead of 'origin/develop' by 2 commits.
(use "git push" to publish your local commits)
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: SparkTest.javaUntracked files:
(use "git add <file>..." to include in what will be committed)
NewFile1.java
no changes added to commit (use "git add" and/or "git commit -a")
# Adding only SparkTest to staging area
$ git add SparkTest.java
$ git status
On branch develop
Your branch is ahead of 'origin/develop' by 2 commits.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: SparkTest.java
Untracked files:
(use "git add <file>..." to include in what will be committed)
NewFile1.java
$ git log --oneline
a017a81 (HEAD -> develop) Merge branch 'master' into develop Merging develop and
master
a15c844 (origin/develop) Deleting file Test3.java from the branch develop
c9ec99e Second commit in branch develop
598bb4d First commit in branch develop
dbab4bf (origin/master, master) First commit
0645585 (tag: v1.0, origin/main, origin/HEAD, main) Initial commit

As evident above, there are two files which have not been committed and pushed yet. File SparkTest.java is in Staging area as we have already fired the git add command, and the file NewFile1.java is still in the working directory.

# Checking the current log$ git log --oneline
a017a81 (HEAD -> develop) Merge branch 'master' into develop Merging develop
and master
a15c844 (origin/develop) Deleting file Test3.java from the branch develop
c9ec99e Second commit in branch develop
598bb4d First commit in branch develop
dbab4bf (origin/master, master) First commit
0645585 (tag: v1.0, origin/main, origin/HEAD, main) Initial commit
$ cat .git/refs/heads/develop
a017a814c19738491c892b374f527419c9da8d44
$ git reset --hard
HEAD is now at a017a81 Merge branch 'master' into develop Merging develop and
master
# The file in the staging area has been lost, hence git reset hard could be a
#dangerous option and should be used with utmost precaution
$ git status
On branch develop
Your branch is ahead of 'origin/develop' by 2 commits.
(use "git push" to publish your local commits)
Untracked files:
(use "git add <file>..." to include in what will be committed)
NewFile1.java
nothing added to commit but untracked files present (use "git add" to track)$ git log --oneline
a017a81 (HEAD -> develop) Merge branch 'master' into develop Merging develop
and master
a15c844 (origin/develop) Deleting file Test3.java from the branch develop
c9ec99e Second commit in branch develop
598bb4d First commit in branch develop
dbab4bf (origin/master, master) First commit
0645585 (tag: v1.0, origin/main, origin/HEAD, main) Initial commit

Quick Note..
Git HEAD^ The Caret (^) is the parent of the Commit.

Git HEAD~ The tilde (~) is a shorthand character for a row of several characters (^). The equivalence of HEAD~2 to HEAD^^

To find the difference between the last 2 commits before the latest one 
git diff Head~1 Head~2

Using the git reset —hard <commit>

# Another way of doing a hard reset is to pass the particular level you want the 
# HEAD to move to. In this case, let's try going to the commit before the current
# one.
$ git reset --hard HEAD^
HEAD is now at a15c844 Deleting file Test3.java from the branch develop
$ git log --oneline
a15c844 (HEAD -> develop, origin/develop) Deleting file Test3.java from the
branch develop
c9ec99e Second commit in branch develop
598bb4d First commit in branch develop
0645585 (tag: v1.0, origin/main, origin/HEAD, main) Initial commit
$ git status
On branch develop
Your branch is up to date with 'origin/develop'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
NewFile1.java
nothing added to commit but untracked files present (use "git add" to track)

References :

https://git-scm.com

--

--

Mentor Konnect

Mentor Konnect is a learning platform to upskill one's technical expertise specially in the areas of Big Data, Data science, ML & AI and other niche domains.