Add reverting commit
This commit is contained in:
parent
7c852486f7
commit
45a40783a9
|
@ -71,6 +71,22 @@ Second option:
|
|||
|
||||
Set the remote stream (~origin~ on this example) as ~main~ branch:
|
||||
|
||||
should create a branch called "main", then set as "upstream"
|
||||
|
||||
#+begin_example bash
|
||||
git branch --set-upstream-to=origin/main
|
||||
#+end_example
|
||||
|
||||
After this, you can use:
|
||||
|
||||
#+begin_example bash
|
||||
git pull
|
||||
#+end_example
|
||||
|
||||
And the branch "main" would be used as remote.
|
||||
|
||||
Optionally you may use the following when you have a new local repository:
|
||||
|
||||
#+begin_example bash
|
||||
git branch -u origin/main
|
||||
#+end_example
|
||||
|
|
|
@ -26,3 +26,36 @@ Unmodify a modified (not staged) file
|
|||
#+begin_example bash
|
||||
git restore file2
|
||||
#+end_example
|
||||
|
||||
** Reverting commits
|
||||
|
||||
First, check logs to verify the commiy hash you want to revert:
|
||||
|
||||
#+begin_example bash
|
||||
git log --oneline
|
||||
#+end_example
|
||||
|
||||
Verify the commit you wish to revert (use commit hash as argument):
|
||||
|
||||
#+begin_example bash
|
||||
git show 0114c758775d852a82f06ea439fdbc5200b36ed7
|
||||
#+end_example
|
||||
|
||||
Then, revert it:
|
||||
|
||||
#+begin_example bash
|
||||
git revert --strategy resolve 0114c758775d852a82f06ea439fdbc5200b36ed7
|
||||
#+end_example
|
||||
|
||||
#+begin_example bash
|
||||
git branch temp-branch
|
||||
git checkout master
|
||||
git merge temp-branch
|
||||
git push origin main
|
||||
#+end_example
|
||||
|
||||
* [[https://stackoverflow.com/questions/30471557/git-push-master-fatal-you-are-not-currently-on-a-branch][Reference]]
|
||||
|
||||
#+begin_example bash
|
||||
git log --pretty=format:"%h %s" --graph
|
||||
#+end_example
|
||||
|
|
Loading…
Reference in New Issue