Friday, June 14, 2013

openssh/git on Windows

You need to install msysgit with openssh first.

Basic ssh:

  1. Check whether environment variable HOME is set by running command "echo %HOME%". If it is not set, set it (for me it is C:\Users\<username>\)
  2. Put your private/public keys into directory: %HOME%/.ssh
  3. SSH config file should be %HOME%/.ssh/config
  4. open a windows cmd window and run "ssh -T <username>@<hostname> ".
    Or open git bash window, and run the same command.

ssh-agent

Unfortunately I could not make it work by using only native Windows env.

Instead, I ran it inside git bash. In git bash,

  • run command
    eval `ssh-agent`
    ssh-add <path>/<to>/<your>/<key>

Eclipse

Open preference dialog, search for "ssh2" and configure the path of private key, etc. accordingly.

git config

Download the git config file https://sites.google.com/site/jenvor/Home/.gitconfig?attredirects=0&d=1 to %HOME%/ and change it based on your info.

Initialize a local repo and push its content to an empty remote repo:

mkdir /path/to/your/project
cd /path/to/your/project
git init
git remote add origin <your_git_ssh_or_https_path>
# add/change files/directories
git add <file>
git commit
git push -u origin --all   # for the first time only

Set-up upstream branch: git branch -u origin/master