Honchar Denys
Honchar Denys

Reputation: 1508

Git script on windows

Before git for windows was upgraded to version 2.x.x I was running scripts by simply creating a file with name pull and inside it I was putting something like git pull origin master. It was running normally, after I made format and install latest version of git it don't support that scripts any more. The error I have is: bash: pull: command not found. I have tried to add .bat and .sh to those files, and that didn't work out.

update:

Now i have in the file pull content:

#!/bin/bash
git pull origin master

To run that script i need to execute on terminal ./pull. Can i somehow use that script without ./?

Upvotes: 0

Views: 141

Answers (2)

VonC
VonC

Reputation: 1323115

What does work in Windows is creating a script called git-xxx (no extension).
For instance: git-mypull.

In that script, you can write a regular bash script, starting with #!/bin/bash.
It will be execute in the mingw-64 shell session which comes with the latest Git for Windows 2.5.x.

You call that script with git xxx (note the space): git mypull.


Now I have in the file pull content:

#!/bin/bash
git pull origin master

To run that script I need to execute on terminal ./pull.
Can I somehow use that script without ./?

Yes, as long as pull is in one of the folders referenced by echo %PATH%.
Then a simple pull would work.

Upvotes: 1

Honchar Denys
Honchar Denys

Reputation: 1508

That did the trick: printf '#!/bin/bash\ngit pull origin master' > ~/bin/pull . I pasted generator code, just in case. it could be just file in the folder ~/bin in your user folder. Before you run that script, you should create folder bin. Also you can modify scripts to file you need. On the script i have pasted, when you write in terminal pull it start git pull origin master

Upvotes: 1

Related Questions