Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

git go back a commit

# as the best wat to revert back 3 commits
git revert HEAD~3
git restore #to restore files from commit
Comment

git got to previous commit

---- [Temporarily switch to a different commit] ----
# If you want to temporarily go back to a particular commit, fool around, 
# then come back to where you are
> git checkout 0d1d7fc32

# Or if you want to make commits while you're there, 
# go ahead and make a new branch while you're at it:
> git checkout -b old-state 0d1d7fc32 

---- [Hard delete unpublished commits] ----
# If, on the other hand, you want to really get rid of everything you've done
# since then, there are two possibilities.
# One, if you haven't published any of these commits, simply reset:

# This will destroy any local modifications.
# Don't do it if you have uncommitted work you want to keep.
> git reset --hard 0d1d7fc32

# Alternatively, if there's work to keep:
> git stash
> git reset --hard 0d1d7fc32
> git stash pop
# This saves the modifications, then reapplies that patch after resetting.
# You could get merge conflicts, if you've modified things which were
# changed since the commit you reset to.
Comment

git go back to previous commit

git checkout 12feg3435 #commit ID
Comment

git go back one commit

#You need to be careful with going back a commit, you could reset your 
#branch and loose all of your work. 

#safe option:
git checkout <commit-id>




Comment

git go back to commit

# Go back to the selected commit on your local environment
# Don't forget the . in the end
git checkout <commit-id> .

# Add this version to the staging area and push to remote
git add .
git commit -m "Reverting to <commit-id>"
git push
Comment

PREVIOUS NEXT
Code Example
Shell :: pip install django invalid syntax 
Shell :: windows cat grep equivalent 
Shell :: delete all mail terminal 
Shell :: NGINX systemd service file 
Shell :: install kubectl windows 
Shell :: cmd dir all files subfolders 
Shell :: how to chanbge port number on centos8 
Shell :: linux check if a group exist or not 
Shell :: remove untracked files git 
Shell :: git folder 
Shell :: git push to create 
Shell :: linux find files older than 15 minutes 
Shell :: how to push cloned repo 
Shell :: how to check wsl version 
Shell :: sed delete line match 
Shell :: powershell help 
Shell :: store environment variables in firebase functions 
Shell :: delete a folder then git push 
Shell :: how to create a branch in git 
Shell :: install node on fish-shell 
Shell :: how to install gdal on pyhon 3.9 
Shell :: how to open files using terminal in ubuntu 
Shell :: unittest run specific test 
Shell :: github new repository 
Shell :: Generate Key Hashes For Facebook login Android app 
Shell :: uninstall R 
Shell :: libqt5core5a is not installed. 
Shell :: ubuntu install mariadb 
Shell :: show pghba 
Shell :: kill nohup task job 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =