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 ­čÖé

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,

[Solved] Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode

Pocket

This error usually is caused when a same library is referenced more than once in gradle build configurati

Cordova Build Error
Cordova Build Error

The solution is very simple we’ve to remove the plugin that is causing the conflict. Issue the below provided two commands one after other.

Change the current directory to the ionic project and then issue the below commands.

$ cordova plugin remove com.google.playservices // version 19
$ cordova plugin add com.google.playservices // version 21

Those command basically remove the conflicting plugin and then re-install it again. Somehow this fixes the issue but don’t know how this internally works perhaps configuration is re-written when plugin is added again.

Below references were used to solve this issue and you too might find them useful in case above command did not work for you.

REFERENCES:

  • http://stackoverflow.com/questions/22468700/unexpected-top-level-exception-com-android-dex-dexexception-multiple-dex-files
  • http://stackoverflow.com/questions/22958979/multiple-dex-files-define-lcom-google-ads-adrequesterrorcode-and-multiple-dex-f
  • https://github.com/floatinghotpot/cordova-plugin-admob/issues/196

[How To] Add Genymotion to Ubuntu Dash Menu

Pocket

Genymotion Dash
At First create a “genymotion.desktop” file in “usr/share/applications/” folder. Then copy and paste the below contents into “genymotion.desktop” file.

[Desktop Entry]
Encoding=UTF-8
Name=Genymotion Simulator
Comment=Android Simulator fast and reliable
GenericName=Genymotion Simulator
Exec=/usr/local/bin/genymotion
Terminal=false
Type=Application
Icon=/media/BACKUP/genymotion/icons/icon.png
Categories=Application;Network;Internet;
StartupWMClass=Genymotion
StartupNotify=true

In above file, I have created symbolic link to my genymotion in “/usr/local/bin/genymotion”. I have installed genymotion in “/media/BACKUP/genymotion/” thus my command to create symbolic link to genymotion is:

$ sudo ln -n "/media/BACKUP/genymotion/genymotion /usr/local/bin/genymotion"

Now, change the “Icon” to point to the icon.png file which is inside the genymotion folder.

If you have any confusions following this walkthrough. Please let me know in comments.

Thanks,