Skip to content

Instantly share code, notes, and snippets.

@madhurjain
Last active June 23, 2019 03:12
Show Gist options
  • Save madhurjain/8b8222df61033a14a63bc34ec33ed5b5 to your computer and use it in GitHub Desktop.
Save madhurjain/8b8222df61033a14a63bc34ec33ed5b5 to your computer and use it in GitHub Desktop.
Git Commands

Cherry-Pick from a different repo

git fetch <remote-git-url> <branch> && git cherry-pick SHA1
or
git remote add other https://example.link/repository.git
git fetch other

then normally do a cherry-pick

git cherry-pick <first_commit>..<last_commit>

Clean-up local branches that were deleted from remote

git fetch --all --prune

Reset commit to HEAD - 2

// Don't care about the changes
git reset --hard HEAD~2
// Move the changes to staging
git reset --soft HEAD~2
// Unstage files from Staging
git reset
// Force clean files from working directory
git clean -f

To try

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