No refs in common and none specified; doing nothing

77,982

Solution 1

No "main" exists yet on the remote (origin) repository.

git push origin main

After this first push you can use the simpler

git push

Edit: With the recent trends my answer has been update to replace "master" with "main"

Solution 2

If you are receiving error:

No refs in common and none specified; doing nothing.
Perhaps you should specify a branch.

But not receiving error:

warning: push.default is unset

Make sure you have run git commit before attempting to run git push

Share:
77,982
Noah
Author by

Noah

Updated on December 21, 2021

Comments

  • Noah
    Noah over 2 years

    I had a local git project that I wanted to add to gitolite. Apparently this is hard so I abandoned the idea. I created a new gitolite repo by adding it to gitolite-admin/conf/gitolite.conf and committing and pushing the changes. Then I cloned the new repo with git clone git-noah:project-name successfully. I then copied all files and folders except .git to the project-name folder. I did,

    git add -A
    git commit -a -m "Moved to new repo."
    git push
    

    I get this error:

    warning: push.default is unset; its implicit value is changing in
    Git 2.0 from 'matching' to 'simple'. To squelch this message
    and maintain the current behavior after the default changes, use:
    
      git config --global push.default matching
    
    To squelch this message and adopt the new behavior now, use:
    
      git config --global push.default simple
    
    See 'git help config' and search for 'push.default' for further information.
    (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
    'current' instead of 'simple' if you sometimes use older versions of Git)
    
    No refs in common and none specified; doing nothing.
    Perhaps you should specify a branch such as 'master'.
    fatal: The remote end hung up unexpectedly
    error: failed to push some refs to 'git-noah:project-name'
    
  • Oliver
    Oliver almost 10 years
    They absolutely do share history! That is one of the most awesome things about git, it knows everything that happened in the remote repo because you cloned the whole thing.
  • Oliver
    Oliver almost 4 years
    @Enrico check the branch names you are pushing. With the recent trends the term "master" is being changed .
  • Tanzeel
    Tanzeel over 3 years
    @Oliver, yes you're right. Some prefer "master" as "main".
  • Oliver
    Oliver over 3 years
    @Tanzeel yes in 2020 "main" would probably the more appropriate choice. My original answer was written in 2014 predating the new branch naming discussions.
  • stackers
    stackers over 3 years
    Weird, main didn't work and gave me the refspec error... I had to change it to master. This is on a fresh github repo.