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: pages/mi/mi-github-and-repositories.md
+37-75Lines changed: 37 additions & 75 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,42 +61,28 @@ Now, there are three levels of repositories to keep in mind:
61
61
62
62
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.
63
63
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)
### 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.
93
79
94
80
### 2.2 Resources
95
81
96
82
-[GitHub Help: Syncing a Fork](https://help.github.com/articles/syncing-a-fork/)
97
83
-[Git Documentation](https://git-scm.com/doc)
98
84
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).
100
86
101
87

102
88
@@ -160,7 +146,7 @@ To fetch updates from the upstream repository, configure it as follows:
160
146
git checkout master
161
147
```
162
148
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:
164
150
165
151
```bash
166
152
git merge upstream/master
@@ -176,58 +162,34 @@ To fetch updates from the upstream repository, configure it as follows:
176
162
177
163
## Summary of Steps
178
164
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 <YourUserName>.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 <YourUserName>.github.io on GitHub
191
-
- Your <YourUserName>.github.io on your OS.
165
+
Follow these commands in your command line:
192
166
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*`
195
171
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
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
202
177
203
178
#### 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
204
183
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
**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))
227
189
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.
229
191
230
-
## Useful links
192
+
## Useful Links
231
193
232
194
-[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.
233
195
-[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