Skip to content
|K07e7su edited this page Jul 28, 2018 · 11 revisions

Git

.------------------------------------------------------------------------------.
|                             .mmMMMMMMMMMMMMMmm.                              |
|                         .mMMMMMMMMMMMMMMMMMMMMMMMm.                          |
|                      .mMMMMMMMMMMMMMMMMMMMMMMMMMMMMMm.                       |
|                    .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.                     |
|                  .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.                   |
|                 MMMMMMMM'  `"MMMMM"""""""MMMM""`  'MMMMMMMM                  |
|                MMMMMMMMM                           MMMMMMMMM                 |
|               MMMMMMMMMM:                         :MMMMMMMMMM                |
|              .MMMMMMMMMM                           MMMMMMMMMM.               |
|              MMMMMMMMM"                             "MMMMMMMMM               |
|              MMMMMMMMM                               MMMMMMMMM               |
|              MMMMMMMMM                               MMMMMMMMM               |
|              MMMMMMMMMM                             MMMMMMMMMM               |
|              `MMMMMMMMMM                           MMMMMMMMMM`               |
|               MMMMMMMMMMMM.                     .MMMMMMMMMMMM                |
|                MMMMMM  MMMMMMMMMM         MMMMMMMMMMMMMMMMMM                 |
|                 MMMMMM  'MMMMMMM           MMMMMMMMMMMMMMMM                  |
|                  `MMMMMM  "MMMMM           MMMMMMMMMMMMMM`                   |
|                    `MMMMMm                 MMMMMMMMMMMM`                     |
|                      `"MMMMMMMMM           MMMMMMMMM"`                       |
|                         `"MMMMMM           MMMMMM"`                          |
|                             `""M           M""`                              |
'------------------------------------------------------------------------------'

Config

[user]
        name = Etsu
        email = etsu4296@gmail.com

[alias]
        home = !git config --global user.email etsu4296@gmail.com && git config --global user.name \"Etsu\"
        ivi = !git config --global user.email pazarova@ivi.ru && git config --global user.name \"pazarova\"
        alfa = !git config --global user.email pazarova@alfabank.ru && git config --global user.name \"pazarova\"

        homerepo = !git config --local user.email etsu4296@gmail.com && git config --local user.name \"Etsu\"
        ivirepo = !git config --local user.email pazarova@ivi.ru && git config --local user.name \"pazarova\"
        alfarepo = !git config --local user.email pazarova@alfabank.ru && git config --local user.name \"pazarova\"

Настройка автора коммитов в git и добавление ключа

git config --global user.name "<name>"
git config --global user.email <email>
git config --list

ssh-keygen -t rsa -b 4096 -C "<email>"
eval "$(ssh-agent -s)"
ssh-add -K ~/.ssh/id_rsa
pbcopy < ~/.ssh/id_rsa.pub

Изменение автора коммита (если нечего терять :) )

git log --graph
git rebase -i <hash>  # от предыдущего
git log
git commit --amend --author = "Etsu"
git rebase --continue <<email>>
git log --graph
git push --force
git log --graph
git rebase -i 11330cb0b7811604c76b88e42fcf29cf6724345c
// change pick -> edit
git commit --amend --author="Etsu <etsu4296@gmail.com>"
git log --graph
git rebase --continue
git log --graph
git status
git push -f

For VIM!

sudo update-alternatives --config editor

Удаление ветки testing

git branch -d testing

Merge

git checkout master
git pull
git checkout <branch>
git rebase master
git push origin :<branch> -- удаляет ветку branch в удаленном репозитории 
git checkout master
git merge --no-ff <branch>
git tag <tag>
git push origin master <tag>

Add remote repository

git remote add origin git://

Two commits -> one commit

git rebase -i HEAD~2
squash newest_commit
pick oldest_commit

If something was wrong:

git rebase --amend