Different copies of the same project by folks working on the same team are called branches. Every project starts out with a "master" branch, which is the main one, but as you and your team need to add features without breaking your main project, you'll add more branches.
Normally a branch is associated to a specific feature or update, and once the feature is finished and merged back to the main or master branch, that feature branch is often removed (or "pruned"). However, when you're just starting out, it's helpful to use a simpler structure, so we're going to name our branches after the person whose environment that branch lives on.
Assuming both the owner and collaborator have cloned the repo, and that the collaborator has been given access to the repo, you're ready to create branches.
where branch-name
is replaced with your name (or any name for
the branch you're working on).
The easiest change to make at this time to avoid a merge conflict is for both you and your partner to add a new file.
Once you've made a change, follow the usual workflow to commit those changes.
Where filename
is the name of the file or files you'd like to
commit, and "description of changes"
is an actual description
of those changes.
Normally pushing changes is pretty simple:
However, you are likely to get an error telling you that there is no specified remote branch on GitHub for you to push it to. It will prompt you with code you can use to CREATE that branch.
Run the code exactly as prompted in the terminal, and you'll see that your changes are on GitHub, but are only reflected on your branch - not on the master branch. You'll only need to do this once. After the first time, git push
will assume you want to push to the remote branch that corresponds to the one you're working on locally.
Finally, it's time to create a pull request on GitHub and merge the changes back in to the master branch. It's typically good practice to have one person CREATE the pull request, and the other person MERGE the pull request, that way one person isn't unilaterally pushing in changes that might break the project.
At this stage, if you and your partner edited the same file, you might have a merge conflict. A merge conflict looks somewhat complicated, but is actually really simple to solve on GitHub. There's a browser-based tool that simply says "I found two versions of the code at this point - which version should we keep?" and once you answer all those questions, you can finish the merge.
Once both you and your partner's code has been merged to the master branch, you and your partner will each want to pull the merged version of the other's code from the remote master down onto your local branch.
If BOTH partners added, committed, pushed, and merged, this part should go without error. If not, you may have to resolve merge conflicts locally.
Finally, once all this is set up, push your local, merged code back up to your remote branch.
This should make it so that your remote code is caught up to your local code, and you'll be ready to continue on.