@@ -27,34 +27,21 @@ git remote add java-repo-tools
[email protected] :GoogleCloudPlatform/java-repo-tool
27
27
git fetch java-repo-tools master
28
28
```
29
29
30
- To make it easier to push changes back upstream, create a new branch.
31
-
32
- ```
33
- git checkout -b java-repo-tools java-repo-tools/master
34
- ```
35
-
36
30
We can then go back to the ` my-java-samples ` code and prepare a Pull Request to
37
- add the ` java-repo-tools ` code in a subtree.
38
-
39
- ```
40
- git checkout master
41
- # Making a new branch ia optional, but recommended to send a pull request to
42
- # start using java-repo-tools.
43
- git checkout -b use-java-repo-tools
44
- ```
45
-
46
- So that we can pull future updates from the ` java-repo-tools ` repository, we
47
- merge histories. This way we won't get unnecessary conflicts when pulling changes
48
- in.
31
+ add the ` java-repo-tools ` code in a subtree. Making a new branch is optional, but
32
+ recommended so that you can more easily send a pull request to start using
33
+ ` java-repo-tools ` .
49
34
50
35
```
51
- git merge -s ours --no-commit java-repo-tools/master
36
+ git checkout -b use- java-repo-tools origin /master
52
37
```
53
38
54
- Finally, read the ` java-repo-tools ` into a subtree.
39
+ Finally, read the ` java-repo-tools ` into a subtree. So that you can pull future
40
+ updates from the ` java-repo-tools ` repository, this command will merge histories.
41
+ This way prevents unnecessary conflicts when pulling changes in.
55
42
56
43
```
57
- git read-tree --prefix=java-repo-tools/ -u java-repo-tools
44
+ git subtree add --prefix=java-repo-tools java-repo-tools master
58
45
```
59
46
60
47
Now all the content of ` java-repo-tools ` will be in the ` java-repo-tools/ `
@@ -143,22 +130,14 @@ Pull Request as you would in the normal flow.
143
130
What if you make changes in your repository and now want to push them upstream?
144
131
145
132
Assuming you just commited changes in the ` java-repo-tools/ ` directory of your
146
- ` my-main-branch ` , to merge the changes into the local ` java-repo-tools ` branch,
147
- we need to cherry pick this commit using the subtree strategy. It will ignore
148
- any changes to file not in the ` java-repo-tools/ ` directory.
149
-
150
- ```
151
- git checkout java-repo-tools
152
- git cherry-pick -x --strategy=subtree my-main-branch
153
- ```
154
-
155
- After you have committed all the changes you want to your ` java-repo-tools `
156
- branch, you can push to the upstream ` java-repo-tools ` repository with the
157
- following command. (Replace ` name-for-remote-branch ` with the name you'd like to
158
- give the branch on the ` java-repo-tools ` repository.)
133
+ ` my-main-branch ` , to split the ` java-repo-tools ` changes into their own branch.
134
+ The first time using the ` subtree ` command, we may need to use the ` --rejoin `
135
+ argument.
159
136
160
137
```
161
- git push java-repo-tools java-repo-tools:name-for-remote-branch
138
+ git subtree split --prefix=java-repo-tools -b ${USER}-push-java-repo-tools
139
+ git checkout ${USER}-push-java-repo-tools
140
+ git push java-repo-tools ${USER}-push-java-repo-tools
162
141
```
163
142
164
143
Then, you can send a pull request to the ` java-repo-tools ` repository.
0 commit comments