-
Notifications
You must be signed in to change notification settings - Fork 2
Git 101
Here is an example workflow that you can follow to push up to a branch:
-
git add .
: This adds all the modified files to the commit -
git commit -m "commit message here"
: Create a commit with a specified commit message -
git push
: Push the commit to your branch
Alternatively, these steps can also be done using an IDE!
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>"
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.
If your PR ends up having merge conflicts with main, here are the steps to go about resolving them:
-
git checkout your_feature_branch
: make sure you are on your feature branch -
git fetch
: allow your local git to fetch any new updates in the project -
git merge origin/main
: assuming you're merging into main, this merges the main branch into your feature branch - 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.
- Commit the merge conflict resolution with a meaningful commit message, an IDE can do this for you as well.
-
git push
: update your feature branch + PR - There should be no more merge conflicts on your PR!
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