In the previous article, I’ve shown how to install Git on Windows 7, but before you can start using it, there’s some basic configuration that needs to be done.
In this article I’ll show how to setup your user name and email address, and configuring external tools like Notepad++ and Beyond Compare to edit your comments and to visualize changes in your code.
Before proceeding, open Cygwin bash shell (Start –> All Programs -> Cygwin -> Cygwin Bash Shell).
Setting user name and email
Git needs to know your user name and email address to properly credit your commits,
$ git config --global user.name "Your Name" $ git config --global user.email your@email.com
NOTE: The “email” setting doesn’t need to a valid email address, it only needs to match the “user@server” naming scheme.
this will setup your user name and email address globally within Git. If you want, you can override this settings on a per-repository basis:
$ cd your_repository $ git config user.name "Your Name" $ git config user.email your@email.com
Setting the core editor
To properly use Notepad++ editor, you need to create a wrapper script “git-core-editor.sh” with the content,
#!/bin/sh "C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -notabbar -nosession $*
and save it at the path “C:\Cygwin\usr\local\bin”.
Now, lets proceed with the editor configuration:
$ git config --global core.editor /usr/local/bin/git-core-editor.sh
The next time you commit something,
$ git commit
Notepad++ will show up, type your comments, save and close.
Setting the diff tool
Similar to the editor configuration, you also need to create a wrapper script “git-difftool-warpper.sh” with the content,
#!/bin/sh
REMOTE="$(cygpath -w "${1}")";
LOCAL=${2};
echo Launching BComp.exe $REMOTE $LOCAL
"C:/Program Files (x86)/Beyond Compare 3/BComp.exe" $REMOTE $LOCAL
and save it at the path “C:\Cygwin\usr\local\bin”.
Now, lets proceed with diff tool configuration:
$ git config --global diff.tool bc3 $ git config --global difftool.bc3.cmd "git-difftool-wrapper.sh \"\$LOCAL\" \"\$REMOTE\"" $ git config --global difftool.prompt false
To visualize your code changes
$ git difftool <file_name>
That’s all you need to start using Git.
Pingback: Git, Gitosis, Putty and Windows
Pingback: DotNetShoutout
last week our class held a similar discussion about this topic and you point out something we have not covered yet, thanks.
- Kris