Git
List existing remotes
Section titled “List existing remotes”git remote -vorgit remote show origin
Set remote’s URL
Section titled “Set remote’s URL”git remote add origin https://github.com/USERNAME/REPOSITORY.git
Change remote’s URL
Section titled “Change remote’s URL”git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
Generate changelog since last tag
Section titled “Generate changelog since last tag”git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%s"git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"* %s by @%an in https://github.com/my-org/my-repo/commit/%H"
Get last tag (semver speaking)
Section titled “Get last tag (semver speaking)”git tag -l --sort=-version:refname | head -1
Rebase the first 2 commits
Section titled “Rebase the first 2 commits”git rebase -i --root
Reset the last commit and keep changes
Section titled “Reset the last commit and keep changes”git reset HEAD~1
Apply a change to a previous commit which is not last commit
Section titled “Apply a change to a previous commit which is not last commit”git rebase -i HEAD~{number of commits to go back} => set "pick" to "edit" at the commit you want to change => apply the changes to your filesgit add .git commit --amend --no-editgit rebase --continue
Force to reset a branch as a remote one (here origin/master)
Section titled “Force to reset a branch as a remote one (here origin/master)”git reset --hard origin/master