Skip to content

Git 101

Rudy Patel edited this page Jan 15, 2022 · 1 revision

How to push to your branch

Here is an example workflow that you can follow to push up to a branch:

  1. git add .: This adds all the modified files to the commit
  2. git commit -m "commit message here": Create a commit with a specified commit message
  3. git push: Push the commit to your branch

Alternatively, these steps can also be done using an IDE!

Commit messages

Having descriptive commit messages is important when working in a team. Detailed commit messages allow for other people to gain a good insight about the commit at a glance, without having to read through the changes.

  • A bad commit message: "added tests"
  • A better commit message: "added unit tests for <insert_class_name_here>"

Branch names

Having unique branch names will allow us to differentiate between all of the feature branches that we may all have in parallel.

Try following this simple template: <your name> <ticket number>

For example, if Rudy is working on ticket number 4: rudy 4 would be a good unique branch name.

Resolving merge conflicts

If your PR ends up having merge conflicts with main, here are the steps to go about resolving them:

  1. git checkout your_feature_branch: make sure you are on your feature branch
  2. git fetch: allow your local git to fetch any new updates in the project
  3. git merge origin/main: assuming you're merging into main, this merges the main branch into your feature branch
  4. Resolve conflicts. This can be done easily in a modern IDE. If it seems like both versions have completely different implementations, it may be worth reaching out to the person who wrote the original code to discuss further.
  5. Commit the merge conflict resolution with a meaningful commit message, an IDE can do this for you as well.
  6. git push: update your feature branch + PR
  7. There should be no more merge conflicts on your PR!

Useful git commands

Here are some good git commands that may come in handy:

git status: check the current status of your files, showing any modified + ready to commit files

git log: shows the commit history of your current branch

Clone this wiki locally