The problem I’ve had is that my fingers automatically type git push origin master. If I instead am working on new-branch and was meaning to type git push origin new-branch and there are unpushed changes on master they will be pushed accidentally. Is there some way to prevent this so that I can only push to and from the current branch?
The problem I’ve had is that my fingers automatically type git push origin master
Share
You can just create an alias named, say,
gitpushcurrent, pointing togit push origin $(git branch | grep "*" | sed "s/* //").Then retrain your fingers to type automatically
gitpushcurrentinstead ofgit push origin master. Thus you don’t need to think what is the current branch.