2025-11-17
Welcome to a github collaboration practice project! This is essentially a fun™ exercise designed to help us get more familiar with the collaborative aspects of GitHub (i.e. forking repositories, making changes, and opening pull requests).
Many of us are comfortable cloning repositories and making modifications, but often we keep those changes to ourselves. Few of us get into branching and contributing to other people's code. Pull requests help you propose changes to the team. They provide a platform for discussion, review, and eventually, integration of changes into the main project. This collaborative workflow is essential in a team setting as it ensures that projects can benefit from the collective expertise of the team.
People can find themselves working on a team that uses git/github, and the only repository they use is core to the work of their unit - it is not an appropriate place to "move fast and break things". That's where this repository comes in - nothing important exists in this repo, and no core work is going to fail as a result of anything we do in here. Please feel free to add/remove/edit any files you want (but note that I've added a Contributor Code of Conduct to remind everyone to behave).
Let's make sure that we're choosing to work on our own, and we're not limited by our ability to work with the collaborative aspects of git.
Although you can work with this via numerous tools, I'll assume you're working with RStudio for any instructions below. If you're using some other method, you probably don't need to read any instructions anyways. :)
Fork the repository:
- Go to https://github.com/Maritimes/Tag_Youre_Git
- Click the "Fork" button in the upper right corner
- This creates a copy of the repository under your own GitHub account
Clone your fork:
Open RStudio and go to File > New Project > Version Control > Git. In the "Repository URL" field, paste the URL of your forked repository (it will be https://github.com/YOUR-USERNAME/Tag_Youre_Git.git). This will clone your fork to your local machine.
Once you've cloned your fork, you can try the following:
- Create a new branch.
- Add/change file(s) in the repository.
- Commit your changes and push your branch to your fork on GitHub.
- Open a pull request from your fork to the original repository and in the description, tag someone to review your changes (using "@username").
- The tagged team member will review and comment on your changes. The repository maintainer will then merge the pull request if approved.
Branches are parallel versions of your repository that allow you to work on different tasks simultaneously without interfering with each other. Think of the main branch as the stable, production-ready version of your code, while other branches are workspaces for development.
Why use branches?
Branches let you isolate your work. If you're refactoring a major function but discover a critical bug that needs immediate attention, you can:
- Commit your refactoring work on its current branch
- Switch back to the main branch
- Create a new branch for the bugfix
- Fix the bug and merge it to main
- Return to your refactoring branch and continue working
Without branches, you'd have to either abandon your refactoring progress or push untested, incomplete code along with your bugfix.
Branch naming conventions:
Use descriptive names that indicate the purpose of the branch. Common patterns include:
feature/add-data-validationbugfix/correct-date-parsinghotfix/security-patchyourname/experiment-with-new-approach
This makes it easy for others (and future you) to understand what each branch is for at a glance.
-
Navigate to your fork: After you have pushed your changes to your branch on your fork, navigate to your fork's page on GitHub.
-
Click on 'Contribute': You'll see a "Contribute" button near the top of the page. Click it, then click "Open pull request".
-
Review the branches: GitHub will automatically set the base repository to
Maritimes/Tag_Youre_Gitand base branch tomain(ormaster), and compare it to your fork and branch. Verify these are correct. -
Review your changes: GitHub will show you the changes you made on your branch compared to the base branch. Review these to make sure everything is correct.
-
Click on 'Create pull request': If everything looks good, click on the 'Create pull request' button.
-
Fill in the pull request form: Give your pull request a title and describe your changes in the comment section. If you want to notify a team member to review your changes, type '@' followed by their username.
-
Submit the pull request: Click on 'Create pull request' to submit your pull request. Now others can review and comment on your changes.
When someone tags you in a pull request, they're asking you to review their proposed changes. Here's what to do:
As a Reviewer (anyone can do this):
-
Check notifications: You'll receive a notification on GitHub. Go to the original repository page (https://github.com/Maritimes/Tag_Youre_Git) and click on "Pull requests".
-
Review the changes: Click on the pull request you've been tagged in. Review the changes under "Files changed". Consider:
- Does the code make sense?
- Will it break anything?
- Is the purpose clear?
-
Provide feedback: Use GitHub's review features to leave comments on specific lines if you have questions or suggestions. You can click "Approve" to indicate the changes look good, or "Request changes" if issues need addressing.
-
Participate in discussion: Engage in the conversation. Ask questions, make suggestions, learn from others' approaches.
As the Repository Maintainer (merging):
Only the repository owner or designated collaborators can actually merge pull requests. If you have merge access:
-
Review feedback: Check that any issues raised by reviewers have been addressed.
-
Merge the pull request: Once satisfied with the changes and any review comments, click "Merge pull request" then "Confirm merge".
-
Continue the chain: After merging, follow the steps in "When You Want to Contribute" to make your own changes and tag the next person.
You can jump in and contribute at any time, whether you've been tagged or not. By tagging someone in your pull request, you're engaging your team in the project.
-
Sync your fork: Go to your fork on GitHub. If it's behind the original repository, you'll see a message. Click "Sync fork" then "Update branch" to bring your fork up to date.
-
Pull latest changes: In RStudio, go to the "Git" tab and click on "Pull". This will update your local repository with the latest changes from your fork.
-
Create a new branch: In the "Git" tab, click on "New Branch", enter a name for your branch, and click "Create".
-
Make your changes: Make your changes to the file(s) in the repository.
-
Stage and commit: Go to the "Git" tab in RStudio. Check the boxes next to changed files to stage them. Write a commit message and click "Commit".
-
Push to your fork: Click "Push" to push your changes to your fork on GitHub.
-
Open a pull request: Go to your fork's GitHub page. You'll see a message about your recently pushed branch. Click "Compare & pull request".
-
Tag someone: Write a description for your changes and tag a team member using "@username". Click "Create pull request".
-
Clean up: After your changes have been merged into the original repository, you can delete your branch to keep things tidy. In RStudio, go to the "Git" tab, click on "More", then "Shell...". In the shell, type
git branch -d branch_name(replacebranch_namewith the name of your branch), then press Enter.
Remember to always sync your fork and pull the latest changes before starting work on a new branch. This ensures you're always working with the most up-to-date version of the project.
If you want to give someone direct write access to the repository (bypassing the fork workflow), you can add them as a collaborator:
- Go to the repository page on GitHub.
- Click on "Settings", then "Collaborators and teams".
- Click "Add people" and enter their GitHub username.
- Set their permission level to "Write" or higher.
Note: This is optional. The fork workflow described above works for anyone without requiring you to add them first. Collaborators can merge pull requests, while non-collaborators can only submit and review them.
Merge conflicts occur when Git is unable to automatically resolve differences in code between two commits. While they can seem daunting, don't worry - they're a common part of the collaborative coding process. Here's a guide to understanding and resolving some of the most common merge conflicts.
- Edit/Edit Conflicts: These occur when two people have changed the same lines in a file, or if one person edited a file and another person deleted the same file.
- Delete/Edit Conflicts: These occur when one person deleted a file while another person was modifying it.
- Rename/Edit Conflicts: These occur when one person renamed a file and another person modified the same file.
-
Identify the Conflict: Git will tell you that a merge conflict has occurred after an attempted git pull. It will also show you the files where conflicts occurred.
-
Examine the Conflict: Open the file with the conflict. Git marks the problematic area in the file by enclosing it in
<<<<<<< HEADand>>>>>>> [other/branch/name]. The changes from the HEAD (your branch) are shown first, followed by the changes from the other branch. -
Resolve the Conflict: Decide if you want to keep only your branch's changes, keep only the other branch's changes, or make a brand new change, which may be a mix of the two. Delete the conflict markers and make the changes you want in the file.
-
Commit the Resolution: After you've resolved the conflict, stage the file with git add. Then, commit the resolution with git commit.
Remember, when resolving conflicts, communication is key. If you're unsure about how to resolve a conflict, reach out to the person you're collaborating with. It's a team effort!
This guide should help your team understand and resolve the most common types of merge conflicts.
If you run into issues, have questions about the workflow, or want to discuss Git/GitHub topics, use the Discussion Board for this repository.
Use Discussions for:
- Questions about forking, branching, or pull requests
- Troubleshooting problems you encounter
- Suggestions for improving this practice repository
- General Git/GitHub questions and tips
Don't use Discussions for:
- Code review feedback (use pull request comments instead)
- Commenting on specific changes (use pull request comments instead)
The Discussion Board is a collaborative space where we can all learn from each other. Don't hesitate to ask questions or share what you've learned!
That's it. I hope this is useful for people, and maybe even kind of fun. If you have any suggestions, please let me know!