This Post is for admins or users who are new to GIT and want to know how to get started with GIT in PowerShell.
You have landed to right article where without going in details we will learn the important things that needs to be done to get started.
- First thing first is to install the GIT on your machine, here is the link:
https://git-scm.com/download/win
Choose 64bit version under stand alone installer.
Now execute it on your machine and install it with default options (no changes required)
2. Next step is to open PowerShell and install Posh-Git Module.
install-module -Name Posh-Git
3. Once this is installed, we are ready to use git, here are some of the command examples that you can utilize.
Import the module first using Import-Module Posh-Git
- You have the git repository link url and you want to clone it to your machine.
Change directory where you want to clone and use the command
git clone https://git.lab.com:443/Gitrepo/GitRepo.git
- You have made some changes and you want to push them to the branch
First add and commit those changes.
git add .
git commit -m “change has been made” # add the message you want about the change you have made to the script.
Now push the changes to remote
git push -u origin master # branch can be different depending on you are working with
This module is intelligent and will show you the tracking on console itself as you can see change in [master] when we ran the commands.
-
You want to see the changes you have done, you can simply use:
Git show
-
You already have the repo you just want to pull the new changes, as you have guessed command is:
Git Pull
There are many git commands, but I will not show all, I just wanted to provide the idea on how you can get started with GIT using PowerShell.
Thanks for reading …
Tech Wizard