Git merge left HEAD marks in my files
All of the answers are right but if you want to Autoremove all conflict marks & want to autochange the files to keep HEAD , then You can create your own bash script like :-
Example Script:
# vim /usr/sbin/solve.git
(Append Following)
#!/bin/bash
for f in $(grep -Rl '^>>>>>>> ' --include="*.php" --include="*.css" --include="*.js" --include="*.html" --include="*.svg" --include="*.txt" .)
do
sed -i -e '/^=======/,/^>>>>>>> /d' -e '/^<<<<<<< /d' $f
sed -i -e '/^>>>>>>> /d' $f
echo "$f Fixed"
done
git add . ; git commit -am "[+] Resolved on `date` from `hostname` by `whoami`" --no-verify
# chmod 755 /usr/sbin/solve.git
& just run it in your GIT repo/path to resolve:
$ cd <path_to_repo>
$ solve.git
Notice:- Above mentioned file extensions are php,css,js,html,svg & txt.
Absolutely start with 'git status' to see what you've got. If you aborted a merge (or had a merge aborted) and you've got conflicted files in the working directory then something went wrong. The Git status will tell you where you are. After that, you have a number of options. You should resolve the merge commit either by-hand, which can be challenging, or using a tool as:
git mergetool
The merge tool will work if your files are listed as needing a merge.
You can also perform one of:
git checkout --ours -- /path/to/conflicted-file # this is probably the one you want
git checkout --theirs -- /path/to/conflicted-file
You can see the different versions using the :1:filename syntax. See here for an explanation. But all of the above assumes that 'git status' shows the files as needing a merge.
Finally, you always have the option of:
git reset --hard # sounds like --hard is what you need but check other options
Those are conflict markers. You're still in the process of merging, but there were some parts that Git couldn't merge automatically. You'll need to hand-edit those parts to what you want them to be and then commit the results.
For instance, in your particular case, you'd probably want to resolve it like this (note - the arrows/text on the right are just my notes, not something you'd type into the file):
integer =
<<<<<<< HEAD <-+ remove the bits here
digits:[0-9]+ |
{ return digits.join(""); } |
======= <-+
sign:"-"* digits:[0-9]+
{ return sign + digits.join(""); }
>>>>>>> gh-pages <-- and this
and thus you'd save the file as...
integer =
sign:"-"* digits:[0-9]+
{ return sign + digits.join(""); }