28

I've seen people recommend that all developers set up a symlink on their machine from C:\project\.git\rr-cache to a shared folder \\server\rr-cache.

However, it would seem more convenient to share the folder by including it in the git repository itself, if that is possible. I've seen people mention this solution, but not actually how to do it.

Any ideas?

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
  • If you need to share your rerere cache with each other, you might too often push branches which are rebased. I think the standard solution to this problem is not to share the caches, but to never rebase what is visible. Then everybody can clean up their own rebase issues from their own private branches since they probably know what they are doing. – Benjamin Bannier Sep 25 '12 at 08:23
  • 1
    You cannot include the rr-cache into the repository, because it is already in it. In case you asked if it is possible to make it part of the history: yes, but it does not look like a good idea (it changes because of changing history, not because of the changing the content, which Git tracks, and you have to setup the tracked rr-cache in every new repo) – fork0 Sep 25 '12 at 08:24
  • that is true, but if you set it up via script, you're good to go. – Adam Dymitruk Sep 25 '12 at 20:52

2 Answers2

21

It can be shared via a dedicated branch. You want to stop if there is a conflict on that branch and resolve it as it means that there were attempts to solve the same conflict in 2 different ways. Needless to say, that will be the exception to the rule.

For the others on this question, google "Branch per Feature" to see where this is useful.

Hooks can automate syncing the common rr-cache branch.

Here is what you need to automate. rereresharing is an example branch that you are merging to, rr-cache is a branch that stores the resolutions; all these steps worked without issue:

git checkout --orphan rereresharing start-sprint-1 
git --git-dir=.git --work-tree=.git/rr-cache checkout -b rr-cache
git --git-dir=.git --work-tree=.git/rr-cache add -A
git --git-dir=.git --work-tree=.git/rr-cache commit -m "initial cache"
git clean -xdf
git checkout rereresharing 
git merge --no-ff FTR-1
git merge --no-ff FTR-2
vim opinion.txt # resolve conflict 
git add -A
git commit
git checkout rr-cache 
git --git-dir=.git --work-tree=.git/rr-cache add -A
git --git-dir=.git --work-tree=.git/rr-cache commit -m "resolution"
git remote add origin ../bpf-central
git push origin rereresharing rr-cache 
cd - # assumes you were previously in the other local repo
git remote add origin ../bpf-central
git fetch
git branch rr-cache origin/rr-cache 
ls .git/rr-cache
git --git-dir=.git --work-tree=.git/rr-cache checkout rr-cache -- .
ls .git/rr-cache

You are now ready to do the same merge and you will have your conflict resolved.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
  • 3
    You could create a disconnected branch for the rr-cache, i.e. `checkout --orphan rr-cache`. Looks nicer – kan Jul 06 '13 at 00:24
  • -b and --orphan are not compatible in the latest versions of git. – Byron Sommardahl Aug 19 '13 at 18:08
  • 1
    I think @kan was suggesting that you replace `-b` with `--orphan` on the 2nd line when creating the `rr-cache` branch so that `rr-cache` doesn't have any prior history. – Byron Sommardahl Aug 20 '13 at 16:23
  • Will putting this under git keep the cache from being wiped after 60 days? Can turning rerere on when changing some things and then turning it off result in only updating rerere cache for those files/directories? – Adrian Jan 02 '18 at 18:52
6

Maybe instead of sharing rr-cache another option would be to learn the conflict resolutions from the existing Git history using rerere-train.sh.

sschuberth
  • 28,386
  • 6
  • 101
  • 146