How to use Git and Github on Windows for Beginners (7 steps)

Arison Cao
4 min readJun 20, 2020
Git and Github on Windows

Convention:

  • The source code folder on PC is called Working Repository.
  • The source code folder on Github (repository) is called Remote Repository.

Step 1: Install Git on Windows

Download Git for Windows and install: https://git-scm.com/downloads

Step 2: Create a new Github Repository

Sign in Github account, click account icon at the right corner > Your Repositories

Click Account Icon -> Your repositories

Create a new Repository by clicking the New button. You choose your repository name and should change Public (default) to Private (as the image below).

New Repository options

Copy Repository Link to Clone with Git (create Clone version of Github repository in your PC ) :

Copy Repository Link

Step 3: Clone Github Repository

  • On Windows 10 go to Start Menu -> Git GUI.
  • Click Clone Existing Repository.
  • Past Repository Link copied into Source Location.
  • In Target Directory: To create First_Repository folder in D:/2.Learning/Git. Browse to “D:/2.Learning/Git” -> Open then add “/First_Repository” in the path. If you create First_Repository folder first (with windows explorer) then Browse to it will issue an error.
  • Click Clone -> input username and password of your Github account.
  • In Git Gui, Repository menu -> Explorer Working Copy to open Working Repository which cloned success.
Clone Repository

Step 4: Commit new files with Git Gui

Create new first_file.txt in Working Repository :

Create new file in Working Repository
  • Come back to Git Gui, click Rescan: first_file.txt appears in Unstaged Changes.
  • Click Stage Changed: to prepare to Commit.
  • Add some text into the Commit Message box. Click Commit
Git commit new file

Step 5: Push new file to Github Repository

Go to Github Repository on Web Browser, you will not see the first_file.txt . Because committing only affecting to Working Repository on PC. You have to do Push action to synchronize to the Github repository.

  • In Git Gui, click Push. In the new Push window, leaving everything as default, click Push.
Git push window

Step 6: Commit a modified file

  • Open first_file.txt on windows, input some text and save.
  • In Git Gui, click Rescan will see first_file.txt appear in “Unstaged Changed with Modified, not staged status”.
  • Click Stage Changed.
  • Add some text into the Commit Message box. Click Commit.
  • Click Push.
  • Now, you can check the file on the Github repository to see the changes.

Step 7: Restore the specific file version

If you edit a file and make some errors you can restore a specific file version with Git.

  • In Git Gui go to menu: Repository -> Visualize master’s History.
  • Choose the version you want, Right Click choose Reset master branch to here -> Hard: Reset working tree and index…
  • Now opening first_file.txt in Working Repository, it restored content but Github repository is still not yet.
  • In Git Gui click Push to synchronize to Github.

Notice: if Git Gui issues an error when Pushing, retry Push with check Force Override Existing Branch … in Push window (as image below)

--

--