Skip to content

Git Workflows#

Create feature branch#

git checkout -b feature/new-feature

Push feature branch#

git push -u origin feature/new-feature

Delete local feature branch#

git checkout main
git pull
git branch -d feature/new-feature

Undo last commit (keep changes)#

git reset HEAD~1

Change last commit message#

git commit --amend -m "New message"

Unstage file#

git restore --staged <file>

Discard local changes#

git restore <file>

Add upstream remote#

git remote add upstream <original-repo-url>

Sync fork#

git fetch upstream
git checkout main
git merge upstream/main
git push origin main

Rebase feature branch#

git checkout feature/branch
git rebase main

Interactive rebase#

git rebase -i HEAD~3

Cherry pick commit#

git cherry-pick <commit-hash>