Skip to content

Latest commit

 

History

History
64 lines (49 loc) · 1.38 KB

Git Workflow.md

File metadata and controls

64 lines (49 loc) · 1.38 KB

Git Workflow

When you are ready to make a PR:

If you are worried about accidentally messing up your branch or if you are about to do something risky, you can always back it up by making a backup branch.

1. Fetch from remote.

Command Line

git fetch --all 

VS Code Source Control ... → Pull, Push → Fetch From All Remotes → origin/main

2. Count your commits on your branch.

Command Line

git rev-list --count --first-parent <parent>..<branch_name>

VS Code Use the Git Graph VS Code extension to manually count the number of commits on your branch.

3. Reset commits to create a singular one (similar to squashing).

git reset --soft HEAD~<number of commits to squash>

4. Do a local commit with a message.

This is to save the squash locally. Command Line

git add .
git commit -m "squashed commits into one"

VS Code

  • Stage changes.
  • Commit message.
  • Push.

5. Force push to remote.

git push -f origin <name of branch>

6. Rebase onto the dev branch.

Command Line

git rebase -i origin/dev

VS Code Source Control ... → Branch → Rebase Branch... → origin/dev

7. Force push to remote.

git push -f origin <name of branch>

8. Open a PR.

9. Enjoy your clean Git history :)