Skip to content

Instantly share code, notes, and snippets.

@Mifrill
Last active June 6, 2024 18:51
Show Gist options
  • Save Mifrill/654e85fabc21d30e71a0330cace30aa2 to your computer and use it in GitHub Desktop.
Save Mifrill/654e85fabc21d30e71a0330cace30aa2 to your computer and use it in GitHub Desktop.

git log -1 --pretty=format:"%h - %an, %ar : %s"

git restore --staged <file>
git reset --hard --recurse-submodule

git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive

curl -H "Authorization: token <your_access_token>" "https://api.github.com/repos/<repository_owner>/<repository_name>/pulls" | jq '.[] | .number' | xargs -I {} sh -c 'curl -H "Authorization: token <your_access_token>" "https://api.github.com/repos/<repository_owner>/<repository_name>/pulls/{}/files" | jq ".[] | select(.filename == "<file_path>")"'

git tag -d connect-qa && git push origin :refs/tags/connect-qa
git tag connect-qa -f && git push origin connect-qa

find largest items from git history git ls-tree -rl HEAD | sort -k4 -n | tail | awk '{print $4, $5}' | numfmt --to=iec-i

git diff master > branch.diff git apply --reverse branch.diff

git show HASH | git apply -R # git undo changes from commit without commit

git stash push -m "linters" git stash apply stash^{/linters}

git checkout tags/v

git diff stash@{0}^1 stash@{0} -- package.json | git apply git fetch remote-git-url branch && git cherry-pick FETCH_HEAD

git diff --binary HEAD commit_sha_you_want_to_revert_to | git apply # https://stackoverflow.com/questions/1463340/how-to-revert-multiple-git-commits

// git cherry-pick multiple commits git cherry-pick A^..B

git merge --no-commit --squash branchA

How to rebase your feature branch from one branch to another

git rebase source-commit --onto target-branch

delete the tag git tag -d tagname git push --delete origin tagname

git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote

git log master --oneline | tail -1

git ls-remote --refs origin git fetch origin pull/123/head:pr/123 && git checkout pr/123

git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD master)

git add -u git reset -- main/dontcheckmein.txt

git log --grep=word

git init git add . git commit -m "something" git push

git log git reset --hard {name of commit} git push origin +master

git remote add origin {new url origin master} git remote set-url origin

git rm -r --cached some-directory git commit -m 'Remove the now ignored directory "some-directory"' git push origin master

git rebase --abort git clean -df git branch -d the_local_branch

git grep $(git rev-list --all)

git clone -b <remote_repo>

git checkout master git pull https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git BRANCH_NAME git push origin master

git config --global credential.helper 'cache --timeout 7200'

https://git-scm.com/docs/git-rebase#_interactive_mode git rebase -i pick reword
squash fixup edit

git fetch && git rebase origin/master && git rebase -i origin/master

git fetch && git rebase origin/master

git reset --soft HEAD^

git undo all uncommitted changes

git clean -fdx

git pull --rebase origin get-rid-of-image_bin

cat ~/.ssh/id_rsa.pub | xclip -sel clip

git config --global credential.helper 'cache --timeout=36000'

git branch -av --sort=committerdate --format='%(committerdate:short) %(authorname) %(refname:short)'

git commit --amend --reset-author

update rbenv plugin

cd ~/.rbenv/plugins/ruby-build git pull

how to look change from commit

git diff-tree -p {commit}

git reflog

different before commit

git diff --cached crawlers

commenter:mifrill type:issue

git stash

git remove differene in file

git checkout master -- middleware/cleaner.rb

git log --pretty=oneline

Look for conflicts in your current files grep -H -r "<<<" * grep -H -r ">>>" * grep -H -r '^=======$' *

git pull after rebase without merge

git pull --rebase

work with fork from other users

git remote add user git://path/to/user/repo.git git fetch user git checkout --track user/foo

update revision

bundle update --source athena

rm -f ./.git/index.lock

git blame middleware/validator.rb

git cherry-pick # используется для перенесения отдельных коммитов из одного места репозитория в другое, обычно между ветками разработки и обслуживания. Этот механизм отличается от привычных команд git merge и git rebase, которые переносят коммиты целыми цепочками.

спрятать все, что вы уже успели сделать git stash save внести необходимые изменения добавить их в последний коммит git add -u && git commit --amend вернуться к работе git stash pop

git cherry-pick git cherry-pick ..master

git reset --soft HEAD~1 git shortlog -sn

@Mifrill
Copy link
Author

Mifrill commented Feb 2, 2024

vscode.dev/

@Mifrill
Copy link
Author

Mifrill commented Feb 20, 2024

is:pr is:closed merged:2023-02-01..2023-03-01 

@Mifrill
Copy link
Author

Mifrill commented Feb 21, 2024

RUN npm ci --timeout=60000 --no-audit --maxsockets 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment