I often find file conflicts when pulling code and need to merge them manually, but I don’t want to merge and want to use other people’s latest ones directly, so I just delete the conflicting files and then pull them again, but pull them like this unsuccessful. So I manually copied the file from other places to the corresponding directory, but it still shows that it needs to be merged. What should I do now? Or how to delete the current branch?
If you have entered a conflict state, git merge --abort aborts the merge first.
If you don’t want to merge, then don’t merge (don’t use git merge or git pull). You can first git fetch to get the contents of the remote repository, and then git checkout to the remote branch (origin/master or the like).
If you want to permanently abandon your local modifications and use remote overrides, you can perform git reset --hard on the remote branch you want (such as origin/master) after fetch.
If you do not have your own commits locally and only have uncommitted modifications, you can use git checkout . && git clean -fd to discard these modifications, and then git pull to update.
Extended reading: ProGit Second Edition Chinese Version.
git stash
, 拉更新,然后git stash drop
The simpler and more crude way is to delete the whole thing and clone it again
Delete the merged file directly, then git add, then git commit, then delete git checkout otherBranch, and then delete the previous branch git branch -D needMergeBranch