-1

I am trying to edit my .gitconfig to add a shortcut that takes into account my current branch and pushes it, even if there is no upstream defined yet. To reference my current branch I would normally do:

git symbolic-ref --short HEAD

My problem is that this solution can't be used for shortcuts.

What I want to do is push the current branch and set its upstream branch. Currently I do:

git push -u origin <my-current-branch>

And I wanted to make a shortcut like:

git pu

How can I add the reference to the current branch in my .gitconfig ?

NOTE: The can be any branch I am working

Tiagojdferreira
  • 1,122
  • 2
  • 14
  • 20
  • possible duplicate of [Default behavior of "git push" without a branch specified](http://stackoverflow.com/questions/948354/default-behavior-of-git-push-without-a-branch-specified) – Igor Milla Aug 07 '15 at 08:29
  • Check this SO answer: http://stackoverflow.com/questions/14753603/shortcuts-for-git-commands – Tomislav Aug 07 '15 at 08:29
  • 1
    My problem is not creating a shortcut. My problem is referencing the current branch. – Tiagojdferreira Aug 07 '15 at 09:10

1 Answers1

3

This is all you need:

git config --global alias.pu 'push -u origin HEAD'