Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the advanced usage of git checkout in Git conflicts

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

What is the advanced usage of git checkout in Git conflict? many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

Background

Git conflicts are usually caused by modifying the same file, which may be submitted to a remote warehouse or by the need to merge the file.

Solution method

Are you sure which warehouse file you need?

Git checkout-- theirs conflicted_file.txt # keeps the remote

Git checkout-- ours conflicted_file.txt # keeps the local

Then execute add and commit

Git add-A

Git commit-m "update conflict

Take a chestnut.

Get the files on the remote server, prompting a conflict that needs to be merged

# git cherry-pick FETCH_HEAD

* branch refs/changes/85/12385/3-> FETCH_HEAD

Error: 'cherry-pick' is not possible because you have unmerged files.

Hint: Fix them up in the work tree

Hint: and then use 'git add/rm' as

Hint: appropriate to mark resolution and make a commit

Hint: or use 'git commit-aura.

Fatal: cherry-pick failed

View the status of the current warehouse

# git status

Not currently on any branch.

You are currently cherry-picking commit 53e5374.

(fix conflicts and run "git cherry-pick-- continue")

(use "git cherry-pick-abort" to cancel the cherry-pick operation)

Unmerged paths:

(use "git add..." To mark resolution)

Both modified: file1.txt

Execute with the prompted command

# git cherry-pick-continue

U file1.txt

Error: 'commit' is not possible because you have unmerged files.

Hint: Fix them up in the work tree

Hint: and then use 'git add/rm' as

Hint: appropriate to mark resolution and make a commit

Hint: or use 'git commit-aura.

Fatal: Exiting because of an unresolved conflict.

Prompt that file1.txt has an update and make sure to replace the file with the remote warehouse. Theirs is used here

Git checkout-theirs file1.txt

Then add it to the local warehouse

Git add-A

Finally, continue cherry-pick "copy"

# git cherry-pick-continue

[detached HEAD 8f26ce8] Summary: test git checkout-theirs

Author: Rik

2 files changed, 0 insertions (+), 0 deletions (-)

Summary

There is a difference between git ckeckout and-- ours and-- theirs with parameters.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report