Removing git branches from local repository


You would like to remove your local branches that were used to track remote branches that no longer exists (deleted after merge).


To delete your local branch you could use the following:

And to to delete the remote tracking branching you could use the following:

git apply name_of_file.patch does not work


You are given a patch file to apply to your git repository but using git apply does not work. No errors reported but no changes applied neither.


Try to use the patch command command possibly with the -p1 parameter like:

NOTE: Make sure that you are in the right folder relative to the file path in the patch file

SSL received a record that exceeded the maximum permissible length.


You want to install rbenv, but when you are trying to clone the code with:

you get the following error:


If you are behind a proxy server make sure that you add your proxy server details in your ~/.bash_profile and source the file afterwards.

So first add the details of your proxy like:

And finally source the file before running the installation again:

How to display the git last commit of every file in a list with ruby


You want to display the last commit of every file that you have in a list.


Let’s say that you have the following file list in an array:

in order to be able to get the last commits of each of the files in ruby do the following:

Refreshing locally remote branches that have been deleted in git


You would like to refresh your local git repository after deleting some remote branches, usually after merging them to a develop,master etc repository, so doing branch -a or branch -r would not display them anymore.


You would need to issue the following git command:

And then doing a branch -r or branch -a should not display the deleted remote branches anymore.

fatal: cannot exec ‘/tmp/…/’: Permission denied – Capistrano, Dreamhost, permission denied for


When trying to use the new Capistrano 3.x to set up your rails project in a dreamhost account, you get the following error complaining that the script copied to your account by capistrano cannot be executed as the permission is denied:


It seems that Dreamhost, and quite possibly other hosting providers are not allowing executables from the /tmp directory, which is where Capistrano places the script. So in order to be able to execute the script you can change the directory where the script is copied in the first place and put it in your home directory. You can do that by adding the following to the config/deploy.rb file:

Pushing and getting the tags from a remote git repository


You want to tag your branches in a remote repository and share the tags with other users, but usually the git pull and git push do not update the tags.


According to the git documentation:


But when doing either a git pull origin [repo] or git fetch origin [repo] the tag list does not seem to be updated.

In this case try the following:

And the list should contain all the tags in the remote repository.

Get github to link your commits to your user account if you have more than one git accounts


You would like to link the commits to a github repository to your github account but you may have different git accounts (ie gitolite etc).
So you would need to specify in the config file which account you want to use.


There is a help page in github that describes this problem here, but they recommend to change your global settings which is maybe not what you want.
So you could the following to change only the current project settings:

And to check the settings:

Stop github asking your username

You are working with a git repository but after first cloning the project to your localhost and trying to push changes afterwards, github is asking for you username and password.

Edit your git configuration and make sure that it uses the git protocol instead of https, so in your ~/project/.git/config file