Skip to content

Instantly share code, notes, and snippets.

@Aldizh Aldizh/git_tips.txt

Last active May 2, 2020
What would you like to do?
Helpful github tips and commands
# Whenever i start coding i like to start with this command to clean up the repo and find out where we are
$ git fetch --prune origin && git status
# Merging is usually a good strategy as it allows for better tracking and dividing up the work
# Github offers a squash && merge option now on the PRs, but lets consider this:
# You want to test the feature branch locally before merging it and if there are any conflicts you want to resolve and test
$ git checkout master
$ git merge --squash feature_branch
$ git reset origin/master (Optional if we want to unstage all files that differ from origin master)
$ git add --all
$ git commit
# Re-writing history (Destructive way)
$ git commit --amend => Lets you edit last commit
$ git rebase -i HEAD~3 => Interactively update/remove and reapply last 3 commit messages
# Alternative we can use -f flag, though not recommended
$ git push -f origin banch_name
# Do your self a favor and set aliases for some commonly used commands
# This is how you can check the config list
$ git config --list | grep alias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.