i want to have the following git workflow,
github
/ \
laptop-----desktop
The idea is that desktop is kept in sync with laptop, and pushing to github happens whenever, from either computer.
Since my laptop is not permantly online, i need a way to pull and push to desktop from laptop. On laptop, i cloned the github repo, and then made a remote for desktop. I then set up a tracking branch (on laptop) to track the branch ‘develop’ on desktop.
> git branch --track develop desktop/develop
I make changes to branch ‘develop’ on laptop, commit, and try to push to desktop i get.
>git push desktop
...
remote: error: refusing to update checked out branch: refs/heads/develop
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 som
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ssh:// ....
! [remote rejected] develop -> develop (branch is currently checked out)
i read a bit about the error and it sounds like the recomended thing to do is to pull from desktop, instead of push from the laptop, but this is not an option.
git says you right what you have to do: You can set
receive.denyCurrentBranchconfiguration variable to ‘ignore’ or ‘warn’ in the remote repository to allow pushing intoits current branch.