Reputation: 1591
I've below alias in my gitconfig:
# Get the current branch name
current-branch = !git rev-parse --abbrev-ref HEAD
# Push the current branch to the remote "origin", and set it to track the upstream branch
publish = "!git push -u origin $(git current-branch)"
My question is can I use "git publish" command to push changes all the time? Since -u option with push is used for creating remote repo for the first time when it does not exist on remote, is it ok to use this option all the time when I push changes multiple times?
Upvotes: 0
Views: 55
Reputation: 141622
If the remote branch is already named after the local branch, setting the upstream on push will be redundant, and that will be okay.
If you then rename the local branch, setting the upstream on push will create a new remote branch. If that is not what you want, you will need to remember to delete the old remote branch.
The latter case would look something like this:
git branch -m the-old-branch-name the-new-branch-name
git publish
git push --delete origin the-old-branch-name
Upvotes: 1