I am using Git on Ubuntu 10.04 (Lucid Lynx).
I have made some commits to my master.
However, I want to get the difference between these commits. All of them are on my master branch.
For example:
commit dj374 made changes commit y4746 made changes commit k73ud made changes
I want to get the difference between k73ud and dj374. However, when I did the following I couldn't see the changes I made in k73ud
.
git diff k73ud..dj374 > master.patch
To see the diff for a particular COMMIT hash, where COMMIT is the hash of the commit: git diff COMMIT~ COMMIT will show you the difference between that COMMIT 's ancestor and the COMMIT .
If you have the hash for a commit, you can use the git show command to display the changes for that single commit. The output is identical to each individual commit when using git log -p .
Comparing changes with git diff Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.
We can view the unpushed git commits using the git command. It will display all the commits that are made locally but not pushed to the remote git repository.
Try
git diff k73ud^..dj374
to make sure to include all changes of k73ud
in the resulting diff.
git diff
compares two endpoints (instead of a commit range). Since the OP want to see the changes introduced by k73ud
, he/she needs to difference between the first parent commit of k73ud
: k73ud^
(or k73ud^1
or k73ud~
).
That way, the diff
results will include changes since k73ud
parent (meaning including changes from k73ud
itself), instead of changes introduced since k73ud
(up to dj374
).
Also you can try:
git diff oldCommit..newCommit git diff k73ud..dj374
and (1 space, not more):
git diff oldCommit newCommit git diff k73ud dj374
And if you need to get only files names (e.g. to copy hotfix them manually):
git diff k73ud dj374 --name-only
And you can get changes applied to another branch:
git diff k73ud dj374 > my.patch git apply my.patch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With