Reputation: 15831
So I want to write a single file that:
cd /d myfolder git pull
But the git variable is not defined in the default cmd in windows, only if I open the git shell icon on the desktop: "C:\Documents and Settings\Administrador\Definições locais\Application Data\GitHub\GitHub.appref-ms" --open-shell
How do I open a cmd with the git shell and cd into a particular folder and the run the pull command, then the window should stay open and let me run other commands if necessary.
Thanks
Upvotes: 1
Views: 198
Reputation: 33203
If you actually install "Git for Windows" (that is the git-1.8.0-preview2012___.exe) rather than the portable one and specify that you want to run from the Windows command prompt it will add the Git\cmd directory to your path so that you can run git from command scripts or the command prompt.
With your portable installation, you can do the same manually -- add the cmd subdirectory to the path. The cmd\git.exe and cmd\gitk.cmd files configure the necessary environment to run the real git command (in bin\git.exe) without adding all the other commands into your search path. This avoids us feeding you different versions of the tools included (perl and tclsh for instance).
Since 1.8.0 the git wrapper command is no longer a cmd script which makes it much simpler to be used in batch / cmd scripts (you no longer have to 'call' it from batch scripts).
Upvotes: 1
Reputation: 1324268
If you have installed GitHub for Windows, you won't be able to use the CLI easily: only the GUI.
Simply extract a portable installation archive of Git (like "PortableGit-1.8.0-preview20121022.7z") wherever you want (since it is a portable installation), and have a script ready to modify your path whenever you need git.
See for instance my gist.
I call (line 30)
call:cleanAddPath PATH "%GITROOT%\bin"
That will make sure my PATH
includes the git I want only once, even if I call my script repeatedly (following "How to keep the value of a variable outside a Windows batch script which uses “delayed expansion local” mode?")
Call that script in any DOS windows, and you are ready to use git commands.
Upvotes: 0
Reputation: 174309
The folder in which you installed GIT needs to be added to the PATH environment variable.
Upvotes: 1