[MacPorts] WorkingWithGit modified

MacPorts noreply at macports.org
Sat Aug 20 14:50:31 PDT 2016


Page "WorkingWithGit" was changed by cal at macports.org
Diff URL: <https://trac.macports.org/wiki/WorkingWithGit?action=diff&version=19>
Revision 19
Comment: Document reverting
Changes:
-------8<------8<------8<------8<------8<------8<------8<------8<--------
Index: WorkingWithGit
=========================================================================
--- WorkingWithGit (version: 18)
+++ WorkingWithGit (version: 19)
@@ -166,6 +166,15 @@
  1. Use the imperative mood in the subject line
  1. Wrap the body at 72 characters
  1. Use the body to explain what and why vs. how
+
+=== Reverting changes === #revert
+Subversion has two methods for reverting changes: `svn revert`, which drops uncommitted local modifications and restores the committed state and `svn merge -c -12345` to undo committed changes.
+
+Due to Git's distributed nature, there are three stages that can be reverted:
+
+ - To drop uncommitted modifications, use `git checkout -- <filename>`. If you had already added the file to the index using `git add`, you have to unstage it first using `git reset HEAD <filename>`. `git status` prints these commands, so you don't have to remember them.
+ - To undo a change that has already been committed and pushed, use `git revert <commitID>`. This will create a new commit that applies the inverse diff. Note that you still have to push this commit to publish it.
+ - To throw away all changes that you have locally committed but not yet pushed, use `git reset --hard origin/master`. '''You will loose all your uncommitted and committed modifications.''' If that is not what you want, Git provides a variety of tools that allow you to change commits that you have not pushed yet (and theoretically also commits that have already been pushed, which will prevent you from pushing any changes again). Since this is an advanced topic it will not be covered here. As a pointer for further research, look for `git commit --amend` to change the topmost commit and `git rebase --interactive`, the so-called "interactive rebase", to change older commits.
 
 === Repository split === #reposplit
 
-------8<------8<------8<------8<------8<------8<------8<------8<--------

--
Page URL: <https://trac.macports.org/wiki/WorkingWithGit>
MacPorts <https://www.macports.org/>
Ports system for OS X

This is an automated message. Someone added your email address to be
notified of changes on 'WorkingWithGit' page.
If it was not you, please report to .


More information about the macports-changes mailing list