Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

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

Saturday, October 13, 2012

Git cheatsheet


My random notes on Git use.

   
   
   
g checkout path for path, reset WT to Index (change WT)
g checkout tree-ish path for path, reset WT and Index to tree-ish (change WT and Index)
g checkout branch switches branch by updating the index, working tree, and HEAD to reflect the specified branch (current branch is switched)
g checkout commit_id check out a commit for inspection and discardable experiments.
(current branch is switched)
g checkout -p commit_id don't switch branch; update working tree and Index interactively.
E.g. g checkout -p HEAD
g checkout -b branchname\
    start_point
create a new branch from start_point and switch to it.
(current branch is switched)
g checkout not sure yet!
   
g reset path for path, reset index to HEAD (WT and branch are not touched)
g reset commit path for path, reset index to commit (WT and branch are not touched)
g reset --option commit reset HEAD to commit, and reset index or WT according to option
(http://www.kernel.org/pub/software/scm/git/docs/git-reset.html)
--soft only reset HEAD
--mixed (default) reset HEAD and index
--hard reset HEAD, index, and WT
--merge reset HEAD and index;
for each file:
    HEAD != commit, then reset WT;
    Index != WT, then don't reset WT;
    HEAD != commit && Index != WT, then abort.
--keep reset HEAD and index;
for each file:
    HEAD == commit, then don't reset WT;
    HEAD != commit && WT == Index && Index == HEAD, then reset WT;
    HEAD != commit && has local changes, then abort.
   
git rebase -i upstream interactively rebase. You can choose to squash commits.
E.g. git rebase -i HEAD^4, git rebasei HEAD@{4}