Kevin's Blog

IT, Java, Ubuntu, Linux

Category: Development Tools

Git: Push to / Pull from Both Github and Bitbucket

* Last Updated: 2013-08-26
* Fixed: Bug in the gitpullall() script. – 2013-07-23
* Refactored: gitpullall() – 2013-08-26

Both Github and Bitbucket are good SCM hosting services. For some reason, you probably want to migrate your project from Github to Bitbucket or vice versa. It’s easy because you just need to change the remote repository info. Sometimes, you want to keep your code in both places which means you want to push it to both Github and Bitbucket.

Pushing to both Github and Bitbucket is easy.

Here is a project cloned from Github. If you check out the remote repository info, it has only Github repo info.

The YOUR_PROJECT/.git/config file, of course, has only Github info.

To add a remote git repository on Bitbucket, use git remote set-url.

Now, it has Bitbucket info too.


Now, run git push -u origin master to set upstream.

It’s enough for pushing to both Github and Bitbucket. So once it’s done, you can just do

Whenever you want to push to both.

Make some changes, Commit and Push

If what you need is only to push to Github and Bitbucket then you don’t need to read this post any further. However, if you also want to pull data from both Github and Bitbucket, it requires a little more extra steps.

Before I show the steps, I need to point out another case that you might want to know. With what I’ve done here, it fetches the data only from Github when running the git pull command. If what you want is only changing it to make it pull from Bitbucket, it’s simple. You just need to swap the positions of origin urls in the YOUR_PROJECT/.git/config file.

So change from this


Now it pulls from Bitbucket instead of Github.

To pull from both Github and Bitbucket, first add the remote repository information using git remote.

You can add both Github and Bitbucket or just the one that is not pulled when running git pull. It’s all up to you.
Now, the YOUR_PROJECT/.git/config file contains the information of the new remote repositories just added.

YOUR_PROJECT/.git/config now has “github” and “bitbucket” as well as “origin”.

If you run git pull, it still pulls from only Github so you need to also run git pull bitbucket master.

* pull from Github


* pull from Bitbucket

If you want to pull it from all the remote repositories, you can use a function in shell script.

Add the following function to .bash_aliases or .bashrc or .profile depending on your OS (sorry Windows users).

Then you can simply run gitpullall to pull from all the remote repositories specified in the YOUR_PROJECT/.git/config file.

To ignore repositories when pulling, add the remote repository names to the repos_to_ignore variable in the gitpullall function above.

Five Things You Didn’t Know About PostgreSQL

This proves that the decision I made about three years ago was right! :)

Code Bubbles – Cool Java IDE

Code Bubbles - Cool Java IDE

Code Bubbles - Cool Java IDE

Seeing is believing so just visit and watch the video.
What an awesome IDE!!!

Eclipse – “Too many open files” Problem

If your OS is Linux and you are using Eclipse, you might possibly see the following error messages or similar after installing lots of plug-ins in Eclipse. In my case, it usually happened after installing TPTP (I’m using Ubuntu Linux 9.04 Jaunty Jackalope Desktop 64bit by the way).

Plug-in org.eclipse.jst.server.tomcat.core was unable to load class org.eclipse.jst.server.tomcat.core.internal.TomcatLaunchConfigurationDelegate.
 /eclipse_installed_path/eclipse/configuration/org.eclipse.osgi/.lazy.15 (Too many open files)


Problems occurred while trying to save the state of the workbench.
 Could not read master table.
 /your_workspace/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources (Too many open files)

or error in opening zip file

This is because there are too many files opened and these are more files than the number of open files allowed . So Eclipse cannot open more files and displays the errors above.

Let’s see the number of open files.

$ lsof | wc -l 


$ lsof | wc -l 

In my case, it was 8965.

What about the number of files Eclipse opens. To see it, use

$ lsof | grep eclipse | wc -l 

In my case,

$ lsof | grep eclipse | wc -l 

2094 files are opened.

Now check the limitation of open files

$ ulimit -a 
core file size          (blocks, -c) #
data seg size           (kbytes, -d) #
scheduling priority             (-e) #
file size               (blocks, -f) #
pending signals                 (-i) #
max locked memory       (kbytes, -l) #
max memory size         (kbytes, -m) #
open files                      (-n) 1024
pipe size            (512 bytes, -p) #
POSIX message queues     (bytes, -q) #
real-time priority              (-r) #
stack size              (kbytes, -s) #
cpu time               (seconds, -t) #
max user processes              (-u) #
virtual memory          (kbytes, -v) #
file locks                      (-x) #

or just use

$ ulimit -n 

To change it, open the file /etc/security/limits.conf and put a greater number than 1024 depending on the number of open files you checked with lsof | wc -l just before.
For example,
Open the file

$ gksudo gedit /etc/security/limits.conf 
add these lines
*                soft    nofile          9216
*                hard    nofile          9216

I just chose some big number that is 9216 (9 * 1024) as it’s greater than 8965

Log out and in then check with ulimit. It should show like this.

$ ulimit -n 

You may try this

$ ulimit -n 9216 

yet I don’t believe it changes the limit for open files permanently. So you’d better modify /etc/security/limits.conf file.

If it is still not changed. Restart the computer and check again. If it still doesn’t show the changed value, open /etc/pam.d/common-session file and add session required

Open the file to edit

$ gksudo gedit /etc/pam.d/common-session 

Add the following line

session required

Log out and in. Now it should work!

$ ulimit -n 

© 2014 Kevin's Blog

Theme by Anders NorenUp ↑

%d bloggers like this: