Skip to content

Commit 61ca48e

Browse files
authored
Merge pull request #12076 from StelioKontosXBL/patch-4
Fix windows tip appearing in code block
2 parents 2014034 + 9111b4d commit 61ca48e

1 file changed

Lines changed: 50 additions & 41 deletions

File tree

content/get-started/using-git/splitting-a-subfolder-out-into-a-new-repository.md

Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,65 +17,74 @@ shortTitle: Splitting a subfolder
1717
If you create a new clone of the repository, you won't lose any of your Git history or changes when you split a folder into a separate repository.
1818

1919
{% data reusables.command_line.open_the_multi_os_terminal %}
20+
2021
2. Change the current working directory to the location where you want to create your new repository.
21-
3. Clone the repository that contains the subfolder.
22-
```shell
23-
$ git clone https://{% data variables.command_line.codeblock %}/<em>USERNAME</em>/<em>REPOSITORY-NAME</em>
24-
```
22+
23+
4. Clone the repository that contains the subfolder.
24+
```shell
25+
$ git clone https://{% data variables.command_line.codeblock %}/<em>USERNAME</em>/<em>REPOSITORY-NAME</em>
26+
```
27+
2528
4. Change the current working directory to your cloned repository.
26-
```shell
27-
$ cd <em>REPOSITORY-NAME</em>
28-
```
29+
```shell
30+
$ cd <em>REPOSITORY-NAME</em>
31+
```
32+
2933
5. To filter out the subfolder from the rest of the files in the repository, run [`git filter-repo`](https://github.com/newren/git-filter-repo), supplying this information:
30-
- `FOLDER-NAME`: The folder within your project where you'd like to create a separate repository.
34+
- `FOLDER-NAME`: The folder within your project where you'd like to create a separate repository.
3135

32-
{% windows %}
36+
{% windows %}
3337

34-
{% tip %}
38+
{% tip %}
3539

36-
**Tip:** Windows users should use `/` to delimit folders.
40+
**Tip:** Windows users should use `/` to delimit folders.
3741

38-
{% endtip %}
42+
{% endtip %}
3943

40-
{% endwindows %}
44+
{% endwindows %}
4145

42-
```shell
43-
$ git filter-repo --path FOLDER-NAME1/ --path FOLDER-NAME2/
44-
# Filter the specified branch in your directory and remove empty commits
45-
> Rewrite 48dc599c80e20527ed902928085e7861e6b3cbe6 (89/89)
46-
> Ref 'refs/heads/<em>BRANCH-NAME</em>' was rewritten
47-
```
48-
The repository should now only contain the files that were in your subfolder(s).
46+
```shell
47+
$ git filter-repo --path FOLDER-NAME1/ --path FOLDER-NAME2/
48+
# Filter the specified branch in your directory and remove empty commits
49+
> Rewrite 48dc599c80e20527ed902928085e7861e6b3cbe6 (89/89)
50+
> Ref 'refs/heads/<em>BRANCH-NAME</em>' was rewritten
51+
```
52+
53+
The repository should now only contain the files that were in your subfolder(s).
4954

5055
6. [Create a new repository](/articles/creating-a-new-repository/) on {% data variables.product.product_name %}.
56+
5157
7. At the top of your new repository on {% ifversion ghae %}{% data variables.product.product_name %}{% else %}{% data variables.product.product_location %}{% endif %}'s Quick Setup page, click {% octicon "clippy" aria-label="The copy to clipboard icon" %} to copy the remote repository URL.
52-
![Copy remote repository URL field](/assets/images/help/repository/copy-remote-repository-url-quick-setup.png)
58+
59+
![Copy remote repository URL field](/assets/images/help/repository/copy-remote-repository-url-quick-setup.png)
5360

54-
{% tip %}
61+
{% tip %}
5562

56-
**Tip:** For information on the difference between HTTPS and SSH URLs, see "[About remote repositories](/github/getting-started-with-github/about-remote-repositories)."
63+
**Tip:** For information on the difference between HTTPS and SSH URLs, see "[About remote repositories](/github/getting-started-with-github/about-remote-repositories)."
5764

58-
{% endtip %}
65+
{% endtip %}
5966

6067
8. Check the existing remote name for your repository. For example, `origin` or `upstream` are two common choices.
61-
```shell
62-
$ git remote -v
63-
> origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/REPOSITORY-NAME</em>.git (fetch)
64-
> origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/REPOSITORY-NAME</em>.git (push)
65-
```
68+
```shell
69+
$ git remote -v
70+
> origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/REPOSITORY-NAME</em>.git (fetch)
71+
> origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/REPOSITORY-NAME</em>.git (push)
72+
```
6673

6774
9. Set up a new remote URL for your new repository using the existing remote name and the remote repository URL you copied in step 7.
68-
```shell
69-
git remote set-url origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/NEW-REPOSITORY-NAME</em>.git
70-
```
75+
```shell
76+
git remote set-url origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/NEW-REPOSITORY-NAME</em>.git
77+
```
78+
7179
10. Verify that the remote URL has changed with your new repository name.
72-
```shell
73-
$ git remote -v
74-
# Verify new remote URL
75-
> origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/NEW-REPOSITORY-NAME</em>.git (fetch)
76-
> origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/NEW-REPOSITORY-NAME</em>.git (push)
77-
```
80+
```shell
81+
$ git remote -v
82+
# Verify new remote URL
83+
> origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/NEW-REPOSITORY-NAME</em>.git (fetch)
84+
> origin https://{% data variables.command_line.codeblock %}/<em>USERNAME/NEW-REPOSITORY-NAME</em>.git (push)
85+
```
86+
7887
11. Push your changes to the new repository on {% data variables.product.product_name %}.
79-
```shell
80-
git push -u origin <em>BRANCH-NAME</em>
81-
```
88+
```shell
89+
git push -u origin <em>BRANCH-NAME</em>
90+
```

0 commit comments

Comments
 (0)