1

I did some work in an Excel spreadsheet. My colleague did different work at the same time and pushed his changes first. Obviously git will not allow me to push, and git merge doesn't seem to work on binary files (and I wouldn't trust it if it did).

The solution I have in mind is to just copy the local repo to a new folder, overwrite the local repo with the remote version, merge in my work by hand, then commit/push and delete the temporary new folder. Is there a better or git-based way to do this? I was looking at git stash but I wasn't sure.

I haven't found any guidance in previous questions despite very thorough answers, e.g. - this one

edit: am I overthinking it? can I just use git fetch then somehow access what I've fetched without mergeing?

Community
  • 1
  • 1
shadowtalker
  • 12,529
  • 3
  • 53
  • 96

1 Answers1

0

You can do this manually by letting git know which files you want to be present. After merging, look at the merge conflicts and identify which versions of those files you want.

If you want the file present in the remote -

git checkout --theirs -- path/to/conflicted-file.txt

If you want to override the file with the version of your branch -

git checkout --ours -- path/to/conflicted-file.txt
gravetii
  • 9,273
  • 9
  • 56
  • 75
  • I'm not sure what you mean by "present." If I do `git checkout --ours spreadsheets/spreadsheet_1.xlsx`, it seems like this will download the remote copy to my local repo and change HEAD to the downloaded version, but without deleting my local version. Great, but how can I then access my local version to make changes _manually_, i.e. by opening both files and physically making edits? And then what's the "correct" way to commit and push these changes? – shadowtalker Jul 21 '14 at 14:27