Git push does not push a new branch

I checked out a new branch from our repo. Everything works great for our industry. But in the new branch "push" does nothing.

Everything looks fine - there are 2 fixations to push.

-> git branch -vv develop 8ab7ef1 [origin/develop] Merge branch 'develop' of git.example.com:core-platform into develop * hotfix112 8521cef [origin/hotfix/1.1.2: ahead 2] CORE-1263 - Completed merging from dev into hot fix. 

But Push does nothing:

 -> git push Everything up-to-date -> git status # On branch hotfix112 # Your branch is ahead of 'origin/hotfix/1.1.2' by 2 commits. # (use "git push" to publish your local commits) # nothing to commit, working directory clean 

I found that "git pull" uses remote, but "git push" does not:

 -> git remote show origin * remote origin Fetch URL: git@git.example.com :core-platform.git Push URL: git@git.example.com :core-platform.git HEAD branch: develop Remote branches: core-platform-1.0.0 tracked develop tracked hotfix/1.1.2 tracked master tracked release/1.0.0 tracked release/1.1.1 tracked Local branches configured for 'git pull': develop merges with remote develop hotfix112 merges with remote hotfix/1.1.2 Local ref configured for 'git push': develop pushes to develop (up to date) -> 

I cannot understand why hotfix112 is not tied to a remote device, but pull.

How to fix this configuration?

+4
source share
3 answers

Git acts as you described, because you have the following situation:

  • You have a local branch (hotfix112) that tracks the remote branch with different names.
  • do you have push.default option for matching (default) or simple

As usual with git, you have several alternatives on how to configure git to act as desired:

1.) The easiest way would be to change the name of your local branch to match the name of the remote branch. After that, pressing starts to work automatically. So just rename the "hotfix112" branches to "hotfix / 1.1.2":

 git branch -m hotfix112 hotfix/1.1.2 

2.) You can change the behavior of the push by setting the push.default option to "track". Since you already have a "hotfix112" branch, to track the source code / patch / 1.1.2, pressing the git button will work as desired. To set the local git option:

 git config --local push.default tracking 

3.) You can manually edit the .git / config file and set push to match the local refspec 'hotfix112' to the remote 'fix / 1.1.2'. You must add a push line below the [remote "origin"] section:

 [remote "origin"] url = ... fetch = ... push = hotfix112:hotfix/1.1.2 

The first and third approaches work only in the hotfix112 branch. The second one works for all tracking branches in this repository (or globally if the global option is used).

+2
source

Try git push origin / hotfix / 1.1.2 (remote branch) hotfix112 (local branch), perhaps by clicking on the remote server, it will create a link. Strange though it wasn't when you branched.

0
source

The current behavior of git push (without any additional parameters) is to push all branches with the same name in the local and remote repository. Since the name of your local branch is different from the name of your remote branch, if you change them to match, git push should push your changes. Keep in mind that this behavior will change in a future version of git (possibly 2.0). See: http://article.gmane.org/gmane.comp.version-control.git/193308 . If you want to change the behavior of git push right now, enter git help config and search for "push.default".

0
source

Source: https://habr.com/ru/post/1496859/


All Articles