Skip to main content
deleted 393 characters in body
Source Link
Brian Webster
  • 12.1k
  • 4
  • 47
  • 59

I came across a similar problem (wanting to pull a commit that included some binary files which caused conflicts when merged), but came across a different solution that can be done entirely using git (i.e. not having to manually copy files over). I figured I'd include it here so at the very least I can remember it the next time I need it. :) The steps look like this:

% git fetch 

This fetches the latest commit(s) from the remote repository (you may need to specify a remote branch name, depending on your setup), but doesn't try to merge them. It records the SHA for the commit in .git/FETCH_HEAD

% cat .git/FETCH_HEAD b91040363160aab4b5dd46e61e42092db74b65b7 branch 'master' of ssh://blah... 

This shows me what the SHA identifier for the latest commit from the remote branch is.FETCH_HEAD

% git checkout b91040363160aab4b5dd46e61e42092db74b65b7FETCH_HEAD stuff/to/update 

This takes the copy of the binary files I want and overwrites what's in the working tree with the version fetched from the remote branch. git doesn't try to do any merging, so you just end up with an exact copy of the binary file from the remote branch. Once that's done, you can add/commit the new copy just like normal.

If anyone has improvements to suggest (particularly the middle step of getting the SHA identifier, which seems kinda hacky), feel free.

I came across a similar problem (wanting to pull a commit that included some binary files which caused conflicts when merged), but came across a different solution that can be done entirely using git (i.e. not having to manually copy files over). I figured I'd include it here so at the very least I can remember it the next time I need it. :) The steps look like this:

% git fetch 

This fetches the latest commit(s) from the remote repository (you may need to specify a remote branch name, depending on your setup), but doesn't try to merge them. It records the SHA for the commit in .git/FETCH_HEAD

% cat .git/FETCH_HEAD b91040363160aab4b5dd46e61e42092db74b65b7 branch 'master' of ssh://blah... 

This shows me what the SHA identifier for the latest commit from the remote branch is.

% git checkout b91040363160aab4b5dd46e61e42092db74b65b7 stuff/to/update 

This takes the copy of the binary files I want and overwrites what's in the working tree with the version fetched from the remote branch. git doesn't try to do any merging, so you just end up with an exact copy of the binary file from the remote branch. Once that's done, you can add/commit the new copy just like normal.

If anyone has improvements to suggest (particularly the middle step of getting the SHA identifier, which seems kinda hacky), feel free.

I came across a similar problem (wanting to pull a commit that included some binary files which caused conflicts when merged), but came across a different solution that can be done entirely using git (i.e. not having to manually copy files over). I figured I'd include it here so at the very least I can remember it the next time I need it. :) The steps look like this:

% git fetch 

This fetches the latest commit(s) from the remote repository (you may need to specify a remote branch name, depending on your setup), but doesn't try to merge them. It records the the commit in FETCH_HEAD

% git checkout FETCH_HEAD stuff/to/update 

This takes the copy of the binary files I want and overwrites what's in the working tree with the version fetched from the remote branch. git doesn't try to do any merging, so you just end up with an exact copy of the binary file from the remote branch. Once that's done, you can add/commit the new copy just like normal.

Source Link
Brian Webster
  • 12.1k
  • 4
  • 47
  • 59

I came across a similar problem (wanting to pull a commit that included some binary files which caused conflicts when merged), but came across a different solution that can be done entirely using git (i.e. not having to manually copy files over). I figured I'd include it here so at the very least I can remember it the next time I need it. :) The steps look like this:

% git fetch 

This fetches the latest commit(s) from the remote repository (you may need to specify a remote branch name, depending on your setup), but doesn't try to merge them. It records the SHA for the commit in .git/FETCH_HEAD

% cat .git/FETCH_HEAD b91040363160aab4b5dd46e61e42092db74b65b7 branch 'master' of ssh://blah... 

This shows me what the SHA identifier for the latest commit from the remote branch is.

% git checkout b91040363160aab4b5dd46e61e42092db74b65b7 stuff/to/update 

This takes the copy of the binary files I want and overwrites what's in the working tree with the version fetched from the remote branch. git doesn't try to do any merging, so you just end up with an exact copy of the binary file from the remote branch. Once that's done, you can add/commit the new copy just like normal.

If anyone has improvements to suggest (particularly the middle step of getting the SHA identifier, which seems kinda hacky), feel free.