Skip to content

Instantly share code, notes, and snippets.

@achesco
Last active November 6, 2017 09:59
Show Gist options
  • Save achesco/999cdce798c2bbee0ef2fe2d0f3bcb72 to your computer and use it in GitHub Desktop.
Save achesco/999cdce798c2bbee0ef2fe2d0f3bcb72 to your computer and use it in GitHub Desktop.

Revisions

  1. achesco revised this gist Nov 6, 2017. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Git, GitFlow code snippets
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    # Make some commits
    # GitFlow
    git checkout develop && git checkout -b _feature-branch_
    git reset --soft _commit-id_
    git commit [-a] [-—amend] [--no-edit]
    git fetch origin
  2. achesco created this gist Nov 6, 2017.
    58 changes: 58 additions & 0 deletions Git, GitFlow code snippets
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    # Make some commits
    git reset --soft _commit-id_
    git commit [-a] [-—amend] [--no-edit]
    git fetch origin
    git pull --rebase origin develop
    git push origin _branch-name_ [-f]


    # Reset one commit back
    git reset --soft HEAD~1

    # Unstage files from index
    git reset HEAD <file>

    # 1. Remove untracked files from the working tree
    # -n - dry run - only preview results
    # -f - force (clean.requireForce)
    # -X - remove ignored files
    # -x - remove ignored and non-ignored files
    # -d - remove directories
    git clean -n -f[xXd]

    # 2. Run if preview doesn’t scare you
    git clean -f[xXd]

    # Remove odd unstated files changes
    # 1. Stash unstated modified / new files
    git stash save -—keep-index

    # 2. Remove stash then
    git stash drop

    # Contents of the index
    git ls-files --abbrev --stage

    # Differences between working tree and the index (not current commit)
    git diff

    # Differences between the index and the current commit
    git diff --staged

    # Cписок обновленных файлов начиная с коммита
    tar czf changes.tgz `git diff --name-only _from-commit-id_ _to-commit-id_`
    # или
    git diff --name-only _from-commit-id_ _to-commit-id_ | xargs tar -czf changes.tgz
    # В корне проекта в результате получаем архив со всеми файлами разложенных
    # по папочкам в соотвествии с иерархией проекта.

    # Squashing commits
    # http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
    # тут еще про Chery Pick, как объеденить несколько не последовательных коммитов
    # http://clock.co.uk/tech-blogs/deleting-a-git-commit

    # Удалить последний коммит после пуша
    git reset --hard HEAD~1

    # Delete all branches merged to ‘develop'
    git checkout develop && git fetch --prune && git branch --merged | grep -v develop | xargs git branch -d