質問

I have a master and want to have several "outputs" How do I accomplish this. I've no clue if this is possible with Git.

Please have a look at this example git project:

Master

  • phpfiles.php
  • config.php
  • plugins
    • a.php
    • b.php
    • c.php

Branch A

  • phpfiles.php
  • config.php -> is different then the Master
  • plugins
    • a.php

Branch B

  • subfolder1
  • subfolder2*
    • phpfiles.php
    • config.php -> is different then the Master
    • plugins
      • c.php

Please note that subfolder2* contains "Master" with additions...

When I change something in phpfiles.php in the Master For instance on my local machine I go to Master/phpfiles.php make a change then apply these commands in terminal:

git status (optional)

git checkout master (optional?)

git add . -A

git commit -m "Made a change"

git push

For Branch A: I go into that folder on the webserver and or local machine:

git checkout Branch A

git pull origin master

--

For Branch B: I go into that folder on the webserver and or local machine:

git checkout Branch B

git pull origin master

Is this the correct workaround to accomplish this? Any help is much appreciated!

--

My steps are:

I've done this, from scratch, created new folder:

git init

git remote add origin https://**@bitbucket.org/*/*.git

git fetch && git checkout BranchB

git merge --strategy=ours origin/master

->I get: Already up-to-date.

ls

->I get:

  • subfolder1

  • subfolder2

I'll then try to "get" the changed file manually from master which needs to go in subfolder2 so:

git checkout origin/master -- changed.php

ls

-> I get:

-subfolder1

-subfolder2

-changed.php

役に立ちましたか?

解決

If branchA and branchB can be constructed by recipe from master, what you have is multiple makefile targets, not multiple branches. If make is too heavyweight, the branch-specific includes in this answer might serve. Remember that branch names are entirely local, per-repo entities. With that setup you can use checkout as a poor-man's-make, with e.g. checkout -B config-set-A to reconfigure your current working directory with the new config set.

他のヒント

You don't have to push/pull to propagate a change from one branch (master) to other branches (branchA, branchB).
You can use local git operations only. No need to use an upstream remote repo.

You can either:

That way, the second merge will only include the commit you just did in master instead of trying to add everything from master.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top