简体   繁体   中英

Git tracking remote branch not working with git push?

I'm using Git Version 1.9.5

I want to understand how remote branch tracking really work.

I create a local branch to track my remote master branch:

git checkout -b feature-a origin/master

Once I ran the above command Git show me the following message "Branch feature-a set up to track remote branch master from origin. Switched to a new branch 'feature-a' "

Now I run the following command:

git pull

It seems the tracking is working, Git knows which remote branch to pull from.

Now I create a new file test.txt and commit and push.

git push 

It show me the following message:

warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Everything up-to-date

My question: Is the "git push" also work in remote branch tracking or only work with "git pull" ?

Lots of article online they state you can do "git push" with remote branch tracking.

That's a warning. Your push happened.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM