Wednesday, March 26, 2014

Git config on GNU-Linux

Colors

To add coloration:
git config --global color.ui true

SSH

Connect to a remote repository without using the password (ssh key). On Bitbucket, different connection protocols have different repository URL formats. Create a private and public ssh key pair with for example the seahorse key manager. Then add the public key to bitbucket under manage account / security / SSH keys.

Moving from https to ssh url format 

My previous connection was through https. You can skip this command if you start with a fresh repository.  Rename the remote "origin" to "originhttps".
git remote rename origin originhttps
Just wanted to be able to connect through https in case the ssh connection doesn't work. This remote tracking branch can be deleted later with:
git remote remove originhttps

Tell git to use a ssh:// remote

Then tell git to use a remote (the "ssh://" protocol name is optional as shown in this how-to):
git add remote origin ssh://git@bitbucket.org/accountname/reponame.git
Fetch the new remote tracking branch into the local repository. (It will probably not load anything new but is required to set this branch as upstream later):
git fetch origin master

Set upstream branch

The commands "Git pull" and "git push" still connected to the https url (which prompts for a password). I had to set the new remote as the default for my master branch:
git branch --set-upstream-to=origin/master
List remote branches (for information)

git branch -r

The repository is now ready to fetch, merge and pull on remote origin without entering the password.


See also my post on git commands.

Thursday, March 13, 2014

Regular Expression


Rstudio REGEX
Wanted to replace # at the end of the line. So that they don't appear in the code navigator. $ indicates the end of a line in a regular expression. 
Replaced #######$ by ####### # .