Programing

Git은 내 파일에서 왼쪽 HEAD 표시를 병합합니다.

lottogame 2020. 9. 14. 21:36
반응형

Git은 내 파일에서 왼쪽 HEAD 표시를 병합합니다.


Git을 사용하여 명령 줄에서 파일을 병합하려고했는데 병합이 중단되었다는 오류 메시지가 나타납니다.

그게 끝이라고 생각했지만 내 파일에 gitmark가 있다는 것을 깨달았습니다. 이렇게 :

start =
    expression

validchar = 
    [0-9a-zA-Z_?!+\-=@#$%^&*/.]

integer = 
<<<<<<< HEAD
    digits:[0-9]+
        { return digits.join(""); }
=======
    sign:"-"* digits:[0-9]+
        { return sign + digits.join(""); }
>>>>>>> gh-pages

파일은 내가 편집하지 않았으며 다음과 같이 삽입 된 줄을 표시합니다.

  • 미만 기호 ( <<<<<<< HEAD) 뒤의 HEAD
  • 변경된 코드 줄
  • 등호 문자열 ( =======)
  • 새 버전의 코드
  • 보다 큼 기호와 분기 이름 ( >>>>>>> gh-pages)으로 시작하는 다른 줄

더 나쁜 것은 파일 내용이 더 이상 순서가 없다는 것입니다. 누구든지 파일을 정상으로 되 돌리는 방법과 gh-branch에서 변경 한 내용이 master 브랜치에 병합되는 방법을 알고 있습니까?


그것들은 갈등 마커 입니다. 여전히 병합하는 중이지만 Git이 자동으로 병합 할 수없는 부분이있었습니다. 당신은 것입니다 손으로 편집에 그 부분이 필요 당신이 그들이 원하는 무엇을하고 결과를 커밋합니다.


예를 들어, 특정 경우에 다음과 같이 해결하고 싶을 것입니다 (참고-오른쪽의 화살표 / 텍스트는 파일에 입력 할 내용이 아니라 내 메모 일뿐입니다).

integer = 
<<<<<<< HEAD                                  <-+ remove the bits here
    digits:[0-9]+                               |
        { return digits.join(""); }             |
=======                                       <-+
    sign:"-"* digits:[0-9]+
        { return sign + digits.join(""); }
>>>>>>> gh-pages                              <-- and this

따라서 파일을 다음과 같이 저장합니다.

integer = 
    sign:"-"* digits:[0-9]+
        { return sign + digits.join(""); }

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

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.


In Atom i had the issue that some files did not save the resolved merge conflicts to the drive, so i had to manually click "save". Took me quite some time to figure out.


I'm coming from this question. And I wanted some automated method of merging the half merged files, instead of manually editing the files (as suggested in other answers, which I am not really comfortable doing). So here's what I ended up doing via netbeans, but can be done via command line too.

Now, bear in mind, this only works if immediately after the merge->add->commit, you realised that you messed up, and want to re-go through the process.

STEP 1: Reset to a previous commit.

git reset --hard a992a93f9312c6fa07c3a1b471c85e9fbf767d0e

STEP 2: Re-Try Merging the branch

git merge --ff origin/feature/YOUR-Branch_here

At this point you shall be prompted with the merging window if you are using a GUI. and you can then proceed as normal.

참고URL : https://stackoverflow.com/questions/10657315/git-merge-left-head-marks-in-my-files

반응형