Git Tutorial

This is a code example

Setup git identity

WIP ssh keys, connect github, email, username...

Essentials

  1. Q: What is git?
  2. A: Is a distributed version control system. The place where all code is stored is called a repository, in the context of git distributed system every computer that has downloaded the repository has a full copy, that means you could do work without being connected to a centralized server.

  3. Q: Why is it needed?
  4. A: Because tracking changes to files is very difficult and it's difficult as a solo programmer, it's even harder when you're working in a team.

  5. Q: How is the installation/usage?
  6. A: Installation varies depending the OS, remember to install git gitbash in Windows

  7. Q: What is the role of gitlab/github/bitbucket?
  8. A: Is another place to have another copy of the repository, particularly one that it is accessible to any system usually they're used as the master copy of the repository. It is not necessary but it can be quite convinient.

  9. Q: How can you clone and pull repositories?
  10. A: git clone [email protected]:engineer-man/piston.git

  11. Q: How can you check the status of the repository?
  12. A: Typing git status

  13. Q: How can you initialize a repository?
  14. A: There are multiple ways, if you want to create a new repo git init inside the project if you want to create a new project git init <projectName>

  15. Q: How can you acquire the changes made to a repo?
  16. A: git pull

Common usage commands

Command Use
git clone {repoURL}

When you clone, you download the repo and you setup your origin.

git remote

git remote -v show us what our origins are. There is one for fetch and one for push

If you're making a repo from scratch you need to add your own origin you can do it with the command git init add origin

git status Tells us, what branch we're one and show us what files in the repository have changed and are ready to be commited
git branch, checkout
git add, commit
git push, pull, fetch
git merge
git log
git diff
git clone, remote