A
A
Artem Prokhorov2021-05-09 11:58:05
git
Artem Prokhorov, 2021-05-09 11:58:05

How to push files to a non-default branch without copying files from the master branch?

There is a master and sub branch.

In the master, there is a pure framework in which all the changes from the sub will then be pushed.
I switch to sub and write some code and now I want to add files with changed code 1.php and 2 .php.
But why after
git push --set-upstream origin sub
me throws these 2 modified files (or created from scratch) and all clean files from the master branch into the sub branch? I only need 1.php and 2.php.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2021-05-09
@kotcich

No way. This is how git works. You created a branch based on the master and therefore it contains the source files and your changes, since the original commit is shared with the master, the branches have a common history. This is what will allow you to merge back into the master without any problems.
PS Well, not really. If you really want to, you can create a branch with two files, but then you won’t be able to merge it into the master. With such an attempt, there will be conflicts at first, and when you try to continue the merge, your 2 files will remain in the master.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question