I seem to hit this issue every time I setup GitHub for Windows on a new machine.
I setup my SSH connection to the git server, but every single time I use git over the SSH transport, I need to re-enter my passphrase.
After finding and trying a few different solutions, this is what worked for me:
- Create a
.bashrc file in your home directory (the
%USERPROFILE% environement variable).
- Add the following lines in it:
Start a git bash session – you will be asked for your passphrase once, at the start, and no more.
eval 'ssh-agent' did not work for me (and strictly speaking the
#!/bin/bash is not needed).
Would love to hear about better alternatives / ways to achieve this.
I found the book to be quite a good introduction as well as a suitable book for power users.
The book starts with the basics – the common uses that most users will have of git, it then goes into workflows followed by more esoteric uses and an in depth look into git internals.
In the in-depth chapters, the details are very low level – how git stores different objects, what they look like and what information the different object types contain.
The book is very *nix centric – some chapters and commands assume a *nix environment, and it isn’t clear how these specifics translate to windows (examples include hooks and hook scripting).
Things I found interesting:
- I did not know that I could just use a network share for collaboration (using the local protocol). This is very simple to setup – could be perfect for a small office/home office environment where code doesn’t need to be on the Internet.
rerere – recording confict resolution. A git feature that allows recording how merge conflicts have been resolved, so future conflicts can be automatically resolved using the same strategy (this is a rare use but can be very helpful if the same merge needs to be performed repeatedly).
- Git hooks for customizing actions – for example, special commit rules, running commands when fetching and more (the book doesn’t make it clear if/how to manage this on Windows).
filter-branch – a very powerful, but very dangerous feature, that allows rewriting history across the whole repository and commits in it. Can be useful for removing certain files from all revisions (say a private key file was committed by error and should be completely expunged).
reset works – the section explains the different states of a repository being tracked, what HEAD means and how to think about it and what
reset does. Clarified quite a bit for me.
- Splitting a repository – for example, if the repository has grown a lot and only the recent history is of interest, it is possible to split a repository into old historical/current.
I recommended this book if you feel you are not using git effectively.
It contains lots of info about how different commands work, and is a good introduction to many tools, some of which you may not be familiar with (
reset, bundling, rebasing and more) as well as a chapter dedicated to the use of github.
The book can be read online, downloaded for free (supported formats are pdf, epub, mobi and HTML), and a dead tree edition is available on amazon.