Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Some wrong solutions to Git

Shulou Source: shulou.com Published: 2022-06-03 05:21:46 10月03日 Update

Note: the personal experience records of Git beginners are for reference only.

1. Pull is not possible because you have unmerged files.

Symptoms: during pull

$git pull

Pull is not possible because you have unmerged files.

Please, fix them up in the work tree, and then use 'git add/rm'

As appropriate to mark resolution, or use 'git commit-a'

I think it's because the local file conflicts.

Solution:

Quote--

"

1.pull will use git merge to cause conflicts. You need to resolve the conflicting file git add-u before git commit can successfully pull.

two。 If you want to discard local file changes, you can use git reset-- hard FETCH_HEAD,FETCH_HEAD to represent the commit point formed after the last successful git pull. Then git pull.

Note:

Git merge forms MERGE-HEAD (FETCH-HEAD). Git push forms a reference like HEAD. HEAD represents a local reference formed after a recent successful push.

"

In my experience, sometimes this happens inexplicably, and there are still a lot of Untracked files (in fact, I may only change one or two files), so I have to save the changes made by myself first, then use git reset-hard FETCH_HEAD to go back to the point after the last successful pull, and then pull will be no problem.

2.You are not currently on a branch.

Symptoms: once there was a conflict during pull, and this time the "git reset-hard FETCH_HEAD" method failed, and appeared:

$git pullYou are not currently on a branch, so I cannot use any'branch..merge' in your configuration file.Please specify which remote branch you want to use on the commandline and try again (e.g. 'git pull'). See git-pull (1) for details.

Solution:

First, git checkout-b temp

Secondly, git checkout master

You can return to the state of master repository, and then you can pull

Reference:

Http://skywhsq1987.iteye.com/blog/1814137

Http://slacy.com/blog/2011/04/git-pull-says-you-are-not-currently-on-a-branch/

Http://ddmytrenko.blogspot.com/2012/03/git-not-currently-on-any-branch.html

Tags: Success documentation conflict method time symptoms experience no inexplicable for reference only two individuals representatives beginners actually in fact sometimes conditions states problems Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info Linux Shulou Information Docker