Technology

What is Git?

Git is Version Control System. A Git repository is a database containing all the information needed to retain and manage the revisions and history of a project.
In Git, a repository retains a complete copy of the entire project throughout its lifetime. However, unlike most other VCSs, the Git repository not only provides a complete working copy of all the files in the repository, but also a copy of the repository itself with which to work.

All of this repository data is stored at the root of your working directory in a hidden subdirectory named .git.

Git Object Types

Blobs
- Each version of a file is represented as a blob. A blob holds a file’s data but does not contain any metadata about the file or even its name.
Trees
- A tree object represents one level of directory information. It records blob identifiers, path names, and a bit of metadata for all the files in one directory.
Commit
- A commit object holds metadata for each change introduced into the repository, including the author, committer, commit date, and log message. Each commit points to a tree object that captures, in one complete snapshot, the state of the repository at the time the commit was performed.

How to get it?

Git can be installed on the most common operating systems like Windows, Mac, and Linux. In fact, Git comes installed by default on most Mac and Linux machines!

Checking for Git

To see if you already have Git installed, open up your terminal application.

Mac

If you're on a Mac, look for a command prompt application called Terminal.

Once you've opened your terminal application, type git version. The output will either tell you which version of Git is installed, or it will alert you that git is an unknown command.

Windows

If you're on a Windows machine, open the windows command prompt or Git Bash.

Once you've opened your terminal application, type git version. The output will either tell you which version of Git is installed, or it will alert you that git is an unknown command.

Install git

If you dont have git, when you need to install it.

Mac

  1. Open the command prompt terminal
  2. Install homebrew
  3. Follow the guide on how to install it
  4. Open the a new command prompt terminal
  5. Once the command output has completed, you can verify the installation by typing: git version

Windows

  1. Download the latest version of git for windows
  2. Once the installer has started, follow the instructions as provided in the Git Setup wizard screen until the installation is complete.
  3. Open the windows command prompt or Git Bash.
  4. Type git version to verify Git was installed

Setup git

You have install git, now you need to set it up.

Setup the username

Open the terminal/windows command prompt/Git Bash and write:

git config --global user.name "name"

You need to connect to your GitHub user. Add your GitHub username here

Setup the email

Open the terminal/windows command prompt/Git Bash and write:

git config --global user.email "email"

Add your GitHub email here

Use Git

Now when we got git, e need to use it, as well.

Make a repo

We now have git on our computer, now it is time to make a repo

  1. Go to github
  2. Make a repo by pressing the new button
  3. Add a name to the repo
  4. Press the button Create repository

Add people to the repo

Let's add people to our repo

  1. Go to your repo
  2. Go to settings
  3. Go to manage access
  4. Press the button add people
  5. Search after the person(s) you can to work with
  6. Press the button Select a collaborator above

Clone the repo to your computer

We now have git on our computer, now it is time to clone it

  1. Make a folder on your computer (call it git, so you know it is a collection of your git repos)
  2. Open the terminal/windows command prompt/Git Bash and write cd (remember space) and drag and drop the folder git
  3. Press enter
  4. Go to github and find the repo you want on your local computer
  5. Press the button Code
  6. Copy the code to your repo. It could be https://github.com/Dominoeffekten/basic.git
  7. Go to the terminal/windows command prompt/Git Bash
  8. Write git clone https://github.com/Dominoeffekten/basic.git
  9. Press enter
  10. Open the git folder and see your repo in there

Upload the changes

You have now cloned the repo, but you have added some files, and want them to be online

  1. Open the terminal/windows command prompt/Git Bash and write cd (remember space) and drag and drop the repo folder
  2. Press enter
  3. Write git status (to check if you have made any changes and if they are staged)
  4. Press enter
  5. Write git add .
  6. Press enter
  7. Write git commit -m "I added some files"
  8. Press enter
  9. Write git push
  10. Press enter

Download the changes

If your teamsmates have made some changes and you want them on your computer

  1. Open the terminal/windows command prompt/Git Bash and write cd (remember space) and drag and drop the repo folder
  2. Press enter
  3. Write git status (to check if you have made any changes and if they are staged)
  4. Press enter
  5. Write git pull
  6. Press enter

If there was red marks when you wrote git status

  1. Write git add .
  2. Press enter
  3. Write git commit -m "I added some files"
  4. Press enter
  5. Write git push
  6. Press enter

GitKraken

You can also use GitKraken. It is the same, but visuel

What is GitKraken?