I have two branches which have very little similar history, but are related to each other.
I want the changes between those two in one git commit.
files have been deleted and created between those patches and I want the patch to reflect that
i.e.: the following stuff will not work:
git diff branch_a branch_b -- > patchfile git checkout branch_b git apply patchfile # deletes and adds are ignored git commit # we miss the deletes
In some cases, you may be interested in knowing the commit differences between two branches. In order to see the commit differences between two branches, use the “git log” command and specify the branches that you want to compare.
Yes, two branches can point to the same commits.
On the Github, go to the Source view of your project. You will see a link named 'Branch List'. Once the page opens you can see a list of all the remote branches. Hit on the Compare button in front of any of the available branches to see the difference between two branches.
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.
A simple way to make "the diff from branch_b..branch_a" into a commit is:
git branch tmp branch_a && git checkout tmp
) (or git reset --hard branch_a
on an existing branch)git reset --soft branch_b
git commit
that commit will include all the diff between branch_b and branch_a.
This works because
1.
causes the files to reflect branch_a. This is the "end result" you want for the branch2.
“resets the head to branch_b” but “leaves all your changed files [i.e. branch_a head] as "Changes to be committed", as git status
would put it.” ←(git reset --soft
docs, with this example's branches added) 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