Document features and changes for phase 2.5 of master/main transition (#15745)
This commit is contained in:
@@ -37,7 +37,7 @@ The best way to explain subtree merges is to show by example. We will:
|
||||
$ touch .gitignore
|
||||
$ git add .gitignore
|
||||
$ git commit -m "initial commit"
|
||||
> [master (root-commit) 3146c2a] initial commit
|
||||
> [main (root-commit) 3146c2a] initial commit
|
||||
> 0 files changed, 0 insertions(+), 0 deletions(-)
|
||||
> create mode 100644 .gitignore
|
||||
```
|
||||
@@ -55,29 +55,29 @@ The best way to explain subtree merges is to show by example. We will:
|
||||
> Receiving objects: 100% (1732/1732), 528.19 KiB | 621 KiB/s, done.
|
||||
> Resolving deltas: 100% (1086/1086), done.
|
||||
> From git://github.com/octocat/Spoon-Knife
|
||||
> * [new branch] master -> Spoon-Knife/master
|
||||
> * [new branch] main -> Spoon-Knife/main
|
||||
```
|
||||
2. Merge the `Spoon-Knife` project into the local Git project. This doesn't change any of your files locally, but it does prepare Git for the next step.
|
||||
|
||||
If you're using Git 2.9 or above:
|
||||
```shell
|
||||
$ git merge -s ours --no-commit --allow-unrelated-histories spoon-knife/master
|
||||
$ git merge -s ours --no-commit --allow-unrelated-histories spoon-knife/main
|
||||
> Automatic merge went well; stopped before committing as requested
|
||||
```
|
||||
|
||||
If you're using Git 2.8 or below:
|
||||
```shell
|
||||
$ git merge -s ours --no-commit spoon-knife/master
|
||||
$ git merge -s ours --no-commit spoon-knife/main
|
||||
> Automatic merge went well; stopped before committing as requested
|
||||
```
|
||||
3. Create a new directory called **spoon-knife**, and copy the Git history of the `Spoon-Knife` project into it.
|
||||
```shell
|
||||
$ git read-tree --prefix=spoon-knife/ -u spoon-knife/master
|
||||
$ git read-tree --prefix=spoon-knife/ -u spoon-knife/main
|
||||
```
|
||||
4. Commit the changes to keep them safe.
|
||||
```shell
|
||||
$ git commit -m "Subtree merged in spoon-knife"
|
||||
> [master fe0ca25] Subtree merged in spoon-knife
|
||||
> [main fe0ca25] Subtree merged in spoon-knife
|
||||
```
|
||||
|
||||
Although we've only added one subproject, any number of subprojects can be incorporated into a Git repository.
|
||||
@@ -99,7 +99,7 @@ $ git pull -s subtree <em>remotename</em> <em>branchname</em>
|
||||
For the example above, this would be:
|
||||
|
||||
```shell
|
||||
$ git pull -s subtree spoon-knife master
|
||||
$ git pull -s subtree spoon-knife main
|
||||
```
|
||||
|
||||
### Further reading
|
||||
|
||||
@@ -11,9 +11,9 @@ versions:
|
||||
If another person has pushed to the same branch as you, Git won't be able to push your changes:
|
||||
|
||||
```shell
|
||||
$ git push origin master
|
||||
$ git push origin main
|
||||
> To https://{% data variables.command_line.codeblock %}/<em>USERNAME</em>/<em>REPOSITORY</em>.git
|
||||
> ! [rejected] master -> master (non-fast-forward)
|
||||
> ! [rejected] main -> main (non-fast-forward)
|
||||
> error: failed to push some refs to 'https://{% data variables.command_line.codeblock %}/<em>USERNAME</em>/<em>REPOSITORY</em>.git'
|
||||
> To prevent you from losing history, non-fast-forward updates were rejected
|
||||
> Merge the remote changes (e.g. 'git pull') before pushing again. See the
|
||||
|
||||
@@ -12,7 +12,7 @@ versions:
|
||||
The `git push` command takes two arguments:
|
||||
|
||||
* A remote name, for example, `origin`
|
||||
* A branch name, for example, `master`
|
||||
* A branch name, for example, `main`
|
||||
|
||||
For example:
|
||||
|
||||
@@ -20,7 +20,7 @@ For example:
|
||||
git push <em> <REMOTENAME> <BRANCHNAME> </em>
|
||||
```
|
||||
|
||||
As an example, you usually run `git push origin master` to push your local changes
|
||||
As an example, you usually run `git push origin main` to push your local changes
|
||||
to your online repository.
|
||||
|
||||
### Renaming branches
|
||||
@@ -96,7 +96,7 @@ git fetch upstream
|
||||
> remote: Total 62 (delta 27), reused 44 (delta 9)
|
||||
> Unpacking objects: 100% (62/62), done.
|
||||
> From https://{% data variables.command_line.codeblock %}/<em>octocat</em>/<em>repo</em>
|
||||
> * [new branch] master -> upstream/master
|
||||
> * [new branch] main -> upstream/main
|
||||
```
|
||||
|
||||
When you're done making local changes, you can push your local branch to GitHub
|
||||
|
||||
@@ -33,7 +33,7 @@ If you create a new clone of the repository, you won't lose any of your Git hist
|
||||
{% endtip %}
|
||||
|
||||
{% endwindows %}
|
||||
- `BRANCH-NAME`: The default branch for your current project, for example, `master` or `gh-pages`.
|
||||
- `BRANCH-NAME`: The default branch for your current project, for example, `main` or `gh-pages`.
|
||||
```shell
|
||||
$ git filter-branch --prune-empty --subdirectory-filter <em>FOLDER-NAME BRANCH-NAME </em>
|
||||
# Filter the specified branch in your directory and remove empty commits
|
||||
|
||||
@@ -123,7 +123,7 @@ As before, Git is showing the commit message for you to edit. You can change the
|
||||
Since you've altered Git history, the usual `git push origin` **will not** work. You'll need to modify the command by "force-pushing" your latest changes:
|
||||
|
||||
```shell
|
||||
$ git push origin master --force
|
||||
$ git push origin main --force
|
||||
```
|
||||
|
||||
{% warning %}
|
||||
|
||||
Reference in New Issue
Block a user