Git is popular distributed and open source version control systems. It is very easy to use. Let us see how can we revert to previous commit.
In order to demo this, I have created a sample repo in GitHub. You can clone it without using ssh keys. You can also try in your Sample Repo as well.
git clone https://github.com/akannan1087/myRepoForJavaApp.git
cd myRepoForJavaApp
First code commit
Let us create a text file called hello.txt
sudo vi hello.txt
Add one line like below
First commit!
git add hello.txt
git commit -m "making our first commit"
git push
you will see all commits with latest commit in the top.
Second code commit
sudo vi hello.txt
Add one line like below
First commit!
Second commit!
git add hello.txt
git commit -m "making our second commit"
git push
third code commit
sudo vi hello.txt
Add one line like below
First commit!
Second commit!
Third commit!!!
git add hello.txt
git commit -m "making our third commit"
git push
Try to view all commits in one line
git log --oneline
547d163 making our third commit
1ec0921 making our second commit
550095c making our first commit
1bad8df Update index.jsp
c206c37 Update index.jsp
161a241 Update index.jsp
5b4e649 my first project setup in GitHub
b429bb6 Initial commit
How to revert to first commit
Now let us say we want to revert to first commit # 550095c making our first commit
git checkout 550095c hello.txt
type git status
git commit -m "reverting to first commit"
git push
cat hello.txt
Please click here if you want to learn more about Git.
In order to demo this, I have created a sample repo in GitHub. You can clone it without using ssh keys. You can also try in your Sample Repo as well.
git clone https://github.com/akannan1087/myRepoForJavaApp.git
cd myRepoForJavaApp
First code commit
Let us create a text file called hello.txt
sudo vi hello.txt
Add one line like below
First commit!
git add hello.txt
git commit -m "making our first commit"
git push
you will see all commits with latest commit in the top.
Second code commit
sudo vi hello.txt
Add one line like below
First commit!
Second commit!
git add hello.txt
git commit -m "making our second commit"
git push
third code commit
sudo vi hello.txt
Add one line like below
First commit!
Second commit!
Third commit!!!
git add hello.txt
git commit -m "making our third commit"
git push
Try to view all commits in one line
git log --oneline
547d163 making our third commit
1ec0921 making our second commit
550095c making our first commit
1bad8df Update index.jsp
c206c37 Update index.jsp
161a241 Update index.jsp
5b4e649 my first project setup in GitHub
b429bb6 Initial commit
How to revert to first commit
Now let us say we want to revert to first commit # 550095c making our first commit
git checkout 550095c hello.txt
type git status
git commit -m "reverting to first commit"
git push
cat hello.txt
Please click here if you want to learn more about Git.

F00CA06A1C
ReplyDeletetakipçi satın al
Aşk Acısına İyi Gelen İlaç
Kredi Çıkaran Firmalar
Fake Numara
Türk Takipçi
Clear and simple explanation! I remember struggling the first time I tried to undo changes in Git, but this step-by-step guide makes it less intimidating. I’ll definitely use this approach in my next project.
ReplyDelete23976CF9DD
ReplyDeleteTakipçi Satın Al
3D Car Parking Para Kodu
Google Yorum Satın Al
Eti Mutlu Kutu Kodları
Call of Dragons Hediye Kodu
05387FD503
ReplyDeletesteroid satın al
Görüntülü Sex
steroid sipariş