Skip to content

Instantly share code, notes, and snippets.

@gabrielStanovsky
Forked from saifun/git_tutorial.md
Last active November 30, 2021 13:54
Show Gist options
  • Save gabrielStanovsky/c307dfc9dd7f04377804a80f5b2f62b3 to your computer and use it in GitHub Desktop.
Save gabrielStanovsky/c307dfc9dd7f04377804a80f5b2f62b3 to your computer and use it in GitHub Desktop.

Revisions

  1. gabrielStanovsky revised this gist Nov 30, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -133,6 +133,8 @@ When working on a project with Git, you want to follow a workflow that will help

    * **Keep a clean `git status` at all times**. Don't conform with having tons of files in there that you don't remember where they belong or where they came from. Maintain a strong `.gitignore` file to achieve this. `git status` should clearly tell you what you're working on right now, and should be clean after every commit and push.

    * \[TIP\] Use a git-aware shell (e.g., fish), to display the branch that you're on and whether you have untracked changes, etc.

    * \[TIP\] If you switch a computer and want to fetch some new branches from the origin, use `git pull`. Then you may checkout to the branch you worked on before, and continue from the same place.

    ## ⚠️ Danger zone ⚠️
  2. gabrielStanovsky revised this gist Nov 30, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -131,7 +131,7 @@ When working on a project with Git, you want to follow a workflow that will help

    * Merge the PR, checkout to `master`, pull the changes, and so on (back to step 3 - checkout to a new branch for the next feature).

    * Keep a clean `git status` at all times. Don't conform with having tons of files in there that you don't remember where they belong or where they came from. Maintain a strong `.gitignore` file to achieve this. `git status` should clearly tell you what you're working on right now, and should be clean after every commit and push.
    * **Keep a clean `git status` at all times**. Don't conform with having tons of files in there that you don't remember where they belong or where they came from. Maintain a strong `.gitignore` file to achieve this. `git status` should clearly tell you what you're working on right now, and should be clean after every commit and push.

    * \[TIP\] If you switch a computer and want to fetch some new branches from the origin, use `git pull`. Then you may checkout to the branch you worked on before, and continue from the same place.

  3. gabrielStanovsky revised this gist Nov 30, 2021. 1 changed file with 35 additions and 0 deletions.
    35 changes: 35 additions & 0 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,41 @@
    # Git Tutorial
    Git is an awesome tool :smile:

    <!-- START doctoc generated TOC please keep comment here to allow auto update -->
    <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
    **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

    - [Git Tutorial](#git-tutorial)
    - [Motivation](#motivation)
    - [Backup and Accessibility](#backup-and-accessibility)
    - [Version control](#version-control)
    - [Mistakes happen](#mistakes-happen)
    - [Branching](#branching)
    - [Some Important Terms](#some-important-terms)
    - [General](#general)
    - [Repository](#repository)
    - [Fork](#fork)
    - [Origin](#origin)
    - [Workflow](#workflow)
    - [Branch](#branch)
    - [Commit](#commit)
    - [Upstream](#upstream)
    - [Merging](#merging)
    - [Pull Request (PR)](#pull-request-pr)
    - [Rebase](#rebase)
    - [Healthy Workflow](#healthy-workflow)
    - [Working with SSH](#working-with-ssh)
    - [What should we track with Git?](#what-should-we-track-with-git)
    - [Special files](#special-files)
    - [.gitignore](#gitignore)
    - [README.md](#readmemd)
    - [LICENSE.md](#licensemd)
    - [Git working cycle](#git-working-cycle)
    - [⚠️ Danger zone ⚠️](#-danger-zone-)
    - [Useful Git Commands](#useful-git-commands)

    <!-- END doctoc generated TOC please keep comment here to allow auto update -->

    ## Motivation
    ### Backup and Accessibility
    Lost files could be recovered from the server.
  4. gabrielStanovsky revised this gist Nov 30, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -100,7 +100,7 @@ When working on a project with Git, you want to follow a workflow that will help

    * \[TIP\] If you switch a computer and want to fetch some new branches from the origin, use `git pull`. Then you may checkout to the branch you worked on before, and continue from the same place.

    ## ⚠️ danger zone ⚠️
    ## ⚠️ Danger zone ⚠️

    <img width="300" alt="image" src="https://imgs.xkcd.com/comics/git.png">

  5. gabrielStanovsky revised this gist Nov 30, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -100,7 +100,7 @@ When working on a project with Git, you want to follow a workflow that will help

    * \[TIP\] If you switch a computer and want to fetch some new branches from the origin, use `git pull`. Then you may checkout to the branch you worked on before, and continue from the same place.

    ⚠️ danger zone ⚠️
    ## ⚠️ danger zone ⚠️

    <img width="300" alt="image" src="https://imgs.xkcd.com/comics/git.png">

  6. gabrielStanovsky revised this gist Nov 30, 2021. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -100,6 +100,16 @@ When working on a project with Git, you want to follow a workflow that will help

    * \[TIP\] If you switch a computer and want to fetch some new branches from the origin, use `git pull`. Then you may checkout to the branch you worked on before, and continue from the same place.

    ⚠️ danger zone ⚠️

    <img width="300" alt="image" src="https://imgs.xkcd.com/comics/git.png">

    Git has commands that let you mess up with the structure of the tree, erase versions, change HEAD pointers and more. You'll see some (dubious) advice online directing you to do this when running into problems, such as accidently commiting a file. Gabi is strongly against these solutions, especially if you're not sure what you're doing. Often just pushing a new version of the file resolves issues much more cleanly (what do we care if the tree is ``contaminated''?). @Saifun has a different view on this?
    In any case, you should definitely approach with utmost caution when seeing these commands:

    * `git reset`
    * @Saifun, more?


    ## Useful Git Commands
    Some of the explanations are taken from [here](https://education.github.com/git-cheat-sheet-education.pdf). You may find this guide useful.
    @@ -126,3 +136,5 @@ Some of the explanations are taken from [here](https://education.github.com/git-

    <img width="300" alt="image" src="https://user-images.githubusercontent.com/44426592/143867017-3eaf552d-1dde-46c5-90e9-f23ca447499d.png">



  7. gabrielStanovsky revised this gist Nov 30, 2021. 1 changed file with 18 additions and 6 deletions.
    24 changes: 18 additions & 6 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -38,11 +38,20 @@ The conventional name for the primary version of a repository, in the remote ser
    A branch is a version of the repository that diverges from the main working project.
    #### Commit
    A commit is a snapshot of the repo at a certain time.
    #### Pull Request (PR)
    A PR is a request for merging all commits from one branch to another, enabling multiple colaborators to discuss the proposed changes before integrating them into the official project.
    <img width="500" alt="image" src="https://user-images.githubusercontent.com/44426592/143865631-2879b244-b74a-4c6a-9911-3597acf3c834.png">
    #### Upstream
    An upstream branch is the branch tracked on the remote repository by the local branch
    #### Merging
    At some point we do want to update code bases between branches, this is called _merging_ in git terminology.
    Git tracks changes per line, and compares three versions when merging to track what should be in the merged version. (@TODO: what are the names of the different versions, I always confuse BASE and the other ones, Also, maybe add screenshot of managing conflicts)
    It'll try to do the most merges automatically, but will present the user with _conflicts_ when two versions of the file have changed the same line. This is called conflict, and need to be resolved manually.

    There are several types of merging, as elaborated below.

    ##### Pull Request (PR)
    A PR is a request for merging all commits from one branch to another, enabling multiple colaborators to discuss the proposed changes before integrating them into the official project. While this could be done between any two branches, the term is generally used when finishing a feature and merging that branch upstream.
    <img width="500" alt="image" src="https://user-images.githubusercontent.com/44426592/143865631-2879b244-b74a-4c6a-9911-3597acf3c834.png">
    ##### Rebase
    Merging from an upstream branch into a feature branch. This is usally done when another feature has finished developement while working on the current feature.


    ## Healthy Workflow
    @@ -67,17 +76,17 @@ TODO

    ### Git working cycle
    When working on a project with Git, you want to follow a workflow that will help you to enjoy your work:
    * \[OPT\]\[ONCE\] When working on an opensource project, fork it.
    * \[RECOMMENDED\]\[ONCE\] When working on an opensource project, fork it. **Especially recommended if there's any chance you'd like to change something in the codebase**.

    * \[ONCE\] Clone the repo

    * **Never** commit to `master` - always checkout to another branch before you start writting code. It's recommended to choose meaningful names for branches, as the name of the PR will be the same as the branch name. The convention is `<purpose>/<name>`, for example `feature/<name>`.

    * \[OPT\] If you want to work on another feature based on the current one, before merging it to master, checkout to another branch from the current one.

    * After every significant change you make, commit your changes. Always use a meaningful commit message.
    * After every change you make or at the end of a work day, commit your changes. Always use a meaningful commit message.

    * Push your changes to the branch you're working on in the origin
    * After every commit, push your changes to the branch you're working on in the origin to backup your work. **Pushing shouldn't be something dangerous, or that has side-effects implications**. If it does in your setup, you should revisit your configuration.

    * If you have tests, make sure to run them.

    @@ -87,8 +96,11 @@ When working on a project with Git, you want to follow a workflow that will help

    * Merge the PR, checkout to `master`, pull the changes, and so on (back to step 3 - checkout to a new branch for the next feature).

    * Keep a clean `git status` at all times. Don't conform with having tons of files in there that you don't remember where they belong or where they came from. Maintain a strong `.gitignore` file to achieve this. `git status` should clearly tell you what you're working on right now, and should be clean after every commit and push.

    * \[TIP\] If you switch a computer and want to fetch some new branches from the origin, use `git pull`. Then you may checkout to the branch you worked on before, and continue from the same place.


    ## Useful Git Commands
    Some of the explanations are taken from [here](https://education.github.com/git-cheat-sheet-education.pdf). You may find this guide useful.
    * `git init` - initialize an existing directory as a Git repository
  8. gabrielStanovsky revised this gist Nov 30, 2021. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -54,12 +54,17 @@ The recommended way is using SSH. It is easy to configure, and once you counfigu
    ### What should we track with Git?
    GitHub has a strict file size limit of 100MB (Files that you add to a repository via a browser are limited to 25MB per file. You can add larger files, up to 100MB each, via the command line). This is not an issue if you are just uploading lines of codes, but you shouldn't upload data and binaries to GitHub (there are some ways to overcome this restriction, but it is considered bad practice).

    ### .gitignore + README.md
    In addition, git stores incremental changes of files, and is great for comparing and tracking changes line-by-line. This doesn't work as effectively for binaries or trained models, etc. For that purpose, we should use an gdrive, dropbox, etc.

    ### Special files
    #### .gitignore
    Sometimes you may not want to track all your files with Git. This includes some local caches, IDE automatically generated files, some local configurations etc.
    Configuring a `.gitignore` makes Git ignore these files and not showing them during staging. GitHub has a feature that generates a `.gitignore` when creating a repo.
    #### README.md
    A readme file is the place to write some information about the project using a free language. These include installation instructions, usage instructions, and any other useful information for someone that views the repo without any previous knowledge. GitHub knows to create a fun preview from this file. The file itself is written in [Markdown](https://www.markdownguide.org/basic-syntax/).
    ### LICENSE.md
    TODO

    ### Git working cycle
    When working on a project with Git, you want to follow a workflow that will help you to enjoy your work:
    * \[OPT\]\[ONCE\] When working on an opensource project, fork it.
  9. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ Working with HTTP was probably simpler until Github changed the privacy conditio
    The recommended way is using SSH. It is easy to configure, and once you counfigure it you don't need to think about it anymore. To use SSH you need to generate a key, and add it to GitHub, as explained [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).

    ### What should we track with Git?
    GitHub has a strict file size limit of 100MB (Files that you add to a repository via a browser are limited to 25MB per file. You can add larger files, up to 100MB each, via the command line). This is not an issue if you are just uploading lines of codes, but you shouldn't upload data and binaries to GitHub (however, it is good to know that there are many ways to overcome the restriction).
    GitHub has a strict file size limit of 100MB (Files that you add to a repository via a browser are limited to 25MB per file. You can add larger files, up to 100MB each, via the command line). This is not an issue if you are just uploading lines of codes, but you shouldn't upload data and binaries to GitHub (there are some ways to overcome this restriction, but it is considered bad practice).

    ### .gitignore + README.md
    #### .gitignore
  10. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -50,8 +50,10 @@ An upstream branch is the branch tracked on the remote repository by the local b
    There are two ways to work with Github - HTTP and SSH.
    Working with HTTP was probably simpler until Github changed the privacy conditions and decided to add personal access tokens with an expiration date. An explanation about token creation could be found [here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token).
    The recommended way is using SSH. It is easy to configure, and once you counfigure it you don't need to think about it anymore. To use SSH you need to generate a key, and add it to GitHub, as explained [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).

    ### What should we track with Git?
    Content...
    GitHub has a strict file size limit of 100MB (Files that you add to a repository via a browser are limited to 25MB per file. You can add larger files, up to 100MB each, via the command line). This is not an issue if you are just uploading lines of codes, but you shouldn't upload data and binaries to GitHub (however, it is good to know that there are many ways to overcome the restriction).

    ### .gitignore + README.md
    #### .gitignore
    Sometimes you may not want to track all your files with Git. This includes some local caches, IDE automatically generated files, some local configurations etc.
  11. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -91,15 +91,19 @@ Some of the explanations are taken from [here](https://education.github.com/git-
    * `git checkout -b <branch-name>` - create a new branch at the current commit
    * `git status` - show modified files in working directory
    <img width="300" alt="image" src="https://user-images.githubusercontent.com/44426592/143866404-c2529469-8231-44d1-93f7-5d760bc3e308.png">

    * `git add` - add a file as it looks now to the next commit
    * `git commit -m "<message>"` - commit the staged changes with the specified commit message
    * `git diff [--staged]` - shows the diff of the changed that are not staged (`--staged` shows diff for staged but not commited files)

    <img width="300" alt="image" src="https://user-images.githubusercontent.com/44426592/143866492-20d92d56-4c5d-4b10-ad66-bd475336b46c.png">

    * `git pull [origin <branch>]` - fetch and merge commits from the remote branch
    * `git push [origin <branch>, -u <upstream>]` - transmit local branch commits to the remote repository branch
    * `git merge` - merge a remote branch into the current branch
    * `git rm; git mv` - delete/move a file and stage the removal for commit
    * `git stash [pop]` - save modified and staged changes, (`pop` adds to the current branch the top of stash stack)
    * `git log` - show the commit history for the currently active branch

    <img width="300" alt="image" src="https://user-images.githubusercontent.com/44426592/143867017-3eaf552d-1dde-46c5-90e9-f23ca447499d.png">

  12. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 11 additions and 11 deletions.
    22 changes: 11 additions & 11 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -60,27 +60,27 @@ Configuring a `.gitignore` makes Git ignore these files and not showing them dur
    A readme file is the place to write some information about the project using a free language. These include installation instructions, usage instructions, and any other useful information for someone that views the repo without any previous knowledge. GitHub knows to create a fun preview from this file. The file itself is written in [Markdown](https://www.markdownguide.org/basic-syntax/).
    ### Git working cycle
    When working on a project with Git, you want to follow a workflow that will help you to enjoy your work:
    \[OPT\]\[ONCE\] When working on an opensource project, fork it.
    * \[OPT\]\[ONCE\] When working on an opensource project, fork it.

    \[ONCE\] Clone the repo
    * \[ONCE\] Clone the repo

    **Never** commit to `master` - always checkout to another branch before you start writting code. It's recommended to choose meaningful names for branches, as the name of the PR will be the same as the branch name. The convention is `<purpose>/<name>`, for example `feature/<name>`.
    * **Never** commit to `master` - always checkout to another branch before you start writting code. It's recommended to choose meaningful names for branches, as the name of the PR will be the same as the branch name. The convention is `<purpose>/<name>`, for example `feature/<name>`.

    \[OPT\] If you want to work on another feature based on the current one, before merging it to master, checkout to another branch from the current one.
    * \[OPT\] If you want to work on another feature based on the current one, before merging it to master, checkout to another branch from the current one.

    After every significant change you make, commit your changes. Always use a meaningful commit message.
    * After every significant change you make, commit your changes. Always use a meaningful commit message.

    Push your changes to the branch you're working on in the origin
    * Push your changes to the branch you're working on in the origin

    If you have tests, make sure to run them.
    * If you have tests, make sure to run them.

    When you finish working on a feature, open a pull request to `master`. If you are working with someone else on the project, ask for a review and fix the code according to the comments before merging.
    * When you finish working on a feature, open a pull request to `master`. If you are working with someone else on the project, ask for a review and fix the code according to the comments before merging.

    \[OPT\] If you have conflicts, pull the changes from the branch you want to merge to, and solve them. Then commit the changes.
    * \[OPT\] If you have conflicts, pull the changes from the branch you want to merge to, and solve them. Then commit the changes.

    Merge the PR, checkout to `master`, pull the changes, and so on (back to step 3 - checkout to a new branch for the next feature).
    * Merge the PR, checkout to `master`, pull the changes, and so on (back to step 3 - checkout to a new branch for the next feature).

    \[TIP\] If you switch a computer and want to fetch some new branches from the origin, use `git pull`. Then you may checkout to the branch you worked on before, and continue from the same place.
    * \[TIP\] If you switch a computer and want to fetch some new branches from the origin, use `git pull`. Then you may checkout to the branch you worked on before, and continue from the same place.

    ## Useful Git Commands
    Some of the explanations are taken from [here](https://education.github.com/git-cheat-sheet-education.pdf). You may find this guide useful.
  13. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -61,15 +61,25 @@ A readme file is the place to write some information about the project using a f
    ### Git working cycle
    When working on a project with Git, you want to follow a workflow that will help you to enjoy your work:
    \[OPT\]\[ONCE\] When working on an opensource project, fork it.

    \[ONCE\] Clone the repo

    **Never** commit to `master` - always checkout to another branch before you start writting code. It's recommended to choose meaningful names for branches, as the name of the PR will be the same as the branch name. The convention is `<purpose>/<name>`, for example `feature/<name>`.

    \[OPT\] If you want to work on another feature based on the current one, before merging it to master, checkout to another branch from the current one.

    → After every significant change you make, commit your changes. Always use a meaningful commit message.

    → Push your changes to the branch you're working on in the origin

    → If you have tests, make sure to run them.

    → When you finish working on a feature, open a pull request to `master`. If you are working with someone else on the project, ask for a review and fix the code according to the comments before merging.

    \[OPT\] If you have conflicts, pull the changes from the branch you want to merge to, and solve them. Then commit the changes.

    → Merge the PR, checkout to `master`, pull the changes, and so on (back to step 3 - checkout to a new branch for the next feature).

    \[TIP\] If you switch a computer and want to fetch some new branches from the origin, use `git pull`. Then you may checkout to the branch you worked on before, and continue from the same place.

    ## Useful Git Commands
  14. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 12 additions and 3 deletions.
    15 changes: 12 additions & 3 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -59,9 +59,18 @@ Configuring a `.gitignore` makes Git ignore these files and not showing them dur
    #### README.md
    A readme file is the place to write some information about the project using a free language. These include installation instructions, usage instructions, and any other useful information for someone that views the repo without any previous knowledge. GitHub knows to create a fun preview from this file. The file itself is written in [Markdown](https://www.markdownguide.org/basic-syntax/).
    ### Git working cycle
    * Branch per feature + how to sync from different computers + when should I open a new branch and how (where to branch from)?
    * Working with PRs
    * Multiple contributors projects
    When working on a project with Git, you want to follow a workflow that will help you to enjoy your work:
    \[OPT\]\[ONCE\] When working on an opensource project, fork it.
    \[ONCE\] Clone the repo
    **Never** commit to `master` - always checkout to another branch before you start writting code. It's recommended to choose meaningful names for branches, as the name of the PR will be the same as the branch name. The convention is `<purpose>/<name>`, for example `feature/<name>`.
    \[OPT\] If you want to work on another feature based on the current one, before merging it to master, checkout to another branch from the current one.
    → After every significant change you make, commit your changes. Always use a meaningful commit message.
    → Push your changes to the branch you're working on in the origin
    → If you have tests, make sure to run them.
    → When you finish working on a feature, open a pull request to `master`. If you are working with someone else on the project, ask for a review and fix the code according to the comments before merging.
    \[OPT\] If you have conflicts, pull the changes from the branch you want to merge to, and solve them. Then commit the changes.
    → Merge the PR, checkout to `master`, pull the changes, and so on (back to step 3 - checkout to a new branch for the next feature).
    \[TIP\] If you switch a computer and want to fetch some new branches from the origin, use `git pull`. Then you may checkout to the branch you worked on before, and continue from the same place.

    ## Useful Git Commands
    Some of the explanations are taken from [here](https://education.github.com/git-cheat-sheet-education.pdf). You may find this guide useful.
  15. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -52,8 +52,12 @@ Working with HTTP was probably simpler until Github changed the privacy conditio
    The recommended way is using SSH. It is easy to configure, and once you counfigure it you don't need to think about it anymore. To use SSH you need to generate a key, and add it to GitHub, as explained [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).
    ### What should we track with Git?
    Content...
    ### .gitignore + README
    Content...
    ### .gitignore + README.md
    #### .gitignore
    Sometimes you may not want to track all your files with Git. This includes some local caches, IDE automatically generated files, some local configurations etc.
    Configuring a `.gitignore` makes Git ignore these files and not showing them during staging. GitHub has a feature that generates a `.gitignore` when creating a repo.
    #### README.md
    A readme file is the place to write some information about the project using a free language. These include installation instructions, usage instructions, and any other useful information for someone that views the repo without any previous knowledge. GitHub knows to create a fun preview from this file. The file itself is written in [Markdown](https://www.markdownguide.org/basic-syntax/).
    ### Git working cycle
    * Branch per feature + how to sync from different computers + when should I open a new branch and how (where to branch from)?
    * Working with PRs
  16. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 22 additions and 22 deletions.
    44 changes: 22 additions & 22 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -1,27 +1,6 @@
    # Git Tutorial
    Git is an awesome tool :smile:

    ## Some Important Terms
    Let's start with the definition of some important terms that are used to create the Git world.
    ### General
    #### Repository
    A repository ("repo") is a directory that stores the content of a project, and some additional metadata. The repo stores the files themselves, the versions of those files, commits, deletions, and more.
    <img style="float: right;" width="500" alt="image" src="https://user-images.githubusercontent.com/44426592/143865768-92f3dec4-3d94-4f71-a8a0-12ccfb3fcee1.png">
    #### Fork
    A fork is a copy of a repository at a certain point at time.
    #### Origin
    The conventional name for the primary version of a repository, in the remote server.
    ### Workflow
    #### Branch
    A branch is a version of the repository that diverges from the main working project.
    #### Commit
    A commit is a snapshot of the repo at a certain time.
    #### Pull Request (PR)
    A PR is a request for merging all commits from one branch to another, enabling multiple colaborators to discuss the proposed changes before integrating them into the official project.
    <img width="500" alt="image" src="https://user-images.githubusercontent.com/44426592/143865631-2879b244-b74a-4c6a-9911-3597acf3c834.png">
    #### Upstream
    An upstream branch is the branch tracked on the remote repository by the local branch

    ## Motivation
    ### Backup and Accessibility
    Lost files could be recovered from the server.
    @@ -44,6 +23,28 @@ A bug can be tracked back to its origin by finding out exactly when it started o
    <img width="300" alt="image" src="https://user-images.githubusercontent.com/44426592/143880050-7ca2e1a0-391f-45bd-9b16-17688840e9b4.png">


    ## Some Important Terms
    Let's start with the definition of some important terms that are used to create the Git world.
    ### General
    #### Repository
    A repository ("repo") is a directory that stores the content of a project, and some additional metadata. The repo stores the files themselves, the versions of those files, commits, deletions, and more.
    <img style="float: right;" width="500" alt="image" src="https://user-images.githubusercontent.com/44426592/143865768-92f3dec4-3d94-4f71-a8a0-12ccfb3fcee1.png">
    #### Fork
    A fork is a copy of a repository at a certain point at time.
    #### Origin
    The conventional name for the primary version of a repository, in the remote server.
    ### Workflow
    #### Branch
    A branch is a version of the repository that diverges from the main working project.
    #### Commit
    A commit is a snapshot of the repo at a certain time.
    #### Pull Request (PR)
    A PR is a request for merging all commits from one branch to another, enabling multiple colaborators to discuss the proposed changes before integrating them into the official project.
    <img width="500" alt="image" src="https://user-images.githubusercontent.com/44426592/143865631-2879b244-b74a-4c6a-9911-3597acf3c834.png">
    #### Upstream
    An upstream branch is the branch tracked on the remote repository by the local branch


    ## Healthy Workflow
    ### Working with SSH
    There are two ways to work with Github - HTTP and SSH.
    @@ -58,7 +59,6 @@ Content...
    * Working with PRs
    * Multiple contributors projects


    ## Useful Git Commands
    Some of the explanations are taken from [here](https://education.github.com/git-cheat-sheet-education.pdf). You may find this guide useful.
    * `git init` - initialize an existing directory as a Git repository
  17. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 16 additions and 12 deletions.
    28 changes: 16 additions & 12 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -22,18 +22,6 @@ A PR is a request for merging all commits from one branch to another, enabling m
    #### Upstream
    An upstream branch is the branch tracked on the remote repository by the local branch

    ## Healthy Workflow
    ### Working with SSH
    Add an explanation about SSH key configuration...
    ### What should we track with Git?
    Content...
    ### .gitignore + README
    Content...
    ### Git working cycle
    * Branch per feature + how to sync from different computers + when should I open a new branch and how (where to branch from)?
    * Working with PRs
    * Multiple contributors projects

    ## Motivation
    ### Backup and Accessibility
    Lost files could be recovered from the server.
    @@ -55,6 +43,22 @@ A bug can be tracked back to its origin by finding out exactly when it started o
    * An idea can be easily discarded if it turns out to be a bad one
    <img width="300" alt="image" src="https://user-images.githubusercontent.com/44426592/143880050-7ca2e1a0-391f-45bd-9b16-17688840e9b4.png">


    ## Healthy Workflow
    ### Working with SSH
    There are two ways to work with Github - HTTP and SSH.
    Working with HTTP was probably simpler until Github changed the privacy conditions and decided to add personal access tokens with an expiration date. An explanation about token creation could be found [here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token).
    The recommended way is using SSH. It is easy to configure, and once you counfigure it you don't need to think about it anymore. To use SSH you need to generate a key, and add it to GitHub, as explained [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).
    ### What should we track with Git?
    Content...
    ### .gitignore + README
    Content...
    ### Git working cycle
    * Branch per feature + how to sync from different computers + when should I open a new branch and how (where to branch from)?
    * Working with PRs
    * Multiple contributors projects


    ## Useful Git Commands
    Some of the explanations are taken from [here](https://education.github.com/git-cheat-sheet-education.pdf). You may find this guide useful.
    * `git init` - initialize an existing directory as a Git repository
  18. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -46,15 +46,14 @@ Because the code is not located only locally on the computer, but also on a serv

    ### Version control
    Snapshots of a project are stored with an easy access.

    <img width="300" alt="image" src="https://user-images.githubusercontent.com/44426592/143880050-7ca2e1a0-391f-45bd-9b16-17688840e9b4.png">
    #### Mistakes happen
    Recorded snapshots make it easy to undo mistakes and go back to a working version.
    A bug can be tracked back to its origin by finding out exactly when it started occurring. Git has a cool tool for binary search over commits (`git bisect`).
    #### Branching
    * Many developers can work on the same code.
    * Several features could be worked on simultaneously, and switched between
    * An idea can be easily discarded if it turns out to be a bad one
    <img width="300" alt="image" src="https://user-images.githubusercontent.com/44426592/143880050-7ca2e1a0-391f-45bd-9b16-17688840e9b4.png">

    ## Useful Git Commands
    Some of the explanations are taken from [here](https://education.github.com/git-cheat-sheet-education.pdf). You may find this guide useful.
  19. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -46,6 +46,7 @@ Because the code is not located only locally on the computer, but also on a serv

    ### Version control
    Snapshots of a project are stored with an easy access.

    <img width="300" alt="image" src="https://user-images.githubusercontent.com/44426592/143880050-7ca2e1a0-391f-45bd-9b16-17688840e9b4.png">
    #### Mistakes happen
    Recorded snapshots make it easy to undo mistakes and go back to a working version.
  20. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ Let's start with the definition of some important terms that are used to create
    ### General
    #### Repository
    A repository ("repo") is a directory that stores the content of a project, and some additional metadata. The repo stores the files themselves, the versions of those files, commits, deletions, and more.
    <img width="500" alt="image" src="https://user-images.githubusercontent.com/44426592/143865768-92f3dec4-3d94-4f71-a8a0-12ccfb3fcee1.png">
    <img style="float: right;" width="500" alt="image" src="https://user-images.githubusercontent.com/44426592/143865768-92f3dec4-3d94-4f71-a8a0-12ccfb3fcee1.png">
    #### Fork
    A fork is a copy of a repository at a certain point at time.
    #### Origin
  21. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -39,6 +39,7 @@ Content...
    Lost files could be recovered from the server.

    ![image](https://user-images.githubusercontent.com/44426592/143880115-386ce757-6f38-4e64-9f7e-19f67c32660b.png)

    Because the code is not located only locally on the computer, but also on a server, it can be accessed from anywhere in the world.

    ![image](https://user-images.githubusercontent.com/44426592/143880164-78437560-d1f0-4247-89a3-069b512e75a0.png)
  22. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -37,8 +37,10 @@ Content...
    ## Motivation
    ### Backup and Accessibility
    Lost files could be recovered from the server.

    ![image](https://user-images.githubusercontent.com/44426592/143880115-386ce757-6f38-4e64-9f7e-19f67c32660b.png)
    Because the code is not located only locally on the computer, but also on a server, it can be accessed from anywhere in the world.

    ![image](https://user-images.githubusercontent.com/44426592/143880164-78437560-d1f0-4247-89a3-069b512e75a0.png)

    ### Version control
  23. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -37,9 +37,13 @@ Content...
    ## Motivation
    ### Backup and Accessibility
    Lost files could be recovered from the server.
    ![image](https://user-images.githubusercontent.com/44426592/143880115-386ce757-6f38-4e64-9f7e-19f67c32660b.png)
    Because the code is not located only locally on the computer, but also on a server, it can be accessed from anywhere in the world.
    ![image](https://user-images.githubusercontent.com/44426592/143880164-78437560-d1f0-4247-89a3-069b512e75a0.png)

    ### Version control
    Snapshots of a project are stored with an easy access.
    Snapshots of a project are stored with an easy access.
    <img width="300" alt="image" src="https://user-images.githubusercontent.com/44426592/143880050-7ca2e1a0-391f-45bd-9b16-17688840e9b4.png">
    #### Mistakes happen
    Recorded snapshots make it easy to undo mistakes and go back to a working version.
    A bug can be tracked back to its origin by finding out exactly when it started occurring. Git has a cool tool for binary search over commits (`git bisect`).
  24. @saifun saifun revised this gist Nov 29, 2021. No changes.
  25. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 12 additions and 3 deletions.
    15 changes: 12 additions & 3 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -35,9 +35,18 @@ Content...
    * Multiple contributors projects

    ## Motivation
    * Backup
    * Version contol
    * Access from anywhere
    ### Backup and Accessibility
    Lost files could be recovered from the server.
    Because the code is not located only locally on the computer, but also on a server, it can be accessed from anywhere in the world.
    ### Version control
    Snapshots of a project are stored with an easy access.
    #### Mistakes happen
    Recorded snapshots make it easy to undo mistakes and go back to a working version.
    A bug can be tracked back to its origin by finding out exactly when it started occurring. Git has a cool tool for binary search over commits (`git bisect`).
    #### Branching
    * Many developers can work on the same code.
    * Several features could be worked on simultaneously, and switched between
    * An idea can be easily discarded if it turns out to be a bad one

    ## Useful Git Commands
    Some of the explanations are taken from [here](https://education.github.com/git-cheat-sheet-education.pdf). You may find this guide useful.
  26. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 7 additions and 4 deletions.
    11 changes: 7 additions & 4 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -23,13 +23,16 @@ A PR is a request for merging all commits from one branch to another, enabling m
    An upstream branch is the branch tracked on the remote repository by the local branch

    ## Healthy Workflow
    * Working with SSH
    ### Working with SSH
    Add an explanation about SSH key configuration...
    ### What should we track with Git?
    Content...
    ### .gitignore + README
    Content...
    ### Git working cycle
    * Branch per feature + how to sync from different computers + when should I open a new branch and how (where to branch from)?
    * Working with PRs
    * Multiple contributors projects
    * .gitignore + README
    ### Working with SSH
    Add an explanation about SSH key configuration...

    ## Motivation
    * Backup
  27. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,7 @@ Let's start with the definition of some important terms that are used to create
    ### General
    #### Repository
    A repository ("repo") is a directory that stores the content of a project, and some additional metadata. The repo stores the files themselves, the versions of those files, commits, deletions, and more.
    <img width="500" alt="image" src="https://user-images.githubusercontent.com/44426592/143865768-92f3dec4-3d94-4f71-a8a0-12ccfb3fcee1.png">
    #### Fork
    A fork is a copy of a repository at a certain point at time.
    #### Origin
    @@ -17,6 +18,7 @@ A branch is a version of the repository that diverges from the main working proj
    A commit is a snapshot of the repo at a certain time.
    #### Pull Request (PR)
    A PR is a request for merging all commits from one branch to another, enabling multiple colaborators to discuss the proposed changes before integrating them into the official project.
    <img width="500" alt="image" src="https://user-images.githubusercontent.com/44426592/143865631-2879b244-b74a-4c6a-9911-3597acf3c834.png">
    #### Upstream
    An upstream branch is the branch tracked on the remote repository by the local branch

    @@ -42,12 +44,16 @@ Some of the explanations are taken from [here](https://education.github.com/git-
    * `git checkout` - switch to another branch and check it out into the working directory
    * `git checkout -b <branch-name>` - create a new branch at the current commit
    * `git status` - show modified files in working directory
    <img width="300" alt="image" src="https://user-images.githubusercontent.com/44426592/143866404-c2529469-8231-44d1-93f7-5d760bc3e308.png">
    * `git add` - add a file as it looks now to the next commit
    * `git commit -m "<message>"` - commit the staged changes with the specified commit message
    * `git diff [--staged]` - shows the diff of the changed that are not staged (`--staged` shows diff for staged but not commited files)
    <img width="300" alt="image" src="https://user-images.githubusercontent.com/44426592/143866492-20d92d56-4c5d-4b10-ad66-bd475336b46c.png">
    * `git pull [origin <branch>]` - fetch and merge commits from the remote branch
    * `git push [origin <branch>, -u <upstream>]` - transmit local branch commits to the remote repository branch
    * `git merge` - merge a remote branch into the current branch
    * `git rm; git mv` - delete/move a file and stage the removal for commit
    * `git stash [pop]` - save modified and staged changes, (`pop` adds to the current branch the top of stash stack)
    * `git log` - show the commit history for the currently active branch
    <img width="300" alt="image" src="https://user-images.githubusercontent.com/44426592/143867017-3eaf552d-1dde-46c5-90e9-f23ca447499d.png">

  28. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -17,8 +17,8 @@ A branch is a version of the repository that diverges from the main working proj
    A commit is a snapshot of the repo at a certain time.
    #### Pull Request (PR)
    A PR is a request for merging all commits from one branch to another, enabling multiple colaborators to discuss the proposed changes before integrating them into the official project.

    * Upstream
    #### Upstream
    An upstream branch is the branch tracked on the remote repository by the local branch

    ## Healthy Workflow
    * Working with SSH
  29. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -11,9 +11,12 @@ A fork is a copy of a repository at a certain point at time.
    #### Origin
    The conventional name for the primary version of a repository, in the remote server.
    ### Workflow
    * Branch - a version of the repository that diverges from the main working project
    * Commit - a snapshot of the repo at a certain time
    * Pull Request (PR) - a request for merging all commits from one branch to another, enabling multiple colaborators to discuss the proposed changes before integrating them into the official project.
    #### Branch
    A branch is a version of the repository that diverges from the main working project.
    #### Commit
    A commit is a snapshot of the repo at a certain time.
    #### Pull Request (PR)
    A PR is a request for merging all commits from one branch to another, enabling multiple colaborators to discuss the proposed changes before integrating them into the official project.

    * Upstream

  30. @saifun saifun revised this gist Nov 29, 2021. 1 changed file with 4 additions and 9 deletions.
    13 changes: 4 additions & 9 deletions git_tutorial.md
    Original file line number Diff line number Diff line change
    @@ -3,22 +3,17 @@ Git is an awesome tool :smile:

    ## Some Important Terms
    Let's start with the definition of some important terms that are used to create the Git world.
    Some of the definitions are taken from [here](https://acloudguru.com/blog/engineering/git-terms-explained#repository).
    ### General
    #### Repository
    A repository ("repo") is a directory that stores the content of a project, and some additional metadata. The repo stores the files themselves, the versions of those files, commits, deletions, and more.
    #### Fork
    A fork is a copy of a repository at a certain point at time.
    #### Origin
    The conventional name for the primary version of a repository, in the remote server.
    * Branch
    * Commit
    * Add
    * Push
    * Pull
    * Merge
    * Rebase
    * Pull Request (PR)
    ### Workflow
    * Branch - a version of the repository that diverges from the main working project
    * Commit - a snapshot of the repo at a certain time
    * Pull Request (PR) - a request for merging all commits from one branch to another, enabling multiple colaborators to discuss the proposed changes before integrating them into the official project.

    * Upstream