Using git on Windows: Difference between revisions

From Bitpost wiki
No edit summary
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
Git in Windows is currently (11/2011) in a sorry state of affairs.  This is mainly due to msysgit being the "official git Windows client" and being a big bloated sac of crap.
Git in Windows is currently (11/2011) in a sorry state of affairs.  This is mainly due to msysgit being the "official git Windows client" and being a big bloated sac of crap. Egit via Eclipse is a nice gui alternative, and TortoiseGit may get polished enough some dayBut we want to use it from Windows batch files.  Enough whining, let's do it.
 
Enough whiningLet's set it up so we can use it from Windows batch files.


* Install msysgit
* Install msysgit
** Tell it to use plink
** Tell it to use external plink for ssh
** You want it to be reachable from the Windows path, select this option during the install (or add it yourself)
* Make sure putty is installed with a valid ssh session, and remember to fire up pageant with your ssh key imported before using git
* Make sure putty is installed with a valid ssh session, and remember to fire up pageant with your ssh key imported before using git
* Install notepad++, a nice reliable simple Windows editor.
* Install notepad++, a nice reliable simple Windows editor.
** Set up a batch file to run notepad++ – make sure that the batch file does not have any spaces in the path to it – I named mine [c:\npp.bat]:
** Set up a batch file to run notepad++ – make sure that the batch file does not have any spaces or quotes in the path to it – I named mine [c:\npp.bat].
<pre><code>#!/bin/sh
<pre>#!/bin/sh
"C:/Michae~1/System~1/npp/notepad++.exe" -multiInst "$*"</code></pre>
"C:/Michae~1/System~1/npp/notepad++.exe" -multiInst "$*"</pre>
** Note that I avoided spaces in the path.  I also found that a single quote in the path will screw up msysgit.
* From a command prompt, configure git to use the editor as follows:
** Set the git editor up as follows (using a msysgit Git Prompt Here):
<pre>git config --global core.editor C:/npp.bat</pre>
<pre><code>git config --global core.editor C:/npp.bat</code></pre>
* Set up a scripts directory in your Windows path.  Mine is: C:\Michael's Data\development\thedigitalage\hangthedj\windows_scripts
* Set up a scripts directory in your Windows path.  Mine is: C:\Michael's Data\development\thedigitalage\hangthedj\windows_scripts
* Set up an "update" script like this:
* Set up an "update" script like this:
<pre><code>@echo off
<pre>@echo off
c:
c:
set BASEDIR=C:\Michael's Data\development
set BASEDIR=C:\Michael's Data\development
Line 39: Line 37:
cd %BASEDIR%/Reusable
cd %BASEDIR%/Reusable
call git pull
call git pull
</code></pre>
</pre>
* Set up a "commit" script like this:
* Set up a "commit" script like this:
<pre><code>@echo off
<pre>@echo off
c:
c:
set BASEDIR=C:\Michael's Data\development
set BASEDIR=C:\Michael's Data\development
Line 59: Line 57:
echo --- Reusable
echo --- Reusable
cd %BASEDIR%/Reusable && call git commit -a && call git push
cd %BASEDIR%/Reusable && call git commit -a && call git push
</code></pre>
</pre>
* You can call your scripts to get the job done.  You can also use git right from any command prompt now.  Yay!

Latest revision as of 00:15, 26 November 2011

Git in Windows is currently (11/2011) in a sorry state of affairs. This is mainly due to msysgit being the "official git Windows client" and being a big bloated sac of crap. Egit via Eclipse is a nice gui alternative, and TortoiseGit may get polished enough some day. But we want to use it from Windows batch files. Enough whining, let's do it.

  • Install msysgit
    • Tell it to use external plink for ssh
    • You want it to be reachable from the Windows path, select this option during the install (or add it yourself)
  • Make sure putty is installed with a valid ssh session, and remember to fire up pageant with your ssh key imported before using git
  • Install notepad++, a nice reliable simple Windows editor.
    • Set up a batch file to run notepad++ – make sure that the batch file does not have any spaces or quotes in the path to it – I named mine [c:\npp.bat].
#!/bin/sh
"C:/Michae~1/System~1/npp/notepad++.exe" -multiInst "$*"
  • From a command prompt, configure git to use the editor as follows:
git config --global core.editor C:/npp.bat
  • Set up a scripts directory in your Windows path. Mine is: C:\Michael's Data\development\thedigitalage\hangthedj\windows_scripts
  • Set up an "update" script like this:
@echo off
c:
set BASEDIR=C:\Michael's Data\development

set EDITOR=C:/npp.bat

echo --- log
cd %BASEDIR%/thedigitalage/log
call git pull
echo --- hangthedj
cd %BASEDIR%/thedigitalage/hangthedj
call git pull
echo --- ampache_tda
cd %BASEDIR%/thedigitalage/ampache_tda/3.5
call git pull
echo --- website
cd %BASEDIR%/thedigitalage/website
call git pull
echo --- philanthropy_engine
cd %BASEDIR%/thedigitalage/philanthropy_engine
call git pull
echo --- Reusable
cd %BASEDIR%/Reusable
call git pull
  • Set up a "commit" script like this:
@echo off
c:
set BASEDIR=C:\Michael's Data\development

set EDITOR=C:/npp.bat

echo --- log
cd %BASEDIR%/thedigitalage/log && call git commit -a -m "Another log commit, from wimpy-windows" && call git push
echo --- hangthedj
cd %BASEDIR%/thedigitalage/hangthedj && call git commit -a && call git push
echo --- ampache_tda
cd %BASEDIR%/thedigitalage/ampache_tda/3.5 && call git commit -a && call git push
echo --- website
cd %BASEDIR%/thedigitalage/website && call git commit -a && call git push
echo --- philanthropy_engine
cd %BASEDIR%/thedigitalage/philanthropy_engine && call git commit -a && call git push
echo --- Reusable
cd %BASEDIR%/Reusable && call git commit -a && call git push
  • You can call your scripts to get the job done. You can also use git right from any command prompt now. Yay!