This might be useful if you want to work with a fork that someone else has started. I found a solution on Stackoverflow which described how to get their work into a branch that can be worked with. [1]
They had forked the project we were talking about on Github, and in their local they checked out a branch of their own to work on, done some awesome work, and pushed their branch back to their fork on Github.
Step 1: Fork our own repository
We can click on the fork button to make a repository of our own that we can work with.
Step 2: Clone our own repository to our local machine
bash
wsl@DESKTOP-DCRMGFD:~$ git clone git@github.com:davidmaceachern/rocket-lamb.git
Cloning into 'rocket-lamb'...
remote: Enumerating objects: 206, done.
remote: Total 206 (delta 0), reused 0 (delta 0), pack-reused 206
Receiving objects: 100% (206/206), 45.74 KiB | 564.00 KiB/s, done.
Resolving deltas: 100% (120/120), done.
Step 3: Get the work that the other person has started into our fork
I ran the following:
bash
$ cd rocket-lamb
$ git remote add other git@github.com:dbanty/rocket-lamb.git
$ git fetch other
$ git checkout -b add-other-changes
$ git pull other rocket-0.5
The output looked like:
bash
wsl@DESKTOP-DCRMGFD:~$ cd rocket-lamb
wsl@DESKTOP-DCRMGFD:~/rocket-lamb$ git remote add other git@github.com:dbanty/rocket-lamb.git
wsl@DESKTOP-DCRMGFD:~/rocket-lamb$ git fetch other
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 15 (delta 9), reused 15 (delta 9), pack-reused 0
Unpacking objects: 100% (15/15), 3.58 KiB | 215.00 KiB/s, done.
From github.com:dbanty/rocket-lamb
* [new branch] master -> other/master
* [new branch] rocket-0.5 -> other/rocket-0.5
wsl@DESKTOP-DCRMGFD:~/rocket-lamb$ git checkout -b add-other-changes
pull other rocket-0.5Switched to a new branch 'add-other-changes'
wsl@DESKTOP-DCRMGFD:~/rocket-lamb$ git pull other rocket-0.5
From github.com:dbanty/rocket-lamb
* branch rocket-0.5 -> FETCH_HEAD
Updating 6b28c56..6a995b1
Fast-forward
Cargo.toml | 9 +++--
src/builder.rs | 26 ++++++++-----
src/handler.rs | 220 ++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------
src/request_ext.rs | 56 +++++++++++++-------------
tests/path_tests.rs | 2 +-
tests/rocket_tests.rs | 11 +++---
6 files changed, 155 insertions(+), 169 deletions(-)
Step 4: Make some changes then push to Github
Once changes have been committed locally they can be pushed to our remote for others to benefit from.
bash
$ git push origin HEAD
They can then add our fork as an other
remote on their local so they make use of the work we did, if what we did was correct of course!
Wrapping up
Thoughts on this? Have you done something similar or maybe there is a better way to go about working with a fork?
If this helped don't forget to go to Stackoverflow and upvote the solution provided there!
References
[1] Git pull from someone else's fork https://stackoverflow.com/questions/42156971/git-pull-from-someone-elses-fork#42157071
Top comments (1)
Oh hey that's me! Thanks for collaborating with me on this βΊοΈ. I'm now using these instructions to pull your latest changes into my fork to keep working!