Question

We've recently adopted our own branch system with Git, but one thing we've been getting frustrated with recently is when trying to commit a change to remote whilst on one branch, Git stops the commit because a different branch is behind its remote counterpart. Therefore, we then have to checkout to each branch that has changed and do a pull first before going back to our original branch to make a commit.

Is there a setting that can prevent Git from stopping commits because of other branches. Is there a certain approach we can take that can prevent the need to have to switch branches?

Was it helpful?

Solution

Try:

git config --global push.default current

It should avoid the kind of error message mentioned here

error: failed to push some refs to 'git@github.com:jkubicek/my_proj.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. If you did not intend to push that branch, you may want to
hint: specify branches to push or set the 'push.default' configuration
hint: variable to 'current' or 'upstream' to push only the current branch
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top