Error pushing changes using git package on Atom — “The tip of your current branch is behind its remote counterpart. Try pulling before pushing.” (already tried pulling)

editor
javascript

#1

So after the wonderful support team (thanks guys!) fixed the error not letting me clone my Glitch project to my computer, I cloned it using Atom and started editing. However, when I pushed my changes a red box came down telling me I couldn’t push. I’ve already tried pulling, fetching and pruning and tons of other stuff. Any ideas?

Also here are the errors that appeared when I used git push in Terminal:

remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

MOD EDIT: formatting


#2

Hey @CarlyRaeJepsenStan, this is a factor of git’s design along with the way Glitch uses your project’s git repo. By default (unless you set the config value mentioned in the error message) you can’t push to a working repo (as opposed to a bare repo - this piece of git docs glancingly discusses the difference) on the checked-out branch. This is because when you do so you also have to go to the remote and checkout the new changes, or you won’t see them in the working code.

You have a couple of options here.

  1. you can set the receive.denyCurrentBranch flag in your git config. If you do that, when you push you need to go to your project and run git checkout master && refresh in your console. That will check out the changes you just pushed and refresh the editor to sync them.
  2. you can put your changes on another branch (say, glitch) using git checkout -b glitch locally, push that branch to your project, then go to your project’s console and use git merge glitch && refresh.

This is basically a side-effect of the fact that your project’s git repo is a working repo, whereas a typical git remote is a bare repo (it doesn’t have the actual files in it, just the list of changes to files). We plan to do some work to make these workflows easier in the future, but I don’t have a specific timeline on when we might get to that.


#3

Thanks for tips! I’ll try those.