March 2018

Ignoring Files on a Local Repository

We maintain maintain many websites on the Pantheon Platform.  One of the things that we must do when creating local repositories is create a settings.local.php file for storing our local credentials so this information is not shared, nor does it break the site when you bring it down and push it back up.  I wish to not have git continually asking if I wish to track this file and I do not wish to take a chance of commiting it accidentally so, with help, I was told of this method to ignore the file locally and not have that addition to .gitignore not conflict or interfere elsewhere.

In short this method allows the system to ignore certain files in your local repository (that are not to be a part of the git branch or that are not to be propogated). 

The .git/ directory gets created when you create/clone a git repo.  Inside that directory you will find a file .git/info/exclude.  This file acts like a personal .gitignore that allows you to specify files you want git to ignore and not stage. 

 

 

 

Setting up SSH Keys for more than one account and repository

Setting up SSH Keys for more than one account and repository

https://medium.com/@fredrikanderzon/setting-up-ssh-keys-for-multiple-bitbucket-github-accounts-a5244c28c0ac

 

My origins delving into git was creating an account on Bitbucket.  That process was quite painless, learning how to create an SSH key on my laptop, setting it up for my account on Bitbucket.

Since becoming a Drupal intern it became necessary to connect to another repository, Pantheon, and also to connect to Bitbucket using a different account.  Trying to do this I became thoroughly frustrated because in order to connect to these different systems I kept running into issues with duplicate keys, disconnected accounts, being able to get one to work but not the others.

I found a way to make it possible to have distinct accounts and SSH keys that will exist in harmony, without fear of duplicate keys or incompatible accounts.

First create a key for each instance needed and name it accordingly:

ssh-keygen -t rsa -C "companyName" -f "companyName"
ssh-add ~/.ssh/companyName

Create the SSH config file:

nano  ~/.ssh/config

Edit the config file adding your individual instances:

Host companyname.bitbucket.org
       HostName bitbucket.org
       Username <your username>
       IdentityFile ~/.ssh/companyName

Host github.com
       HostName github.com
       Username <your username>
       IdentityFile ~/.ssh/id_rsa

Host AnyOldRepository
       HostName github.com
       Username <your username>
       IdentityFile ~/.ssh/companyName

Now that the keys are setup you can go to your hosting repository and setup the key for that particular repository/username pair (follow the instructions for the individual repository).