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

Sunday, July 7, 2013

git install --windows


There are two competing Git packages for Windows: a Cygwin-based Git and msysGit. I will describe how to install the msysGit package

Run the installer (Git-1.8.4-preview20130916.exe  at the time of writing) :
  • explorer integration : simple context menu (I haven't tried the cheetah one)
  • Use git Bash only (at least for starters) - see here for a hack
  • Configure line endings : that's a complicated one. Bottom line : choose Checkout as-is, Commit as-is and be sure to setup a .gitattributes file in all of your repos. I will blog about this soon.
First of all, on installing, if not on english windoz, you will have the nasty surprise of having the GUI display in your locale. That's plain a pain - and easily fixed : delete C:\Program Files (x86)\Git\share\git-gui\lib\msgs\*.msg file(s). Read on all the gory details

Recent versions of git won't allow you  to commit without telling who you are :
git config --global user.name "Firstname Lastname"
git config --global user.email "your_email@youremail.com"
At some point you may need to setup an editor for git - I use notepad++ and a guide for setting this up is here. Essentially you need to issue :

git config --global core.editor C:/path_with_no_spaces/npp.bat

where npp.bat:

#!/bin/sh
"c:/Program Files/Notepad++/notepad++.exe" -multiInst "$*"

notice the Unix like syntax. Alternatively you may just issue :

git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

Explanation for the flags (you probably only need -multiInst - see here) - another post by VonC with similar info.

At some other point you may need to setup a merge tool - see here for various tools, and here for more up to date info on p4merge.

Git - First-Time Git Setup for more info - I'd say to add these commands in a script and also to dump your %USERPROFILE%/.gitconfig into dropbox and link to it from there

Finally if you are annoyed by the gc popup disable it thusly (but be sure to understand what it is about)

Worth noting : .gitignore, .gitattributes etc start with a dot - you can't create them in explorer - do this in git Bash (for instance) :

$ echo "*.class" >> .gitignore
Another complicated point is to set up the SSH keys (if you want to push without entering your username/pass. You may leave it for now). From here :

Go to Start > Git Gui >

Click the "Generate Key" button.This will generate your public and private OpenSSH keys. You will be prompted to enter an optional passphrase. If you do, then you will be prompted to enter the passphrase each time you try to push to github - so you may wish to leave it blank. Once generated, Git GUI will store your private and public keys in your %USERPROFILE%/.ssh directory. You may wish to back up these keys to somewhere secure. Git GUI will now display your public key. Enter this to your github (or other) account (in github is under Settings > SSH Keys).

Here are some very useful links :

An Illustrated Guide to Git on Windows - really nice demo (with screens) of using the Gui and Bash to commit, branch, push etc. Start from here (I just found the contents)

Basic docs :

Git - Book - be sure to read at least Git - Basic Branching and Merging.
Git Reference - nice minimal site
Git User’s Manual (for version 1.5.3 or newer) - da manual

Couple of links on specific topics - must read :

Git for Computer Scientists - the data structures !
A successful Git branching model - branching done right

More docs tutorials etc :

The Git Parable - lol
Everyday GIT With 20 Commands Or So - quick reference
Git Magic - Preface - and another one
A tour of git: the basics - yet another
Git Immersion - step by step
The Thing About Git - why the index
Git For Windows Developers
A few of my Git tricks, tips and workflows

2013.11.02 20.53 UTC

Saturday, October 13, 2012

git remind


And I will begin with :
git checkout revision/branch path/to/file
for checking out into the working tree a particular version of a particular file. So :
git checkout HEAD path/to/file
would revert all changes in file relative to the last commit index.

Push a local branch to a different remote branch :

git push -v -u remote_repo local_branch:remote_branch
as in git push -v -u origin github:master. -v is verbose -u is to set the local tracking the remote branch. Add -n for dry-run.
Push all branches/tags up to the remote repo :

git push --all
git push --tags

From here. Don't be in a hurry though - make sure you really want to push everything.

See all commits  messages in a range between commits abc... and def... affecting a single file :

git log oldhash..newhash -- path/to/inspect
 notice the 2 dots.

Ah - the subject of gitignore - this merits a post but for starters here is the syntax.
See all files that have the assume unchanged bit set :
git ls-files -v
I use the msgit gui to stage/commit separate lines/hunks. If ever interested in how one can do this via console (which sounds like an absolute chore) here is a great post about that.

Free private git repos are sought after. I went for assembla for a (school) project were I needed many (>5) people - but I'd go for bitbucket (I like the UI better). Github unfortunately does not offer private for free. Anyway - from the previous post I got two links describing how one could set up a git repo on their Dropbox account.

Links :

Git Reference
For windoz : http://nathanj.github.com/gitguide/tour.html

2013.09.21 19.01 UTC