Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.4k points)

Is there a shortcut to tell Git to push the current tracking branch to origin? 

Note: I know that I can change the default push behavior, but I am looking for an ad-hoc solution that does not change the default behavior.

For example, suppose I am on branch feature/123-sandbox-tests I would be using

git push origin feature/123-sandbox-tests

which is tedious. I am looking for a shortcut, something like

git push origin current

where git knows that current is feature/123-sandbox-tests.

1 Answer

0 votes
by (27.5k points)

Here is a handy way to push the current branch to the same name on the remote.

$ git push origin HEAD

 If you haven't already pushed to the origin, it is useful to use 'git push -u origin HEAD' to set upstream tracking information in the local branch

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...