Juri Strumpflohner

RSS
all notes🌱seedling·Updated

Everyday Git Commands

Author profile pic
Juri Strumpflohner

Sort Git branches by last commit

git branch --sort=-committerdate

Pushing commits to a PR of someone else

Update: newer versions of the GitHub CLI seems to handle this automatically

When reviewing a PR, you might often see some small change that needs to be made, so rather than pinging the person again, you can just change it and create another commit on the person’s branch.

Usually in an open source project that means to push aGit commit to the person’s forked repository (and to the according branch there).

Identify the forked repo and branch

So in this case that’d be vivekmore:feature/use-more-es6-features

Check out the PR

This can be done very easily using the GitHub CLI

gh pr checkout <number>

Push the commit

Just create a commit normally on your local machine and then push it back up to the forked repository.

git push git@github.com:vivekmore/nx.git feature/use-more-es6-features:feature/use-more-es6-features

Add the -f if you rebased a commit.

Reset workspace (removing all changes)

The first part resets all changed parts, the clean also removes new files that have not been staged or anything.

git reset --hard HEAD && git clean -df