Setup Git on Windows 10

rsashna
3 min readOct 12, 2020

It’s that wonderful setup time again ._.

Photo by Jay Prajapati on Unsplash

Step 0: make sure you didn’t already install it

In Command Prompt:

git --version

if ‘git’ is not recognized, you dont have it installed and can proceed, otherwise it will return a version number and I guess you’re all done with this setup article

Step 1: downloading git

Choose the correct system version from here https://git-scm.com/download/win
and install it

Step 2: setup git accounts

Launch the git bash application, and check the directory is at the user’s folder with pwd. (Doing a git — version should return a version number now).

git config --global user.name myGitUserNamegit config --global user.email myEmailAddr@email.com

Doing >git config user.name should return the right user name now, and same for >git config user.email

Step 3 (for Cloning): clone an existing repository (this will create a local copy of a repository onto your computer which is already on GitHub or another git hosting site)

Go to the place where you want to create this copy (either through file explorer or through the git bash terminal).

Now you need to ‘clone’ the repository you wanted with the repo link. This link is found on the top right corner of the repository’s page (click Code or Clone button). In the git bash terminal, type in the clone command with the copied link:

git clone https://github.com/someOnesUserName/aRepositoryName.git

Note: Selecting the ‘https:’ link will require you to sign in from the command line each time you want to pull or push changes. Selecting the ‘ssh:’ link will not ask to sign in each time, but you will have to create a matching ssh key from the repo and copy it into your root files (process not shown here).

Step 3 (for Creating): Creating a new local repository and pushing it up to Github

To create a new repo in Github from your computer’s existing code base, first create a new empty repository on Github

Copy the repo link from the top right of the new repository page

Then back on your local machine, use bash to go to the main folder that is holding the code you want to push up, initialize the folder with:

git init

This will create the hidden .git folder to help during pushes and pulls. Now we have to add the link to the ‘remote’ repository by adding the location of it (this the repo link you coppied). Use:

git remote add origin https://userNameHere/theNameYouGaveTheRepo.git

Note: Selecting the ‘https:’ link will require you to sign in from the command line each time you want to pull or push changes. Selecting the ‘ssh:’ link will not ask to sign in each time, but you will have to create a matching ssh key from the repo and copy it into your root files (process not shown here).

If you do a git status the files that are on your computer should be listed in red under ‘Untracked files.’ Meaning they need to be added. Use git add . if you want to add all the files (the . means all), otherwise you can specify the name of the files with git add nameOfFile

git add .

Add a ‘commit’ message to describe what the code is about or what you modified:

git commit -m "This is some work I did"

and push up the file by typing git push and then copy pasting the prompt that shows up git push — set-upstream origin master

git push

They will ask for a username and password verification if this is your first push or if you used the https link

Step 4: using git

At this point you should be able to do all the branching and editing and coding etc. on the cloned repo. Here’s a link to a git cheatsheet with most of the main commands: https://education.github.com/git-cheat-sheet-education.pdf

And now Windows should be ready for all your version control desires :)

Reffs:

https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup

--

--