Here are some common git commands that I use on a regular basis to create pull requests on GitHub –
1. Shows all remotesgit remote
2. Shows remotes with their urlgit remote -v
3. Gets remote data into local repo but doesn’t add to your working filesgit fetch <remote>
4. Merge fetched datagit merge <remote>/master
5. Fetch and merge remote data with our working filesgit pull
ORgit fetch <remote>git checkout mastergit merge <remote>/master
6. Add a remotegit add remote <name> <url>
7. Add remote branch as a local branchgit checkout --track <remote>/<branch_name>
8. Delete a branch locallygit branch -d <branch_name>git branch -D <branch_name> force delete
9. Delete remote branchgit push <remote_name> --delete <branch_name>
10. Create and checkout a branchgit checkout -b <branch_name>
Bonus
I know I said 10 in the title but here are some more –
11. Rebase current branch with another branch.git rebase <branch_name>
This will “port” another branch (Branch A) into the branch where you are currently working (Branch B), by applying all of your unique commits from Branch B on top of Branch A and replacing Branch B with this revised version. That way, you can “catch up” to other branches by re-writing git history in your local git. [Source]
12. See commits in current branch that aren’t cherry picked to mastergit cherry -v master
13. Push a branch to remotegit push <remote> <branch>git push <remote> <branch> -f force push
That’s all for now. If you’d like, go ahead and bookmark this page as I may add more to it in the future.