Git
Basic Git workflow covering the essential commands for typical tasks.
Basic workflow
git clone <repository-url>  # Clone a remote repository
git status                  # Show working directory status
git add <file>              # Stage specific file changes
git add .                   # Stage all changes
git commit -m "message"     # Commit staged changes
git push origin <branch>    # Push changes to remote branch
git pull origin <branch>    # Pull changes from remote branch
git branch <new-branch>     # Create a new branch
git switch <branch>         # Switch to a branch
git merge <branch>          # Merge branch into current branch
git branch -d <branch>      # Delete local branch
git push origin --delete <branch>  # Delete remote branch
Create a local branch, make and push changes.
git checkout -b <"my-feature">
git commit -m <"feat: my feature description">
git push
git push -u origin <"my-feature">
Updating a branch
git checkout
git fetch
git checkout your-branch-name
git merge origin/main
# or
git rebase origin/main
# Resolve conflicts if needed
git add resolved-file
# if merging
git merge --continue
# if rebasing
git rebase --continue
git push origin your-branch-name
# if rebasing
git push origin your-branch-name --force-with-lease
git switch
git fetch
git switch your-branch-name
git merge origin/main  # or git rebase origin/main
# Resolve conflicts if needed
git add resolved-file
# if merging
git merge --continue
# if rebasing
git rebase --continue
git push origin your-branch-name --force-with-lease  # if rebasing
Resolving conflicts
git checkout
git status
# Open and edit conflicted files
git add <file>
git commit
# If rebasing, continue with
git rebase --continue
git push
git switch
git switch <branch-name>
git merge <branch-to-merge>
git status
# Resolve conflicts in files
git add <file>
git commit
git push