Last active
March 11, 2023 00:18
-
-
Save juliofruta/7c6f6d3e557965ea28295aa29ff7c7e4 to your computer and use it in GitHub Desktop.
Useful git & github cli commands for you!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git | |
git init # Initialize git on the current folder | |
git checkout -b <new-branch-name> # Create a branch | |
git checkout <existing-branch> # Checkout a branch | |
git fetch --all # Get latest commits from origin | |
git add <file> # Add file to the stage area | |
git commit # Commit stages | |
git push origin <branch> # Push a branch to origin | |
git push origin <branch> --force # Force push a branch to origin | |
git pull # Get current branch latest commits from remote | |
git reset --soft HEAD~1 # Revert a commit without losing changes | |
git reset --hard <commit> # Revert to a commit losing changes | |
git stash #Put current work into a stash | |
git cherrypick <commit-hash> # Put a specific commit in top of current branch | |
git merge <branch> # Merge <branch> into current branch | |
git log --oneline <commitA>...<commitB> | grep 'Merge pull request #' # Get a list of pull requests between 2 commits | |
git log --oneline <commitA>...<commit-B> | ggrep -oP '#\K[0-9]*' | xargs -I _ sh -c "gh pr view _ --repo <ORGANIZATION>/<REPOSITORY> | head -n 1" > prs.txt # This requires ggrep to be installed. | |
# Github CLI | |
gh pr view <pr-number> --repo <owner>/<repository> | head -n 1 | |
git log --oneline 5.2.1...release/5.3.0 | ggrep -oP '#\K[0-9]*' | xargs -I _ sh -c "gh pr view _ --repo PGEDigitalCatalyst/Inspect | head -n 1" | grep "ACE" > prs.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great! thank you