سؤال

I don't know if Git has the concept of a revision.

I'd like to diff the current working copy with an older version of it (not necessarily the last commit).

It would be great if it could be done inside Emacs.

هل كانت مفيدة؟

المحلول

I've no idea about doing this inside Emacs, but:

git diff rev1..rev2

will do what you want for the whole repository. You can then add to that:

 git diff rev1>..rev2 path

path can be an absolute path to a file, or a path to a directory, so you can diff subtrees.

If you're looking to diff the working copy - just specify revision 1:

git diff rev1 path

The revision codes can be special names, for example, HEAD^..HEAD means last to current, or their SHA-1 values from the logs.

نصائح أخرى

To do this in Emacs (using magit) you can:

  1. From a magit buffer press d to open up the diff menu
  2. Press r to select the range of commits to use in the diff. Alternatively, you can highlight a range of commits and they will automatically be selected.

If you only want to diff certain files, you can also use the -- option to select which files will be included in the diff.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top