Skip to content

Instantly share code, notes, and snippets.

@NisargIO
Last active March 13, 2024 19:21
Show Gist options
  • Save NisargIO/78d276e60a991e2738d4f0b8f26d2e20 to your computer and use it in GitHub Desktop.
Save NisargIO/78d276e60a991e2738d4f0b8f26d2e20 to your computer and use it in GitHub Desktop.
Better Github

Git Convention

Recommended Committing Convention

Not necessary, but a good convention to go by.

Examples

  • feat: new feature
  • fix: bug in scope
  • feat: breaking change / feat: rework API
  • chore: update dependencies

Commit types

  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Changes which doesn't change source code or tests e.g. changes to the build process, auxiliary tools, libraries
  • docs: Documentation only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • revert: Revert something
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)
  • test: Adding missing tests or correcting existing tests
  • hk: Housekeeping

For Branch Convention

  1. Convert : to /
  2. Convert spaces to -
  3. Convert ands to +

i.e feat/login-google, feat/login+signup

The following are useful information/commands/actions for Github I hate searching for.

Pulling when multiple people are working on a branch.

Let's say John and you (or more ppl) are working on the same branch.

  1. [SITUATION 1] You have some changes and John pushes. Now your local repo is one commit behind. i.e ↓ 1

    1. Try git pull to catch up your current branch. If successful, you're done!
    2. Try git stash to stash your changes, git pull to pull John's commit, git stash pop to add your changes back.
    3. If get Fatal: Not possible to fast-forward, aborting move on to SITUATION 2.
  2. [SITUATION 2] Let's say you already have multiple commits and John pushes. Now your local repo looks like ↓ 1 ↑ 3

    1. Use git pull --rebase. Think of this as putting your changes aside, pulling all the pushed changes from Github and then popping you changes on top of that. This may cause merge conflicts if John's changed files that you also changed.

Revert a commit and remove from the history from a branch. [DANGEROUS + MAYBE BAD PRACTICE?]

  1. Reverts your local repo to the commit before the commit you want to remove. The git reset should tell you what current commit you are on.

    // For one commit back
    git reset --hard HEAD~
    
    // For n commit back
    git reset --hard HEAD~n
  2. Force pushes your local repo to origin essentially overriding the Github repo with your local repo.

    git push --force origin
  3. Verify new history on Github

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