setup git

This page describes the Git setup for Windows MWP

 

Configure Git for Windows Client

TortoiseGit

TortoiseGit is a windows GIT client that integrates into windows explorer. Install TortoiseGit by performing the following steps:

Download the latest version of TortoiseGit from here and install it using these settings:

  • In the Choose SSH Client dialogue, select OpenSSH, Git default SSH Client.

Git for Windows

Download and install the latest version of Git for Windows from here which is required by TortoiseGit.

  • Uncheck Windows Explorer Integration in the Select Components panel, this to avoid cluttering up your right-click context menu.
  • In the Adjusting your PATH environment dialogue, select Use Git Bash only.
  • In the Configuring the line ending conversions dialogue, selectCheckout Windows-style, commit Unix-style line endings.
  • When installation is finished, add/modify a user environment variable HOME with the value C:\Users\<signum>. (Control Panel, System, Advances system settings, Environment Variables)
  • Configure user name and Email, by right-clicking in a folder or on the desktop and clickingTortoiseGit',Settings.Select Git in the left hand window.
    Select Global in the right hand window. De-select inherit for Name and Email. Enter yourName (your full name not Ericsson signum) and Email (e-mail address). Press Apply and then OK. If you get a fault applying this change, try to modify the user environment variable HOME with the value C:\Users\<signum> first and try setting name and email again (you may need to close and reopen the Settings window in between).
  • Right-click on the desktop, select TortoiseGit, Settings, Network and check that the SSH client path is C:\Program Files (x86)\Git\bin\ssh.exe
  • TortoiseGitSettings.PNG
  • Add Git bin directory C:\Program Files (x86)\Git\bin to your Windows System variable Path:
    Select Start, Computer, System Properties, Advanced system settings. Select the System variable Path and select Edit... Insert this string as the first Variable value:
    C:\Program Files (x86)\Git\bin;
    Select OK.

SSH keys

GIT uses SSH to sync with remote repositories. Key based authentication has to be set up since some tools, such as gerrit, do not allow keyboard interactive authentication. Perform steps 1-2 athttps://help.github.com/articles/generating-ssh-keys and copy the key by usingclip < ~/.ssh/id_rsa.pub, and continue to the step 'Setup Gerrit Account' further down on this page.

An another option to generate SSH keys, where eclipse is configured as well, and add your public key to gerrit, perform the following steps:

  1. Start eclipse and open preferences by clicking window then Preferences. In preferences, expand General, Network Connectionsand select SSH2.
  2. In the General tab, click Browse next to SSH2 home either select a folder containing your SSH keys or C:\Users\<username>\.ssh\ if you don't have one.
  3. If you don't have any SSH keys: in the Key Management tab, clickGenerate RSA Key, click Save Private Key and save the keyswithout passphrase protection to C:\Users\<username>\.ssh\

Cross platform (Windows/Linux) issues

Windows and Linux use different line endings (CRLF / LF). To ensure proper handling of line endings and permissions in Windows, run this command from Git Bash in Windows:

git config --global core.autocrlf input
git config --global core.filemode false
git config --system core.filemode false
git config --system core.autocrlf input

Git in Eclipse

Egit is an Git plugin for eclipse. Install it using these instructuions: http://www.banym.de/eclipse/install-git-plugin-for-eclipse

Setup Git account

Git needs to know who you are. This information will be stored with each commit you make so make sure it's correct before you start working. It isvery important that you type a correct mail address. Execute these commands in Git Bash:

git config --global user.name "Firstname Lastname"

git config --global user.email "yourmailaddress"

Merge tool

KDiff3 is the recommended merge tool.

Download and install KDiff3 using the default settings.

Add the KDiff3 directory C:\Program Files (x86)\KDiff3\bin to your Windows System Path:
Select Start, Computer, System Properties, Advanced system settings. Select the System variable Path and select Edit... Insert this string as the first Variable value:
C:\Program Files (x86)\KDiff3\bin;
Select OK.

Add KDiff3 as your Git mergetool by running this command from Git Bash:

git config --global merge.tool kdiff3

Add KDiff3 as your Git difftool by running this command from Git Bash:

git config --global diff.tool kdiff3

Add KDiff3 complete path to Git Config by running this command from Git Bash:

git config --global mergetool.kdiff3.path "C:/Program Files (x86)/KDiff3/kdiff3.exe"

Git default push behavior

To have "git push" to only push the current branch (and not all branches) is the most secure push behavior:

git config --global push.default current


NOTE: You will be loggedout automatically after some time, but it looks like you are still logged in! Refresh the page or click signout and sign in again.

GitBash copy/paste and layout settings

You can modify the settings applied when using the Git Bash Here context menu by doing the following:

Open the Git for Windows installation folder:

Windows Vista:

C:\Program Files\Git

Windows 7:

C:\Program Files (x86)\Git

Right click on the Git Bash shortcut file (not the VB script file!) and select Run As Administrator. Click Yes if asked whether you want to give the Windows Command Processor permissions to modify the computer (otherwise your changes will not be persisted). Modify the properties as below. Note that some tabs in the screenshot may not be visible on your system.

  1. Right click on GitBash icon.
  2. Click on "Properties"
  3. In the "Options" tab, tick "QuickEdit mode" and "Insert mode"

Good Setting for the layout are:

Screen buffer size

Width: 160

Height: 3000

Windows size

Width: 160

Height: 75

Now you can select text with mouse pointer and left button, copy with "enter" and paste with right mouse button.

GitBash.JPG


Setup some useful aliases

Please refer to this page  for instructions on how to setup useful aliases.

Include current branch in Git Bash prompt

Edit the ~/.bashrc file with this command in a Git Bash shell:

vi ~/.bashrc

Insert this line:

export PS1='\[\033[01;32m\]\h\[\033[01;34m\] \w\[\033[31m\]$(__git_ps1 "(%s)") \[\033[01;34m\]$\[\033[00m\] '

A couple of other aliases you can add in the file also:

alias ls="ls -F"
alias la="ls -aF"
alias ll="ls -al"
alias more="less"

Save and exit, the changes will take effect if you start a new Git Shell.

發佈了27 篇原創文章 · 獲贊 5 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章