--soft: uncommit changes, changes are left staged (index).
git log --oneline
c6e3374 (HEAD -> main) Revert "ticket 93"
0f70f4f ticket 93
3ab8b74 ticket 92
9f58820 (origin/main, origin/HEAD) new file
2c76a55 first commit
echo "new file" > new.txt
git add -A
git commit -m new.txt
[main 7ae912c] new.txt
1 file changed, 1 insertion(+)
create mode 100644 new.txt
git log --oneline
7ae912c (HEAD -> main) new.txt
c6e3374 Revert "ticket 93"
0f70f4f ticket 93
3ab8b74 ticket 92
9f58820 (origin/main, origin/HEAD) new file
2c76a55 first commit
git reset --soft c6e3374
git log --oneline
c6e3374 (HEAD -> main) Revert "ticket 93"
0f70f4f ticket 93
3ab8b74 ticket 92
9f58820 (origin/main, origin/HEAD) new file
2c76a55 first commit
git status
On branch main
Your branch is ahead of 'origin/main' by 3 commits.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: new.txt
--mixed (default): uncommit + unstage changes, changes are left in working tree.
git commit -m "new file for --mixed"
[main 16ca1a9] new file for --mixed
1 file changed, 1 insertion(+)
create mode 100644 new.txt
emailid@ip-172-3X-21-XX7:~/gitdemo_feb$ git status
On branch main
Your branch is ahead of 'origin/main' by 4 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
git log --oneline
16ca1a9 (HEAD -> main) new file for --mixed
c6e3374 Revert "ticket 93"
0f70f4f ticket 93
3ab8b74 ticket 92
9f58820 (origin/main, origin/HEAD) new file
2c76a55 first commit
git reset c6e3374
OR
git reset --mixed c6e3374
git log --oneline
c6e3374 (HEAD -> main) Revert "ticket 93"
0f70f4f ticket 93
3ab8b74 ticket 92
9f58820 (origin/main, origin/HEAD) new file
2c76a55 first commit
emailid@ip-172-3X-21-XX7:~/gitdemo_feb$ git status
On branch main
Your branch is ahead of 'origin/main' by 3 commits.
(use "git push" to publish your local commits)
Untracked files:
(use "git add <file>..." to include in what will be committed)
new.txt
nothing added to commit but untracked files present (use "git add" to track)
--hard: uncommit + unstage + delete changes, nothing left.
git add -A
git commit -m "commit for --hard"
[main 9022f76] commit for --hard
1 file changed, 1 insertion(+)
create mode 100644 new.txt
git log --oneline
9022f76 (HEAD -> main) commit for --hard
c6e3374 Revert "ticket 93"
0f70f4f ticket 93
3ab8b74 ticket 92
9f58820 (origin/main, origin/HEAD) new file
2c76a55 first commit
ls
file1 file2 new.txt
git reset --hard c6e3374
HEAD is now at c6e3374 Revert "ticket 93"
ls
file1 file2
git log --oneline
c6e3374 (HEAD -> main) Revert "ticket 93"
0f70f4f ticket 93
3ab8b74 ticket 92
9f58820 (origin/main, origin/HEAD) new file
2c76a55 first commit
No comments:
Post a Comment