When Git tells you it failed to push some refs
I received an unhelpful error while trying to push to a repository on Github today: git push To git
Using git, you'll sometimes find that you're not on any branch. This usually happens when you're using a submodule inside another project. Sometimes you'll make some changes to this submodule, commit them and then try to push them up to a remote repository:
Er, what? Everything is not up to date - I just made changes! The clue is in the first part of the commit response - [detached HEAD d2bdb98]. This just means that we've made a commit without actually being on any branch.
Luckily, this is easy to solve - all we need to do is checkout the branch we should have been on and merge in that commit SHA:
Once we got onto the master branch, we just called git merge with the SHA reference for the commit we just made (d2bd98), which applied our commit to the master branch. The output tells us that the commit was applied, and now we can push up to our remote repository as normal:
This had me puzzled for a while so hopefully it'll save someone banging their head against a nearby wall.
If you're exploring Git submodules, you might find Git clone vs Git submodule insightful, as it delves into managing dependencies and repository structures. Additionally, consider reading When Git tells you it failed to push some refs for a solution to the "non-fast forward" error, which is another common issue encountered when working with Git.
I received an unhelpful error while trying to push to a repository on Github today: git push To git
Having recently made the switch from svn to git, I wanted to achieve what svn externals did (and wha
Short Dev Loop & excellent automation give teams using Next.js and Vercel an advantage over teams who don't.
A few days back Praveen Ray posted about 'Traits' in Ext JS. What he described is pretty much what