Difference between revisions of "How to do git tricks"

From openwfm
Jump to navigation Jump to search
Line 17: Line 17:
 
git push -u origin rep2/branch2:rep2/branch2
 
git push -u origin rep2/branch2:rep2/branch2
 
</pre>
 
</pre>
There is no need for the two repository to have a common initial commit or anything.  
+
There is no need for the two repositories to have a common initial commit or anything.  
 
The commit hashes are preserved. You can even <tt>git cherry-pick</tt> commit from the other repostory and git will do pretty good job finding files to apply the commits to, even if the files have somewhat different names and are in somewhat different locations in the file two file trees.
 
The commit hashes are preserved. You can even <tt>git cherry-pick</tt> commit from the other repostory and git will do pretty good job finding files to apply the commits to, even if the files have somewhat different names and are in somewhat different locations in the file two file trees.

Revision as of 06:38, 18 January 2019

Comparing files

From https://stackoverflow.com/questions/8131135/git-how-to-diff-two-different-files-in-different-branches

git diff branch1:full/path/to/foo.txt branch2:full/path/to/foo-another.txt

How to link to such comparison view on github?

Cherry pick commit and update only some files

?

Include branch from an unrelated repository

git remote add rep2-git url_to_unrelated_repository
git fetch rep2-git
git checkout remotes/rep2-git/branch2
git checkout -b rep2/branch2
git push -u origin rep2/branch2:rep2/branch2

There is no need for the two repositories to have a common initial commit or anything. The commit hashes are preserved. You can even git cherry-pick commit from the other repostory and git will do pretty good job finding files to apply the commits to, even if the files have somewhat different names and are in somewhat different locations in the file two file trees.