Git refusal to enter the current branch

I installed a remote repository, and I can make new changes to it, but I cannot extract from it, I always get a (rather cryptic) error message:

fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository fatal: The remote end hung up unexpectedly 

What does it mean? What to do to enable sampling?

(Note that this remote repo is only used as a backup repo, so it should be pretty much an exact copy of my local repository. I really don’t understand why I can click on it, but not extract from it ..)

My config is as follows:

 [remote "origin"] url = ssh://blablablah fetch = +refs/*:refs/* mirror = true 
+56
git git-fetch fetch
Feb 10 2018-10-10
source share
7 answers

What you are trying to do is get the branch you are working on. That is, you are on the main branch, and you are trying to update it. It's impossible. Most often, update remotes/* branches and then paste them into your local ones. What you want maybe

 git remote add otherrepo thehost:/the/path.git 

This will install the repository in remotes/otherrepo/* . git fetch otherrepo should do the trick. Alternativeley, you can manually edit your .git/config and set the remote fetch for something like refs/heads/*:refs/remotes/otherrepo/* .

+32
Feb 10 2018-10-10
source share

In case anyone finds this because they specifically want to enter the current branch, you can use the --update-head-ok flag. From the docs :

-u
--update-head is good
By default, git fetch refuses to update the head that matches the current branch. This flag disables verification. It is purely for internal use for git pull to communicate with git fetch and , if you are not using your own porcelain, which you should not use.

In some cases, we want to implement our own porcelain teams, such as automation and tools.

+51
Oct 06 '13 at 5:17
source share

This should also work if you are in the master branch and want to get the last try.

git pull origin master

+5
Apr 13 '17 at 18:45
source share

I had this problem when I thoughtlessly cloned a repository rather than receiving it, so both repositories were masters. If you haven’t worked on a remote repository, you can fix things using the basic git commands as follows: (1) delete the remote repository, (2) copy the local repository to the place where the remote was, (3) delete the local one, and then (4) configure local repository using

 git init; git fetch $REMOTE_GIT_REPOSITORY_URL 

Then git pull and git push will do the right thing. The advantage of avoiding git remote , to Michael's more efficient and principled answer, is that you don’t need to think about the semantics of the tracking branches.

+1
Sep 14 '11 at 12:14
source share

I have the same problem. First I try to take advantage of this

 git fetch [remote_name] [branch_name] 

I had the same problem you are talking about. After that I tried this simple command.

 git pull [remote_name] [branch_name] 

Note will extract and merge changes. If you use a terminal, then the file opens, requiring a message to be committed. With this message you will push the last commit. Try this command, and finally you can click the query.

 git push [remote_name] [branch_name_local] 
0
Apr 11 '15 at 6:10
source share

Are you really typing Git commands on the command line or are you using the Git executable from your own code? If you use it from code, are you sure Git is trying to find the correct local directory?

There are two possible ways to do this:

  • Use the options provided by your programming language to set the correct working directory before executing Git
    ( C # example because this is what I use)

  • Always pass the -C option to Git to specify a directory with a local repo.




I have a project in which I call the Git executable from C # code, and I got the same error message as in the question when I accidentally forgot to set -C parameter .

0
Sep 08 '17 at 19:12
source share

Fatal: refusal to load non-empty storage into the current branch of links / headers / BRANCHNAME

I created the BRANCHNAME branch locally, then ran the command “ git fetch upstream pull / ID / head: BRANCHNAME ” and got fatal: refusing to select the current branch refs / heads / BRANCHNAME from the non-bare repository

then I deleted the branch and called the same cmd again, which is normal.

Actually, I checked the retrieval request branch.

-one
Feb 25 '19 at 12:19
source share



All Articles