λ git checkout master
Switched to branch 'master'
λ git merge new
Auto-merging myfile.py
CONFLICT (content): Merge conflict in myfile.py
Automatic merge failed; fix conflicts and then commit the result.
Git tells you that there's a merge conflict in myfile.py. What you need to do is to open the file with conflicts and edit it. Here's what myfile.py looks like now:
import numpy as np
arr = np.arange(10)
print(arr.mean())
print(arr.std())
<<<<<<< HEAD
a = 10
=======
a = 20
>>>>>>> new
Notice Git puts the markers (<<<, ===, >>>) around the conflict area, showing two contradicting sources. You simply need to remove one version, along with all the markers. I.e. change the file to the desired final version:
import numpy as np
arr = np.arange(10)
print(arr.mean())
print(arr.std())
a = 10
Then you can treat the remaining steps as a normal file edit: simply add and commit.
λ git add myfile.py
λ git commit -m "Merging with a conflict"
[master df51349] Merging with a conflict
Now the merge is complete. The master branch is updated.
λ git log --oneline
df51349 (HEAD -> master) Merging with a conflict
9efb6e7 (new) Added variable a
349921c Added variable a
e84601c Added new file
a37231a Revert "Added another file"
35ac407 Added another file
ee7ebbd Print out the std dev
b1e55d3 Print out the mean
c96c526 First commit