Skip to content

Commit bc1fda3

Browse files
update mi-github-and-repositories.md (fixes #3328) (#3487)
1 parent 5c4a816 commit bc1fda3

File tree

1 file changed

+37
-75
lines changed

1 file changed

+37
-75
lines changed

pages/mi/mi-github-and-repositories.md

Lines changed: 37 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -61,42 +61,28 @@ Now, there are three levels of repositories to keep in mind:
6161

6262
These repositories must be consistently synced and up-to-date with each other since we all contribute to the upstream repository (open-learning-exchange.github.io). It's crucial to keep changes separate and avoid mixing them between repositories. Significant differences can cause conflicts and prevent you from performing `git push/pull` operations smoothly.
6363

64-
### 2.1 Steps to Sync Repositories
65-
66-
1. **Fork and Clone:**
67-
- Fork `open-learning-exchange.github.io` to create `<YourUserName>.github.io` on GitHub. (This was done in Step 1).
68-
- Clone `<YourUserName>.github.io` to your local system. (This was done in this step's 1.1)
69-
70-
2. **Sync with Upstream:**
71-
- Add the upstream repository:
72-
```
73-
git remote add upstream https://github.com/open-learning-exchange/open-learning-exchange.github.io.git
74-
```
75-
- Fetch changes from upstream:
76-
```sh
77-
git fetch upstream
78-
```
79-
- Checkout your local master branch:
80-
```sh
81-
git checkout master
82-
```
83-
- Merge upstream changes into your local branch:
84-
```sh
85-
git merge upstream/master
86-
```
87-
88-
3. **Push Updates to Your Fork on GitHub:**
89-
- Push local changes to your fork on GitHub:
90-
```sh
91-
git push origin master
92-
```
64+
### 2.1 Detailed Explanation of Syncing Repositories
65+
66+
The syncing process involves several key steps to ensure your local repository, your GitHub fork, and the upstream repository remain coordinated:
67+
68+
1. **Establish Remote Connections**
69+
When you clone a repository, Git automatically creates a remote connection called `origin` pointing to your GitHub fork. However, you need to manually add a connection to the upstream repository from which you originally forked.
70+
71+
2. **Fetch Upstream Changes**
72+
The `git fetch upstream` command retrieves all the branches and their respective commits from the upstream repository. This doesn't modify your local files but allows you to see what changes have been made in the original repository.
73+
74+
3. **Merge Upstream Changes**
75+
After fetching, you'll want to merge the upstream changes into your local branch. This ensures your local repository reflects the most recent updates from the upstream repository.
76+
77+
4. **Push Updates to Your Fork**
78+
Once you've merged upstream changes locally, you can push these updates to your GitHub fork, keeping it synchronized with the upstream repository.
9379

9480
### 2.2 Resources
9581

9682
- [GitHub Help: Syncing a Fork](https://help.github.com/articles/syncing-a-fork/)
9783
- [Git Documentation](https://git-scm.com/doc)
9884

99-
By following these steps, you ensure your repositories are consistently up to date and avoid conflicts (Refer the diagram below).
85+
By understanding and following these steps, you ensure your repositories are consistently up to date and avoid conflicts (Refer the diagram below).
10086

10187
![GitHub Clone URL](image/mi-sync-a-fork.png)
10288

@@ -160,7 +146,7 @@ To fetch updates from the upstream repository, configure it as follows:
160146
git checkout master
161147
```
162148

163-
3. Merge the upstream/master with currnet branch in your local repository:
149+
3. Merge the upstream/master with current branch in your local repository:
164150

165151
```bash
166152
git merge upstream/master
@@ -176,58 +162,34 @@ To fetch updates from the upstream repository, configure it as follows:
176162

177163
## Summary of Steps
178164

179-
Generally, follow these commands in your command line, but refer back above if there are any errors or further questions about why you are writing any of the following commands
180-
181-
#### Clone your GitHub repository &lt;YourUserName&gt;.github.io
182-
183-
1. Open your command prompt/terminal and find the correct directory
184-
2. Copy the HTTPS or SSH link from your repository on the GitHub site
185-
3. On the command line, type `git clone *paste your HTTPS or SSH link here*`
186-
187-
#### Understand that there are three levels of a Github repository
188-
189-
- the upstream ([open-learning-exchange.github.io](https://github.com/open-learning-exchange/open-learning-exchange.github.io))
190-
- Your &lt;YourUserName&gt;.github.io on GitHub
191-
- Your &lt;YourUserName&gt;.github.io on your OS.
165+
Follow these commands in your command line:
192166

193-
These need to be synced and checked constantly.
194-
The **upstream repository** is the one we are contributing to.
167+
#### Clone Your GitHub Repository
168+
1. Open your Git Bash/terminal and go to the directory of your choice
169+
2. Copy the HTTPS or SSH link from your forked repository on the GitHub site
170+
3. Run `git clone *paste your HTTPS or SSH link here*`
195171

196-
#### Configure the upstream repository to your fork
197-
198-
1. `cd <YourUserName>.github.io.`
199-
2. `git remote -v` see above to make sure you are pushing and fetching to your own repository on GitHub as the origin
172+
#### Configure Upstream Repository
173+
1. `cd <YourUserName>.github.io`
174+
2. `git remote -v` - verify current remote repositories
200175
3. `git remote add upstream https://github.com/open-learning-exchange/open-learning-exchange.github.io.git`
201-
4. `git remote -v` origins should remain the same, but you should also be fetching and pushing to OLE as the upstream now
176+
4. `git remote -v` - confirm upstream repository is added
202177

203178
#### Sync Your Fork
179+
1. `git fetch upstream` - retrieve changes from the upstream repository
180+
2. `git checkout master` - switch to the master branch
181+
3. `git merge upstream/master` - merge upstream changes into your local branch
182+
4. `git push origin master` - push updates to your GitHub fork
204183

205-
1. `git fetch upstream` - to fetch branches from the upstream repository ([more info](https://git-scm.com/docs/git-fetch))
206-
2. `git checkout master` - to checkout the `master` branch ([more info](https://git-scm.com/docs/git-checkout))
207-
3. `git show-branch` - to see branches and the changes made in them ([more info](https://git-scm.com/docs/git-show-branch))
208-
4. `git merge upstream/master` - You repository should now be synced to upstream/master ([more info](https://git-scm.com/docs/git-merge))
209-
210-
#### Make sure your repository is up to date
211-
212-
1. `git diff` - for comparing different versions of the same file ([more info](https://git-scm.com/docs/git-diff))
213-
2. `git status` - to view the changes made in the branch, whether the branch is up-to-date with master ([more info](https://git-scm.com/docs/git-status))
214-
3. `git pull` - to sync the local repository with the remote repository ([more info](https://git-scm.com/docs/git-pull))
215-
4. `git push` - to push the updates that you made to the local repositories to the GitHub repositories ([more info](https://git-scm.com/docs/git-push))
216-
217-
**NOTE**: Developers should always sync their fork and make sure their repositories are up to date with GitHub every time they begin to work. This way we as a team can minimize data loss, and can save you some time.
218-
219-
#### If you find yourself needing to rebase your forked repository, the following two links should help
220-
221-
- [Rebase](https://git-scm.com/docs/git-rebase)
222-
- [Branching Rebasing](https://git-scm.com/book/en/v2/Git-Branching-Rebasing)
223-
224-
**NOTE**: While rebasing and merging are similar, there is a difference between them. Merging takes all changes in one branch and merges onto another branch in one commit. Rebasing moves the branch's starting point to another place. For example, if you rebased your branch to the master branch, then your branch now incorporates all the changes made in the master, and every time master is changed, your branch is changed as well. In contrast, merging is a one-time change.
225-
226-
For more info on differences of merging vs. rebasing (and when to use which one), [check this out](https://www.atlassian.com/git/tutorials/merging-vs-rebasing)
184+
#### Additional Useful Commands
185+
1. `git diff` - compare different versions of files ([more info](https://git-scm.com/docs/git-diff))
186+
2. `git status` - view the changes made in the branch, and whether the branch is up-to-date with master ([more info](https://git-scm.com/docs/git-status))
187+
3. `git pull` - sync the local repository with the remote repository ([more info](https://git-scm.com/docs/git-pull))
188+
4. `git push` - push the updates that you made to the local repositories to the GitHub repositories ([more info](https://git-scm.com/docs/git-push))
227189

228-
If you would like to understand how syncing with the fork works, here is a useful [video](https://www.youtube.com/watch?v=-zvHQXnBO6c)
190+
**NOTE**: Always sync your fork and ensure your repositories are up to date before starting work to minimize data loss and potential conflicts.
229191

230-
## Useful links
192+
## Useful Links
231193

232194
- [Configuring a remote repository for a fork | GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) - You can sync changes made in the original repository with a fork.
233195
- [Syncing a fork | GitHub Docs](https://help.github.com/articles/syncing-a-fork/) - Sync a fork of a repository to keep it up-to-date with the upstream repository.

0 commit comments

Comments
 (0)