You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contribute-open-source/clone-repo.md
+19-21Lines changed: 19 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,82 +17,80 @@ myst_html_meta:
17
17
---
18
18
19
19
(clone-repository)=
20
-
# Clone a GitHub Repository to Work Locally
21
-
How to clone a repo.
20
+
21
+
# Clone a GitHub Repository to Work Locally
22
+
23
+
How to clone a repo.
22
24
23
25
## Clone a repo: copy files From GitHub.com to your computer
24
26
25
27
To work locally with a **GitHub** repository (including forked repos), you must create a local copy of that repository on your computer (a task referred to as `cloning` a repo). You can clone **GitHub** repositories that you own or that are owned by others (e.g., repositories that you have forked to your **GitHub** account).
26
28
27
-
In either case, cloning allows you to create a local copy of a **GitHub** repository to work with the files locally on your computer. Cloning a repository to your computer is a great way to work on your files locally while still having a copy of your files on the cloud on **GitHub.com**. Following the steps below, you will use the `git clone` command in the **terminal** to clone **GitHub** repositories.
28
-
29
+
In either case, cloning allows you to create a local copy of a **GitHub** repository to work with the files locally on your computer. Cloning a repository to your computer is a great way to work on your files locally while still having a copy of your files on the cloud on **GitHub.com**. Following the steps below, you will use the `git clone` command in the **terminal** to clone **GitHub** repositories.
29
30
30
31
### Use `Bash` to Change to Your Desired Working Directory
31
32
32
33
The first step to using any **git** command is changing the current working directory to your desired one.
33
-
In the case of `git clone`, the current working directory needs to be where you want to download a local copy of a **GitHub** repository.
34
-
35
-
For this lesson, you will clone a repo locally on your computer (or wherever you work).
34
+
In the case of `git clone`, the current working directory needs to be where you want to download a local copy of a **GitHub** repository.
36
35
36
+
For this lesson, you will clone a repo locally on your computer (or wherever you work).
37
37
38
38
### Copy a Github.com Repository URL From GitHub.com
39
39
40
-
To run the `git clone` command, you need the URL for the repository you want to clone (i.e., either a repository owned by you or a fork you created from another user's repository).
40
+
To run the `git clone` command, you need the URL for the repository you want to clone (i.e., either a repository owned by you or a fork you created from another user's repository).
41
41
42
-
On the main **GitHub.com** page of the repository, you can click on the green button for `Clone or download`, and copy the URL provided in the box, which will look like this:
42
+
On the main **GitHub.com** page of the repository, you can click on the green button for `Clone or download`, and copy the URL provided in the box, which will look like this:
43
43
44
44
`https://github.com/your-username/repo-name`
45
45
46
46
::::{todo}
47
47
:::{figure} /images/github/image-coming-soon.png
48
48
:alt: alt text here
49
49
50
-
You can make a local copy of your forked repository on your computer with the git clone command.
50
+
You can make a local copy of your forked repository on your computer with the git clone command.
51
51
:::
52
52
::::
53
53
54
-
:::{tip}
55
-
You can copy the URL directly from your web browser, or in some cases, you might already know the URL. However, in many cases, you will come across a new **GitHub.com** repository on your own and will need to follow these instructions to copy the URL for future use.
54
+
:::{tip}
55
+
You can copy the URL directly from your web browser, or in some cases, you might already know the URL. However, in many cases, you will come across a new **GitHub.com** repository on your own and will need to follow these instructions to copy the URL for future use.
56
56
:::
57
57
58
58
### Run the `git clone` in the shell
59
59
60
-
Now that you have the URL for a repository that you want to copy locally, you can use the **terminal** to run the `git clone` command followed by the URL that you copied:
60
+
Now that you have the URL for a repository that you want to copy locally, you can use the **terminal** to run the `git clone` command followed by the URL that you copied:
You have now made a local copy of a repository. You can double-check that the directory exists using the `ls` command in the **terminal**.
66
+
You have now made a local copy of a repository. You can double-check that the directory exists using the `ls` command in the **terminal**.
67
67
68
68
```bash
69
-
$ ls
69
+
$ ls
70
70
repo-name
71
71
```
72
72
73
-
74
73
:::{admonition} <iclass="fa fa-pencil-square-o"aria-hidden="true"></i> Challenge - Fork and Clone a Repository
75
74
76
75
Go to GitHub.com and login. Then use the link below to open the **repo-name** repo.
77
76
78
77
`https://github.com/pyopensci/repo-name`
79
78
80
79
* On the main **GitHub.com** page of this repository, you will see a button on the top right that says `Fork`. The number next to `Fork` tells the number of times that the repository has been copied or forked.
81
-
* Click on the `Fork` button and select your **GitHub.com** account as the home of the forked repository.
80
+
* Click on the `Fork` button and select your **GitHub.com** account as the home of the forked repository.
82
81
* Once you have forked a repository, you will have a copy (or a fork) of that repository in your **GitHub** account. The URL to your fork will contain your username:
83
82
84
83
`https://github.com/your-username/repo-name`
85
84
86
-
* Finally, clone the fork that you created above so you have a copy of all the files on github.com on your local computer.
85
+
* Finally, clone the fork that you created above so you have a copy of all the files on github.com on your local computer.
87
86
88
-
To make sure you did things right, in bash, cd to the repo-name directory on your computer.
87
+
To make sure you did things right, in bash, cd to the repo-name directory on your computer.
89
88
Type:
90
89
91
-
`$ git remote -v`
90
+
`$ git remote -v`
92
91
93
92
The paths returned should look something like this:
Copy file name to clipboardExpand all lines: contribute-open-source/edit-commit-files.md
+21-21Lines changed: 21 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,46 +19,47 @@ og:image:alt: An image that shows the steps for contributing to open source on G
19
19
---
20
20
21
21
(pyos-edit-commit-files)=
22
+
22
23
# Your First Edits to a File in Your Fork: Edit & Commit
23
24
24
-
> In this lesson, you’ll learn how to:
25
+
> In this lesson, you’ll learn how to:
25
26
> <iclass="fa-solid fa-circle-check"style="color: #81c0aa;"></i>edit a file directly in your **fork** using GitHub’s interface and commit the changes using only the native GitHub interface
26
27
>
27
28
> If you want to work on the files locally on your laptop, you will need to [clone or make a copy of your repo locally](clone-repo).
28
29
29
-
Now that you've [identified and commented on an issue](identify-github-issue), [forked the repository](fork-repo), and received approval to work on an issue, it's time to make your changes.
30
+
Now that you've [identified and commented on an issue](identify-github-issue), [forked the repository](fork-repo), and received approval to work on an issue, it's time to make your changes.
30
31
31
32
:::{tip}
32
-
💡 Your fix should be **small and text-based**, like updating documentation or fixing a typo.
33
+
💡 Your fix should be **small and text-based**, like updating documentation or fixing a typo.
33
34
:::
34
35
35
-
## How to edit a file in your fork
36
+
## How to edit a file in your fork
36
37
37
-
GitHub lets you edit files right in your browser. Here’s how:
38
+
GitHub lets you edit files right in your browser. Here’s how:
38
39
39
-
1. Navigate to **your fork** of the repository.
40
-
2. Find the file you want to edit.
41
-
3. Click the <kbd><iclass="fa-solid fa-pencil"style="color: #81c0aa;"></i> Edit</kbd> button.
40
+
1. Navigate to **your fork** of the repository.
41
+
2. Find the file you want to edit.
42
+
3. Click the <kbd><iclass="fa-solid fa-pencil"style="color: #81c0aa;"></i> Edit</kbd> button.
42
43
4. Make your changes and **commit** them.
43
44
44
45
:::{figure} /images/github/edit-commit-file.gif
45
-
:alt: "GIF showing how to edit and commit a file on GitHub."
46
+
:alt: "GIF showing how to edit and commit a file on GitHub."
46
47
47
48
Editing a file directly in the GitHub interface is a straight forward process.
48
49
:::
49
50
50
-
> **⚡ Quick tip:** You can edit as many files as you want, but GitHub only lets you commit them **one at a time** in the browser.
51
+
> **⚡ Quick tip:** You can edit as many files as you want, but GitHub only lets you commit them **one at a time** in the browser.
51
52
52
-
## Ways to edit a file: GitHub vs. GitHub Codespaces
53
+
## Ways to edit a file: GitHub vs. GitHub Codespaces
53
54
54
55
GitHub now offers **two ways** to edit files directly in the interface or using the [cloud-based GitHub Codespaces](about-codespace). If you’re making a small change, use GitHub’s interface. If you need to edit multiple files, try Codespaces.
55
56
56
-
|| Option | When to Use | Pros | Limitations |
57
-
|-|---------|------------|------|-------------|
58
-
||**GitHub Interface** <iclass="fa-solid fa-pencil"style="color: #81c0aa;"></i> | Quick edits (typos, small fixes) | No setup needed, edit in browser | Can only commit one file at a time |
59
-
||**GitHub Codespaces** <iclass="fa-solid fa-laptop-code"style="color: #81c0aa;"></i> | Editing multiple files | Full VS Code environment in browser | Requires configuration but once configured, you can reuse it |
57
+
|| Option | When to Use | Pros | Limitations |
58
+
|-|---------|------------|------|-------------|
59
+
||**GitHub Interface** <iclass="fa-solid fa-pencil"style="color: #81c0aa;"></i> | Quick edits (typos, small fixes) | No setup needed, edit in browser | Can only commit one file at a time |
60
+
||**GitHub Codespaces** <iclass="fa-solid fa-laptop-code"style="color: #81c0aa;"></i> | Editing multiple files | Full VS Code environment in browser | Requires configuration but once configured, you can reuse it |
60
61
61
-
> **💡 Need to edit multiple files using a coding editor like VsCode or Jupyter?** Learn more about using [GitHub Codespaces](github-codespaces).
62
+
> **💡 Need to edit multiple files using a coding editor like VsCode or Jupyter?** Learn more about using [GitHub Codespaces](github-codespaces).
62
63
63
64
## What is a commit?
64
65
@@ -85,11 +86,10 @@ Each commit represents **a set of changes** at a specific time.
85
86
You can always **undo or revert** changes using Git.
86
87
:::
87
88
88
-
:::{admonition} What's next?
89
-
:class: seealso
89
+
:::{admonition} What's next?
90
+
:class: seealso
90
91
91
-
Once you've committed your changes, you can open a **<iclass="fa-brands fa-github-alt"></i> pull request (PR)** to suggest your edits to the main project.
92
+
Once you've committed your changes, you can open a **<iclass="fa-brands fa-github-alt"></i> pull request (PR)** to suggest your edits to the main project.
92
93
93
-
[<iclass="fa-solid fa-circle-check"style="color: #81c0aa;"></i> Learn how to create a pull request →](pyos-pull-request)
94
+
[<iclass="fa-solid fa-circle-check"style="color: #81c0aa;"></i> Learn how to create a pull request →](pyos-pull-request)
0 commit comments