Reputation: 137
I'm trying to do a quick & dirty compare against 2 directories that got have a .git directory and they are both related(one was initially a clone of the other). What I currently do is copy both down to my workstation, copy DIR-A to a working directory, commit all changes, delete all the files and then copy DIR-B over the top of the Work-DIR and use git status to see what has changed.
DIR-A -> WORK-DIR -> COMMIT WORK-DIR -> delete directories under WORK-DIR -> copy DIR-B to WORK-DIR -> use git status to see whats changed. Is there a shorter , git only method?
Upvotes: 0
Views: 41
Reputation: 43690
You can set up your directories as names remotes of each other and compare them using git diff
git remote add <name that you want to give> <absolute path to directory>
The above will add a remote path that you can then use to compare with. This won't get comparisons with uncommitted changes in the other directory. You will be able to compare with any branches that are in the other repo also. To get the latest changes, you will need to run git fetch <name that you gave to the remote>
The path needs to be an absolute path otherwise git won't be able to recognize the path as an git repository.
For example if you named the repo as 'foo':
git remote add foo /path/to/repo
git fetch foo
git diff foo/master //compare current status to master branch of other repo
Upvotes: 1