After cloning from remote git repository (at bettercodes) I made some changes, commited and tried to push:
git push origin master
Errors
You want to try doing:
git gc --prune=now
See https://www.kernel.org/pub/software/scm/git/docs/git-gc.html
In my case after getting this message I did the checkout command and was given this message:
Your branch is based on 'origin/myBranch', but the upstream is gone.
(use "git branch --unset-upstream" to fixup)
After running this command I was back to normal.
In my case a branch was moved to a subdirectory and the directory was called as the branch. Git was confused by that. When I deleted the local branch (in SourceTree just with right click delete) everything worked as usual.
I saw this error when trying to run git filter-branch
to detach many subdirectories into a new, separate repository (as in this answer).
I tried all of the above solutions and none of them worked. Eventually, I decided I didn't need to preserve my tags all that badly in the new branch and just ran:
git remote remove origin
git tag | xargs git tag -d
git gc --prune=now
git filter-branch --index-filter 'git rm --cached -qr --ignore-unmatch -- . && git reset -q $GIT_COMMIT -- apps/AAA/ libs/xxx' --prune-empty -- --all
for me, removing .git/info/ref
kick things going.There shouldn't be a ref
file when git is not running. But in my case there were one for whatever reason and caused the problem.
Removing the file will not remove any of your local commits or branches.
In my case, it was connected with the branch name that I had already created.
To fix the issue I've created a branch with the name that for certain shouldn't exist, like:
git checkout -b some_unknown_branch
Then I've cleared all my other branches(not active) because they were just unnecessary garbage.
git branch | grep -v \* | grep -v master | xargs git branch -D
and then renamed my current branch with the name that I've intended, like:
git checkout -m my_desired_branch_name