Git Product home page Git Product logo

git-cheat-sheet's Introduction

Шпаргалка по Git

Основные команды

Работа с репозиторием

  • git init - инициализация нового репозитория
  • git clone <URL> - клонирование репозитория
  • git remote add origin <URL> - добавление удаленного репозитория
  • git pull origin <branch> - получение и объединение изменений из удаленного репозитория
  • git push origin <branch> - отправка изменений в удаленный репозиторий
  • git branch <branch> - создание новой ветки
  • git checkout <branch> - переключение на другую ветку
  • git merge <branch> - объединение веток

Работа с изменениями

  • git status - проверка состояния репозитория

  • git add <file> - добавление файла в индекс

  • git commit -m "Сообщение" - создание коммита с сообщением

    • git commit --amend --no-edit - дополнить коммит новыми файлами
  • git diff - просмотр изменений в файлах после git add

    • git diff --staged - просмотр изменений после git commit
  • git log - просмотр истории коммитов

    • git log --oneline - сокращённый лог c автоподбором
    • git commit --amend -m "Обновлённое сообщение коммита" - изменить сообщение к коммиту

Отмена изменений

  • git reset <commit> - отмена коммита и сохранение изменений
    • git restore --staged <file> - переведёт файл из staged обратно в modified или untracked
    • git reset --hard <commit hash> - «откатит» историю до коммита с хешем . Более поздние коммиты потеряются!
    • git restore <file> - «откатит» изменения в файле до последней сохранённой (в коммите или в staging) версии
  • git revert <commit> - создание нового коммита, отменяющего изменения
  • git checkout -- <file> - отмена изменений в файле

Расширенные возможности

  • git stash - временное сохранение изменений
  • git rebase - изменение истории коммитов
  • git cherry-pick <commit> - применение коммита из другой ветки
  • git bisect - поиск коммита, в котором возникла проблема
graph LR;
  untracked -- "git add" --> staged;
  staged    -- "???"     --> tracked/comitted;

%% стрелка без текста для примера: 
  A --> B;
Loading

git-cheat-sheet's People

Contributors

js-easy-school avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.