How to fork MaidSafe and contribute a code change / Submit a Pull Request

When I did this I was a git / github novice trying to make a trivial change and submit a pull request. With a bit of help I succeeded, so anyone should be able to follow me. This FAQ explains what I did.

I already have an account on github configured with ssh keys etc and have been using it to clone the maidsafe C++ repo to my Linux PC and build it, and recently also cloning dirvine’s Rust crates and building those. The latter is what I’m trying to get my name in…

Here is what I did so far, following the instructions at https://help.github.com/articles/fork-a-repo/

In firefox visit https://github.com/dirvine/self_encryption

Click fork

Grab URL of the fork: https://github.com/theWebalyst/self_encryption

Switch to Linux terminal:

$ cd ~/src/forks
$ git clone https://github.com/theWebalyst/self_encryption

Sync with the original repo…

$ cd self_encryption
# Show current sync..
$ git remote -v 
# Sync with source of fork..
git remote add upstream https://github.com/dirvine/self_encryption
# Verify
$ git remote -v

To sync with the master repo (see: https://help.github.com/articles/syncing-a-fork/)

$ git fetch upstream
$ git checkout master
$ git merge upstream/master

I made a change to src/self_encryption.rs and tried to commit

$ git commit`
On branch master
Your branch is ahead of 'origin/master' by 45 commits.
  (use "git push" to publish your local commits)
Changes not staged for commit:
	modified:   src/lib.rs

no changes added to commit

I stopped at this point because of the output above. Looks like I’m not set up correctly. I thought it a bit odd that when I did the git fetch upstream it appeared to grab and merge lots of changes when I wasn’t expecting any. Maybe that’s where I messed up? I was following the instructions from this: https://help.github.com/articles/fork-a-repo/

@dirvine any hints!?

David says they just made a load of changes, so I am ok and have ended up with my clone ahead of my git repo, so to push my clone to the repo…

Push local back to my repo

$ git push
Username for 'https://github.com': theWebalyst
Password for 'https://theWebalyst@github.com': 
Counting objects: 154, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (72/72), done.
Writing objects: 100% (154/154), 31.69 KiB | 0 bytes/s, done.
Total 154 (delta 83), reused 139 (delta 68)
To https://github.com/theWebalyst/self_encryption
   7c9fca4..ef83646  master -> master

Try again

$ git commit
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
	modified:   src/lib.rs

no changes added to commit

Oops! I need to “stage” before “commit”, so do either git add ; git commit -m "commentary"
or…

$ git commit -am "test change - added a comment"
[master 8a48db8] test change - added a comment
 1 file changed, 3 insertions(+)

Push to my repo…

$ git push
Username for 'https://github.com': theWebalyst
Password for 'https://theWebalyst@github.com': 
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 497 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
To https://github.com/theWebalyst/self_encryption
   ef83646..8a48db8  master -> master

Woo hoo! Now to create the pull request…
(see: https://help.github.com/articles/creating-a-pull-request/)

In firefox visit my repo at: https://github.com/theWebalyst/self_encryption

In the “Branch” menu, choose the branch that contains your commits.
To the left of the “Branch” menu, click the green Compare and Review button.
The Compare page will automatically select the base and compare branches; to change these, click Edit.
On the Compare page, click Create pull request.
Type a title and description for your pull request.
Click Create pull request.

Done!

Think you’re OK here Mark. Upstream (us) moved on a wee bit since you forked. so your copy is a wee bit behind, but you then pulled from upstream (us) which put your local copy ahead of your repository on github. If you push to your repo you will be fine. then click Pull Request in github and it’s mostly automatic from there. It allows you to see all is well in CI and you can see what exactly you are pushing to us. You can also change or close that so no worries and it’s very safe :slight_smile:

2 Likes

@dirvine that was sneaky pushing those changes just after I forked!

Anyway, all done and documented. I might even be able to do this for real now :smile:

Thanks as always. Woo hooooooo! :sunny:

3 Likes

Proof

4 Likes

I’m really excited too, Mark!! Well, done.

I just wish I knew what you were talking about!!

4 Likes

I just wish I knew what you were talking about!!

Er, me too :#)

2 Likes

Thanks for posting this. My first fork/push/PR as well. Just a readme file update, but hey, perfect learning place.

2 Likes

And merged, thanks core contributors :slight_smile: The more the merrier.

1 Like