Skip to content

Instantly share code, notes, and snippets.

@timmyreilly
Last active May 14, 2025 00:03
Show Gist options
  • Save timmyreilly/95cbefd4e0accadbff254eba724fd122 to your computer and use it in GitHub Desktop.
Save timmyreilly/95cbefd4e0accadbff254eba724fd122 to your computer and use it in GitHub Desktop.
Git Flow

1. Git flow

Fork the project, and clone to your machine from the fork.

Get your local main branch up to date with upstream's main branch:

git fetch upstream
git checkout main
git rebase upstream/main

Create a local branch from main for your development:

# While on the main branch
git checkout -b <branch name>
# ex: git checkout -b feature

Keep your branch up to date during development:

git fetch upstream
git rebase upstream/main

# or: git pull --rebase upstream main

4. Commit

Make code changes on the feature branch and commit them with your signature

git commit -s

Make sure to squash your commits before opening a pull request. This is preferred so that your pull request can be merged as is without requesting to be squashed before merge if possible.

5. Push

Push your branch to your remote fork:

git push -f <remote name> <branch name>

6. Open a pull request

  1. Visit your fork at https://github.com/ + username + project_name
  2. Open a pull request from your feature branch using the Compare & Pull Request button.
  3. Fill the pull request template and provide enough description so that it can be reviewed.

If your pull request is not ready to be reviewed, open it as a draft.

Check the log: git log --graph --decorate --pretty=oneline --abbrev-commit

And follow the steps in this blog: https://www.scraggo.com/how-to-squash-commits/

git rebase -i HEAD~5 5 being the number of commits to squash

image

@timmyreilly
Copy link
Author

timmyreilly commented Apr 16, 2024

Want to remove some changes:

git filter-branch --force --index-filter "git rm --cached --ignore-unmatch /influx/modules/InfluxWriterModule/Dockerfile.amd64:Zone.Identifier" --prune-empty --tag-name-filter cat -- --all

This will remove a file from your git history

Just update the path to file your want removed

@timmyreilly
Copy link
Author

timmyreilly commented Apr 16, 2024

git filter-branch --force --index-filter "git rm --cached --ignore-unmatch ./docs/examples/postman_content.txt" --prune-empty --tag-name-filter cat -- --all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment