How to use git for Windows using sourcetree

  1. Install Git for Windows
    •   Download lastest version and Install
      Caution : lastest version is 1.8.3 now. That is why previous version has bugs when you push your branch.
  2. Install Git Client
    • Go to SourceTree WebSite : http://www.sourcetreeapp.com/
    • Download lastest version and Install
    • Due to the license is free, Recommend you to register.
    • Set Proxy
      • Options in source tree just installe
      • Move to Network Tab
      • Click “Use custom proxy settings” and set to what you want
      • Click “Proxy server requires username and password”
          Warning : username is not just username of proxy.. you should enter username as domain\username.
      • Click “Add proxy server configuration to Git/Mercurial
      • Disable SSL certification validation for WebSite using self-signed certification
      • Move to Git Tab
      • Click “Disable SSL certification validation”
    • Change git to system git(custom installed git)
      • Still on Git Tab, click “Use System Git” Button
  3. Generate private key and public key for accessing your gitlab project to sourcetree
    • Create Private key and Public Key
      • Start up sourcetree
      • Choose Tools/Create or Import SSH Keys  from the menu.
      • Click “Generate” and wiggle the mouse as requested on screen
      • Enter and confirm a key passphrase  (this will be used each time you want to commit, etc)
      • Click “Save private key” and save it to your folder which you want to save it and save with filename.ppk you want
      • Click “Save public key” and save it to the same folder above, so save it again as filename you want as it doesn’t have an extension
      • Select the entire public key that’s been generated in the text box at the top  and copy it to the clipboard!
      • Close the “Generate” dialog box altogether.
  4. Add the private key to source tree
    • Go to your Windows System Tray at right bottom.
      Whenever you have Sourcetree running there will be an app running called “Pageant”
      which is the PuTTY authentication agent ? it’s a blue PC with a hat icon
    • Caution : When you can find Pageant, You should go to Tools/Option in SourceTree,
      and Change SSH Client to Putty/Plink and Click “Automatically start SSH agent when SourceTree opens”.
      and then restart sourcetree.
    • Click “Add Key”
    • Browse to the private key file ( set above as filename.ppk) folder. And choose the .ppk file and “Open” it
    • Type in your passphrase what you entered when you create the private key.
    • Close this dialog box.
    • Go to Tools / Options
    • Stay on the General tab. Click the “…” button next to the SSH Key
    • Browse to the folder( where private key is ), and choose the .ppk file again.
    • Close the options dialog box.
  5. Add above public key saved into clipboard to Gitlab
    • Log in to Gitlab site
    • Click Image Button meaning My Profile at right top of the page.
    • Click “SSH keys”
    • Click “Add New”
    • Paste in the clipboard what keep public key  to “Key” field and fill title what it best express into “Title” field
    • Click “Save”

     

  6. Create Session for passing Proxy using ssh.
    • Download the full PuTTY.exe client from http://www.putty.org
    • Launch it
    • Type an session name under ‘Saved Sessions’
    • Go to Connection > Proxy
    • Fill in the proxy details
    • Go back to Session
    • Complete the host name above before saving
    • Click “Save”

     

  7. Clone Repo
    • Click “Clone/New” Image button in sourcetree
    • Move to “Clone Repository” Tab
    • Go to Project Home on Gitlab
    • Click “SSH” button and copy url next to the button.
    • Back to SourceTree and paste it to “Source Path/URL” field.
    • Replace its hostname with putty session name you created above.
    • Click “Destination Path” , then source path will be starting to detect repository
    • If Repository Type detected, Choose “Destination Path”
    • Finally,  Click “Clone” Button.

 

  • TroubleShootings
    • Tip: If Repository couldn’t detect, maybe private key is not proper. check out gitlab and sourcetree settings .
      If Error appeared like that
      fatal: Could not read from remote repository.
      Please make sure you have the correct access rights and the repository exists.
      , the causes are that key setting is not proper or proxy things.
    • In case of a cause like that
      Host does not existfatal: Could not read from remote repository.
      Please make sure you have the correct access rights
      and the repository exists.
      , that is why host was not resolved if your proxy blocked.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: