Making commits simpler in Git using PowerShell

Question:

I’m using Git and being an old dude, I prefer to punch my will on the keyboard rather than send a rodent on a clicky trip. So, usually when I finish off my work, I’ll go something like this in the console.

git add .
git commit –message “Cure for cancer (or so it feels like)”
git push

I could have a static script doing that but, regrettably, not every day’s contribution is as awesome as the cure for cancer, so I’d need to have a script that takes a parameter (and if none is provided, it could be substituted by e.g. “donkey“.

How would I go about creating such script?

I’ve googlearched it a bit but got a lot of different suggestions and at my competence level with PowerShell, I have the fear that I’ll screw something up really badly. Creating a batch file would be an option but now that I do the magic in PowerShell, I fell I ought to learn it a bit more. As long as we can keep the learning curve not very steep, hehe.

Suggestions?

Answer:

To extend Sergiu Vidrascu’s answer, you can wrap the code in a function :

and add it to your profile so that the function is available in every Powershell session you start.

In a PS console, run notepad $profile, paste the code in the notepad window and save the file, for instance (then use a new console window to load the new profile).

You can learn more about Powershell profiles here. Setting the scripting rights is described here.

Source:

Making commits simpler in Git using PowerShell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply