Giter Site home page Giter Site logo

js-5-02's Introduction

git-config (JS-5-02)

Действия после установки git

посмотреть настройки

git config --list
git config --global user.name “имя”
git config --global user.email “почта”


git config --global core.safecrlf warn
git config --global core.quotepath off
git config --global init.defaultBranch main # Ветка по умолчанию

windows

git config --global core.autocrlf true

MAC & UNIX

git config --global core.autocrlf input

Действия при инициализации нового репозитория и при работе с ним

инициализация git репозитория

git init

текущее состояние репозитория

git status

добавить в трек (отслеживаемые) файл или папку

git add index.html

добавить все файлы из корня в трек

git add .

выполнить коммит (сделать слепок) текущего состояния проекта

git commit -m "сообщение"

показывает изменения

git diff
git diff --color-words // показывает по строкам изменения

отменить коммит "ПЕРЕПИСЫВАЕТ ИСТОРИЮ"

вернуться к коммиту старому но оставить текущие изменения, если коммит еще не отправлен в репозиторий

git reset 'HASH commit'

вернуться к коммиту и удалить все изменения, если коммит еще не отправлен в репозиторий

git reset --hard 'HASH commit'
git reset --hard HEAD~    //~2 ~3 на сколько коммитов откатить

откатить изменения

### у всех файлов трека
git checkout .  
git clean -fd (удалить все неотслеживаемые файлы)
### в одном файле или каталоге
git checkout name.file //откатить изменения в одном файле или каталоге
git restore index.html //возвратить файл до исходного состояния)

git branch //посмотреть где находимся
git checkout main //вернутся к основной ветке

отправить изменения в удаленный репозиторий

git push 

клонирование репозитория

git clone https://github.com/Quper87/git-lesson.git

сохраняет изменения отслеживаемых файлов и выполняет коммит

git commit -a -m 'сохраняет изменения отслеживаемых файлов и выполняет коммит'

ЗАМЕТКИ

generate key:

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

ssh-keygen -t ed25519 -C "[email protected]"

agent:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

Adding a new SSH key to your account (github --web):

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account

clip < ~/.ssh/id_ed25519.pub

логи и pull

git pull --rebase //подтянуть данные не поломав коммиты

git log //логи коммитов
git show 'хэш коммита можно первые 8 символов'
git log --oneline // краткие логи коммитов в одну строку
git blame index.html (посмотреть кто изменял какую строку)
git grep h1  (поиск подстроки)

отменить коммит

git revert 'хэш коммита'

поправить коммит (например забыли добавить что-то)

Выполнить stage отслеживание:
git add . или git add music.css
Выполнить
git commit --ammend

отложить в кладовку написанный код

Выполнить stage отслеживание:
git add . или git add music.css
Выполнить
git stash
### достать написанный код
git pop 

работа с ветками branch

git chekout -b 'название новой ветки' // создать и перейти в новую ветку.
отправляем ветку в удаленный репозиторий как обычно:
git add .
git push

Чтобы слить ветку с main:
git checkout main //переходим в main
git merge 'имя ветки для слияния в мейн'
git branch -d 'имя ветки для удаления' //удаляем ненужную ветку
git push -d origin имя-ветки // чтобы также удалить в репозиторий удаленном
Конфликты merge 
git diff - посмотреть детально конфликт в консоли
исправить конфликт ручками и затем
git add . 
git commit -a -m ''

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.