How to keep your forked repositories in sync with the source repository

Pocket

This blog post aims to answer the following questions.

  • How to contribute to Open Source Projects (Partially)?
  • How to keep forked repositories in sync with the source repository ?
  • How to pull the commits from source repository to the forked repository?

I often forked open source repositories found in github and also commit back to the repositories whenever I feel to. However, this may seem obvious who has been doing these kind of thing. But for someone who is completely new this is kind of mess and it’s hard to figure out the right way to do it at first. So, I do not claim that the way I show here is right. I am just showing how I do it my way and would like to share it with others.

I have forked repository from github repo. I already have it cloned in my local repository. I had forked it long ago. So, when I get back to the forked repo, I get a message saying that My repository is 3 commits behind.

Introduction

Now, before I can contribute to the main repo I have to first sync up my repo with the forked one. To do that I have to bring in all the commits that are missing from my repo, those commits are as follows:

  • Add PHP School to intro FAQ
  • Add Snappy library
  • Add packages to work with screenshot APIs

I get inside my forked repository i.e. https://github.com/samundra/php-faq

php-faq

is the folder that I have my forked repo on my local machine. So I use

$ cd php-faq

to get inside the folder. Inside the folder as you can see below “git remote -v” displays the “origin” as the remote.

To be able to pull in changes, I will add another remote which is my forked repository. I use

git remote add wwphp https://github.com/wwphp-fb/php-resources

Now when I do

$ git remote -v

it will display origin and wwphp under remote list.

Git Remote Add

Now, I fetch all the meta information from the newly added repo i.e. wwphp. I am only interested in the master branch and thus fetching information from that particular branch only.

git fetch wwphp master

Now, to see the commits that my repository is missing I use

$ git log --oneline origin/master..wwphp/master --left-right

Fetch metainformation from remote repository

It basically lists out all the commits that are in wwphp/master branch but no in origin/master (my forked repository).

We can see that we don’t have above 3 commits on my forked repository.
Commits on current repo

Just to confirm:
Commits on current repo

Now, to pull in the commits that my repo is missing I will use

$ git merge wwphp/master

Merge github commits from remote repo to forked repo

To confirm that we have successfully pulled in the commits we can see the “git log” output. The above output message “Your branch is ahead of ‘origin/master’ by 3 commits.” are shown because I haven’t pushed them to my forked repo on github. Once I push the currently made changes to my github repo then this message will stop showing up.

View merged commits

Finally push all the newly introduced commits to my forked repository.
Final push to the github

Now, the message has changed from “3 commits behind” to “branch is even” which means that we have successfully pulled in all the commits from remote repo to our forked repositories.

Note:

Instead of “git fetch wwphp master” we can also use “git fetch https://github.com/wwphp-fb/php-resources/ master” similarly we can use “git pull https://github.com/wwphp-fb/php-resources/ master”. However, I would suggest you use the fetch and then see the commits that will come in and whether you would like to merge or not.

Let me know if you have any confusions on this. I will try to answer them.

Happy forking šŸ™‚

Magento API Error “invalid API Path”

Pocket

I have extensibly working with Magento APIs lately. At one instance I got error “invalid API path”. After some digging around, I found the solutions and issue that caused it.

This issue is caused when the magento API call is not defined in the XML definition of the API file. The original API call was “catalog_product.create” and I used “product_catalog.create” so this was the reason for “invalid API Path” error in Magento API.

Hope this information helps.

Unable to change account picture and lock screen background in windows8.1

Pocket
Account picture in windows8.1
Account picture in windows8.1

It’s been a while I have been using Windows8.1 activated. I tried to change the account picture and lock screen background but to my surprise I could not change it. After researching a bit, I came to know that this issue was caused by the folder permissions issue in windows8.1. In order to change account picture and lock screen background picture the user needs to have access to “C:\ProgramData\Microsoft\User Account Pictures”. Once I knew the issue it was matter of minutes to get this done.

Please follow the below processĀ to assign permissions to yourself in windows8.1 pro.

1. Hit “Ctrl+r” type “%programdata%\Microsoft\”
2. Select “User Account Pictures” click properties
3. Remove the “Read Only” attribute checkbox from this folder
4. Click on “Security” Tab
5. Click “edit” > It will show a new window
6. In newly shown window, Click “Add” > This will again show a new window “Select User & Groups”
7. In “Select User & Groups” window click advanced, This will again show a new window, Here click in “Find Now”
8. From the displayed search results select your “username”, If you are not sure about how to find your username it’s quite easy.

How to find username?
1. Ctrl+R
2. Type “cmd”
3. The user would be last one in the bash terminal e.g. “c:\Users\samundra>”. Then “samundra” would be the username.

9. Once user is selected, Select that user in permission window and under “Permissions for user” section “check mark” on allow for him on everything.
10. click “OK” on every window that’s been opened.
11. Now try to change the account picture and lock screen background.

Please let me know if you have any confusions on this.

Thanks,

Nepal gets a new constitution 2072

Pocket

CONSTITUTIONĀ of NEPAL 2072

Today, Nepal got its most awaited constitution 2072. Being Nepali this is proud moment for me and for all Nepalese. There has been clashes between political leaders, parties. Despite all the shortcomings they gave us the constitution 2072. IĀ hadn’t expected the constitution would come so sooner.Ā 

Here is my facebook status.

Congrats to all of us ā€Ŗ#ā€ŽNepaleseā€¬ for the new constitution 2072. Celeberation begins smile emoticon with Asee Shrestha being an Engineer eight years is not a long span for something that has to do with country’s revolution. Once again thanks to all the political parties, leaders who showed their active participation in this historical moment.