- Elementary commands

- Elementary commands#

clone view

Running git clone <url> performs the following operations:
  1. Copy the remote repository

  2. Create tracking branches for all remote branches.

  3. Check out the active branch from the remote repository.

Note

git clone is run typically only once

pull  

In short, git pull is a combination of two command: git fetch followed by either git merge or git rebase.

It fetches the changes from the remote repository and integrates them into the current branch. The integration happens either though a merge or a rebase and can be set by passing the options --rebase or --no-rebase to the git merge command.

This is a very common operation when working with a remote repository and is often used to update your local repository with the changes from the remote repository.

git pull procedure:

Assume this is the state in which you run a git pull --no-rebase:

      C---D---E main on origin
     /
A---B---C'---D' main
    ^
    origin/main in your repository
  1. Your local state of origin/main will be updated

                    origin/main in your repository
                    ∨
           C---D----E main on origin
          /
     A---B---C'---D' main
    
  2. origin/main is integrated in your main

    This happesn in two steps:

    1. replay the commit from the remote branch (C, D and E) at the end of your local main, i.e. on top of D'

    2. register the result in a new commit F on top of your local branch, i.e. main in this case

                    origin/main in your repository
                    ∨
           C---D----E main on origin
          /          \
     A---B---C'---D'--F main