Changing the Git remote 'push to' default

后端 未结 11 1925
失恋的感觉
失恋的感觉 2020-12-04 05:35

I want to change the Git default remote branch destination so I could just

git push

Instead of:

git push upstream
         


        
11条回答
  •  南笙
    南笙 (楼主)
    2020-12-04 05:52

    It might be helpful to take a look at .git/config inside your repo, it will list all remotes and also the default remote for each branch

    eg.

    [core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
    [remote "origin"]
        url = git@gitea.xxx.be:fii/web2016.git
        fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
        remote = origin
        merge = refs/heads/master
    [branch "bugfix/#8302"]
        remote = origin
        merge = "refs/heads/bugfix/#8302"
    [branch "feature/#8331"]
        remote = origin
        merge = "refs/heads/feature/#8331"
    [remote "scm"]
        url = https://scm.xxx.be/git/web2016bs.git
        fetch = +refs/heads/*:refs/remotes/scm/*
    

    you can make manual changes in this file to remove an unwanted remote, or update the default remotes for the different branches you have

    • Pay attention! when changing or removing the remotes make sure to update all references to it in this config file

提交回复
热议问题