During my 1st weeks in Flatiron School I began learning about Git for the first time, ever! However, the majority of all the labs and assignments involved working alone. I found myself doing the same simple git commands to fork and clone a GitHub repository, and then push my changes when the assignment was complete. At the beginning of my 3rd week we had our first group project and realized that neither of us were very familiar with working on building a web app together without conflicting changes. This blogpost is written for beginner programmers that want to work collaboratively on a project! It assumes you already have git installed and know the basics of working solo.
Add collaborators to your repository
Create a repository on GitHub and navigate to Settings/Manage access. Invite people you will be working on the project with.
Create a new branch name
In the terminal, navigate to your projects folder. The following commands
will be entered into the terminal.
git branch new-branch-name
Switch to your new branch to being work
git checkout new-branch-name
Don't forget to make regular commits!
Make regular commits to your branch to back up your work.
git add .
git commit -m "describe changes"
git push origin new-branch-name
At any point you can make sure you're in the desired branch with
git status
Merge the branches when ready
When you have completed the work on your branch, merge it into the main branch and push it to the remote repository.
git checkout main
git merge new-branch-name
git push origin main
Once each person has done this, the main branch should be up to date with your project!
Top comments (0)