Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

git go back to previous commit temporarily

---- [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 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 :: gem install version 
Shell :: cmp in linux 
Shell :: laravel sail composer 
Shell :: ufw add rule with comment 
Shell :: search package linux 
Shell :: .gitignore 
Shell :: etherum for ubuntu 
Shell :: apt update package 
Shell :: github git init main 
Shell :: how to increase font size in elementary os 
Shell :: gh ubuntu 
Shell :: echo new line 
Shell :: docker Error: no space left on device 
Shell :: refusing to exec crouton from noexec mount 
Shell :: bash parameter 
Shell :: vim exit 
Shell :: zsh: command not found: wine-stable 
Shell :: grep exclude files 
Shell :: bash case statement 
Shell :: html2canvas 
Shell :: enable apache2 site 
Shell :: generate git ssh key 
Shell :: git squash commits merge 
Shell :: push the project to github 
Shell :: ssh github 
Shell :: create and switch to a branch 
Shell :: terraform install on ubuntu 
Shell :: check gcp disk space usage 
Shell :: tail last 100 lines 
Shell :: postinstall docker 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =