Skip to content

GitHub and how to work with Open Source in Visual Studio

Kaisinel edited this page Nov 7, 2023 · 2 revisions

What is git?

Git is code versioning system. It supports having a history of all the changes that happened at any given time for files that were placed in it. Git works on both local and remote levels, so you can even use it without any website, just on your local machine.

How do you work with git?

There are many different ways to work with git. Don't be intimidated by all the options that there are. For 95% of all the use cases, basic git commands or tools are good enough and are not hard to get used to.

Git Bash

The most direct way is by using git bash. However, working with git bash requires you to memorize all sorts of different commands and might be intimidating.

TODO: finish

Visual studio

Visual studio with git extensions supports working with git and most common of its' host: github, azure... If you are interested about working with Github in Visual Studio here is a step by step flow:
Gitflow for Visual Studio

Other tools

TODO: add more tools

Git is just 3 areas

Understanding git comes down to understanding how do files move from one place to another. And it's quite simple, because there are 3 places in total!

Working directory

Working directory is your normal directory where all the work happens. It's any folder really and has little to do with git. Git is related to working directory only because there is an index file which stores all status updates.

File statuses

Untracked- A file is not a part of git yet, it does not exist outside your local environment.
Unmodified- A file is being tracked by git, but has no local changes and so can be ignored for now.
Modified- A file has been modified locally. You need to stage files for them to be moved further down the git pipeline.
Staged- A file that is ready to be commited

Staging area

This is the most simple of all the areas. It serves as an intermediate area between git and working directory. Files in staging area are the files that will be commited with the statuses they were added there. You can add all files to staging area using this git command:

git add .

Add moves files from working area to staging area. However, if you changed any of the added files, they are already staged and for their status to be updated again, you need to do the same command again.

Repository

Repository is the last place where files in git end up. It's divided in two areas called local and remote repository.

Local

As mentioned before, files in staging area are ready to be commited. But what is a commit? A commit is a changelist with a message summarising what was changed. Changes that are commited end up in local repository. You can commit the changes with this command:

git commit -m "Meaningful message"

Commit moves files from staging area to local repository

Remote

Remote is just like your local repository, but except it being native to your local machine, it's native to whatever git hosting service you are using. In other words, remote repository has is like local repository of some commit. Like local repository, it holds all the changes in history.

Homework

Create a PR to master of bootcamp for homework 1.

Clone this wiki locally