0

When I have a repository with the following settings:

  • branch dev with fetch/push remote (A)
  • branch master with fetch/push remote (B)

and I push branch dev to (A), will git send to the server only changes applied to this branch or is there a risk that other changes will get there too?

In other words: is git strict about branches when pushing changes to the server?


Background: remote (B) contains internal code modifications that I don't want to notify the other remote about.

1
  • 3
    Git pushes commits, not changes. Commits are snapshots, independent of each other. The set of commits that gets sent is under your control: you generally request that your Git send the tips of various branches, which drags with them all the commits leading to those tips. RomainValeri's answer is correct, with the caveat that you're pushing commits (whole chains of them), not changes. Commented Jun 26, 2019 at 9:43

1 Answer 1

2

When you do a git push without giving a specific branch to push

It depends on the push.default setting entry in your config. (doc)

In short, a push would push all branches to their counterparts ONLY if push.default was set to 'matching', which is not the default value any more since Git 2.0.


And when you specify the branch to push

You're sure to push only it.

Sign up to request clarification or add additional context in comments.

1 Comment

Also, if you're unsure about the result of a push but you need to be sure : use --dry-run for your push and see what would have happened without impacting anything.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.