Initial Git Setup
21 October 2019
Ssh
I keep forgetting these commands - they’ve got nothing much to do with this project, but I’m going to write them down anyway - maybe they’ll be useful next time around.
Creating a key
creating an ssh key
ssh-keygen -o -a 100 -t ed25519
and then add the public ssh key to GitHub .
Starting the ssh-agent
in my .bashrc file add
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/github_key
in my .bash_logout file add
kill $SSH_AGENT_PID
Commit Messages
A while back, I read a blog post about creating commit messages before starting work. In theory, this would help the commit log to contain the ‘whys’ and not just the ‘whats’ of the change.
But where to save the commit message that has been written up-front? One answer would be to keep a small text file containing the message, probably in the root of the repository. Said file would naturally not be committed itself; it is after all the commit message. Simple. Add the file to the gitignore, and it won’t be committed. But, what now if we change branch? I’ll probably want another commit message here, and I likely don’t want to lose the one I had before either. The complexity ramps up.
My current working solution is to create a file with the name of the branch in a folder full of commit messages with the whole folder added to the gitignore. I also like to split my branches into feature branches and bugfix branches - it just helps to keep me organised - so I want to mirror this in my commit message files.
Naturally creating these files by hand is quickly going to be tedious, and since tedious things tend to get ignored that just won’t do. So I set up a couple of bash functions. Will be interesting to see how these evolve with usage.
function prep() {
local rootpath=$(git rev-parse --show-toplevel)
local branch=$(git rev-parse --abbrev-ref HEAD)
mkdir -p ${rootpath}/commits/${branch}
rm -f ${rootpath}/commits/${branch}.msg
vim -f ${rootpath}/commits/${branch}.msg
}
function commit() {
local rootpath=$(git rev-parse --show-toplevel)
local branch=$(git rev-parse --abbrev-ref HEAD)
cd ${rootpath}
git commit -F${rootpath}/commits/${branch}.msg -e
}
And with that done, hopefully, I can move on to the project itself.