Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git config settings to automatically create remote branch with same name

Tags:

git

git-config

I used to have my git set up very nicely where it would automatically push to the remote branch with the same name when I ran git push, and automatically pull when running git pull.

I tried to show a friend how to do this and in the process managed to break my own config. How can I get back to the functionality I'm looking for? I've tried a bunch of configs, but each has its problems.

I currently have this in ~/.gitconfig:

[push]
    default = current
[branch]
    autoSetupMerge = always

But when I create a new branch locally, then commit and push, it says "Everything up-to-date". If I then run git push origin <branch_name> it does push the changes.

These settings don't seem to do the trick either:

[push]
    default = matching
[branch]
    autoSetupMerge = always
like image 273
Eliezer Steinbock Avatar asked Jan 26 '23 02:01

Eliezer Steinbock


1 Answers

You can use following command to instruct git to by default create remote branch with same name (I have used global level, you can decide level based on your requirement:

git config --global push.default current

source

you can use -u option for first time push for new branch, it will help in tracking of new branch and will help while pulling changes. If you did not use -u for first time push, you can use it for later push also. Basically, tracking will start after a push with -u option.

git push -u

without specifying origin and branch name for new branch and push changes.

like image 83
Rajni Kewlani Avatar answered Jan 29 '23 10:01

Rajni Kewlani