Is it possible to run an npm script containing a git push command with the upstream option based on the current branch ?
As an example, I would like to be able to run a command npm run push
.
This command will do something like git push -u origin ${current-branch}
where $current-branch
will be replaced by the local current git branch.
I know that this is possible to achieve it by creating a script, but I would like to know if there is already something provided by npm or git to achieve this with the minimal code requirement.
Thanks for the help !
Solution:
Vlad274's solution works.
Steps:
- Add a new file
.gitconfig
on the root of your repository - Apply the configuration with
git config --local include.path ../.gitconfig
- You will be able to use a new git command which will push with the origin by using the default local branch name