arcyqwerty
arcyqwerty

Reputation: 10685

git push.default include current new branch

Suppose I just created a local branch b. When I do git push it pushes changes from other branches according to matching (git 1.x default):

push all branches having the same name on both ends. This makes the repository you are pushing to remember the set of branches that will be pushed out (e.g. if you always push maint and master there and no other branches, the repository you push to will have these two branches, and your local maint and master will be pushed there).

However, if the current branch doesn't exist on the remote yet, it will not push the current branch. git push --all seems to do this. Is there a way to make this behavior default for git push? Are there any bad side-effects to aliasing push=push --all?

Edit: actually I only want it to push matching + current branch (including new), excluding other new branches

Upvotes: 1

Views: 77

Answers (1)

Stefan Ferstl
Stefan Ferstl

Reputation: 5265

You could do that by

git config --add remote.origin.push 'refs/heads/*:refs/heads/*'

See also: https://stackoverflow.com/a/5239626/1497059

Update:

If you only want to push the current new branch, you can use the push.default=current setting:

git config --add push.default current

Upvotes: 1

Related Questions