Skip to content

Instantly share code, notes, and snippets.

@ArjunRayGA
Last active December 8, 2017 04:23
Show Gist options
  • Select an option

  • Save ArjunRayGA/428328884e102f5bbf54e8b782195c2a to your computer and use it in GitHub Desktop.

Select an option

Save ArjunRayGA/428328884e102f5bbf54e8b782195c2a to your computer and use it in GitHub Desktop.
how to tell git pull/merge to automatically keep local or remote versions of files on merge conflicts

A method for using git to pull changes from our master repo without merge conflicts

example below is for Jupyter Notebooks but it works for any type of file. Use "theirs" keyword instead of "ours" if you want to keep remote version of file on merge conflict

  1. You must first navigate to the root directory of your local repo copy in your terminal

  2. if git remote -v doesn’t show remotes with an address https://github.com/ga-students/DS-BOS-19.git, run

git remote add dat-origin https://github.com/ga-students/DS-BOS-19.git

Otherwise, note the remote name that has the https://github.com/ga-students/DS-BOS-19.git address

  1. run the following to tell git pull/git merge to keep local versions of our lesson Jupyter Notebook files, even if they are out of sync with the copies kept in the main repo
echo 'lessons/**/*.ipynb merge=ours' > .git/info/attributes
git config merge.ours.driver true
  1. You should be able to run
git pull <dat-origin / whatever your remote name was from step 2> master

and pull down changes from the master repo without getting merge conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment