git

Linux · Packages · reference only

What it does

Version control system: it keeps a project's change history and lets you go back, branch and collaborate.

Syntax

git orden [opciones]

Options and parameters

  • init

    Creates a new repository in the current directory.

  • status

    Shows which files changed and which are staged for the commit.

  • add fichero

    Stages changes for the next commit; add . stages them all.

  • commit -m "mensaje"

    Saves the staged changes in the history, with a message.

  • log --oneline

    Shows the commit history, one line each.

  • config --global clave valor

    Configures Git for your user, such as user.name and user.email.

  • branch [nombre]

    Lists branches or creates a new one.

Usage examples

  • git init

    Turns the current directory into a repository.

  • git status

    Checks the state of the working directory.

  • git add informe.txt && git commit -m "Añade el informe"

    Stages a file and saves it in the history.

  • git log --oneline

    Reviews the history compactly.

  • git config --global user.name "Ana"

    Sets the name that will appear on your commits.

  • git branch pruebas

    Creates a branch called pruebas.

Notes and common mistakes

  • Git stores each commit with an identity: set user.name and user.email before the first one.
  • Simulator scope: init, status, add, commit, log, config and branch.

Related commands