Run multiple GIT commands in one click!

Run multiple GIT commands in one click!

Are you wasting your time in running same set of GIT commands again and again?

We have a solution here. Believe me, it is very simple!

It will help you in running all your commands in a single click. All you have to do is to create a file and add all your commands in the same sequence in which you want to execute. That's it!

Let me help you to create the file.

  1. Open your Notepad and create a new file.
  2. Write all the commands in separate lines and in same order in which you want to execute e.g.
git add .
git commit -m "First commit"
git push 

3. Save the file with .bat extension in the local git project folder e.g. <filename>.bat

4. Make sure to select "All Files" in Save as type while saving the file.

4. Open the Command line interface and point the path to the local git folder.

5. Run following command:

git <filename>.bat

Here it is! Try this and you would love the way this process saves multiple clicks.

Additional Information: Now, you might be thinking that this process will commit all the changes with same commit message. But we have a solution for that too.

  1. Update the commit command in your .bat file to : git commit -m %l and save the file.
  2. Run the .bat file along with the commit message: git <filename>.bat "<your dynamic commit message here>"

FOR WINDOWS ONLY!

Pranshu Taneja

Software Engineer | React.js | Node.js | JavaScript

2 年

Here is an another solution to this https://stackoverflow.com/a/48819157/13914357

Kathryn Grant

Sr. Technical Writer and Instructional Designer

2 年

This looks like a great timesaver! I ran into a couple of issues, though... using the batch file test.bat, when I type "git test.bat" in my git folder, I get the message "git: 'test.bat' is not a git command." And when I run it without "git" at the beginning (in other words, just test.bat), it works, with one exception: I included the command "git commit -m %l" as indicated above to include a dynamic commit message, but when I look at the log, the commit message is just "l"--the message I supplied isn't there. I thought I followed the instructions above to the letter, but I must have missed something :) What do I need to change? Many thanks!

回复

要查看或添加评论,请登录

Harshita Khandelwal的更多文章

社区洞察

其他会员也浏览了