Removing git branches from local repository

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

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

Solution

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

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

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.

Solution

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.

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

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

you get the following error:

Solution

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

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

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

Solution

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

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

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.

Solution

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/…/git-ssh.sh’: Permission denied – Capistrano, Dreamhost, permission denied for git-ssh.sh

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

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 git-ssh.sh script copied to your account by capistrano cannot be executed as the permission is denied:

Solution

It seems that Dreamhost, and quite possibly other hosting providers are not allowing executables from the /tmp directory, which is where Capistrano places the git-ssh.sh 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

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

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.

Solution

According to the git documentation:

and:

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

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

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.

Solution

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

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem
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.

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

replace:

with: