gitGraph commit id: "A" commit id: "B" branch feature checkout feature commit id: "C" commit id: "D" checkout main commit id: "E" commit id: "F"
Working collaboratively on GitHub
February 3, 2027
For any respository on GitHub, you can add collaborators.
Go to the repository’s “Settings”
then “Collaborators”
and add their GitHub username
As long as you and your collaborators are not editing the same files,
you can push and pull to same GitHub repository.
But if you and your collaborator have conflicting commits
then you will not be able to push to the repository without first resolving the conflict.
One way to solve an out of sync local repository is to…
The default “branch” is called “master” or “main”.
This is how you have been using Git repositories so far.
The default “branch” is called “master” or “main”.
This is how you have been using Git repositories so far.
“Branches” allow you to split your GitHub repository into two (or more) states, each with their own set of commits.
Branches allow you to develop features, fix bugs, or safely experiment with new ideas in a contained area of your repository. - GitHub Docs
Branches are like copying your entire repository to a new folder.
When you are happy with the state of a branch, you will want to merge it back to the “main” repository.
GitHub calls this merge a “pull request”.
Pull requests let you tell others about changes you’ve pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch. - GitHub Docs
Once you have a branch that you want to merge back onto “main”,
Pull requests will
After a succesful pull request, you can delete the branch.
Branches are a tool and there are a lot of ways to use them in practice:
Branches complicate the flow of Git commits
but they have real benefits
Image you have two branches “main” and “feature” with the following commits:
gitGraph commit id: "A" commit id: "B" branch feature checkout feature commit id: "C" commit id: "D" checkout main commit id: "E" commit id: "F"
Conflict: If “C” and “E” both edit the same line of a file differently, then when you try to merge “feature” into “main”, Git will not know which edit to keep.
One solution is to manually resolve the conflict, then merge the branches.
VS Code has a built-in tool, the “merge editor”:
One solution is to manually resolve the conflict, then merge the branches.
gitGraph commit id: "A" commit id: "B" branch feature checkout feature commit id: "C" commit id: "D" checkout main commit id: "E" commit id: "F" merge feature
Rebase: Shift the base of your branch to the last commit on “main”.
gitGraph commit id: "A" commit id: "B" checkout main commit id: "E" commit id: "F" branch feature checkout feature commit id: "C" commit id: "D"
This only works if “C” and “E” do not edit the exact same lines of the same files. O.W. you will still have to resolve the conflict first.
GitLens is an extension for VS Code that adds additional Git functionality.
I will show you an example where we can use it to rebase.
On your homework, you will use GitLens
GitHub Issues are items you can create in a repository to plan, discuss and track work. - GitHub Docs
Each repository has an “Issues” tab, and the green “New issue” button opens the editor.
The description is Markdown, so you can add formatting, links, and task lists:
Solo projects are collaborations between your current self and your future self.
#12 and GitHub links to itCloses #12 (or Fixes #12) in a commit message or pull request description
mainmain locally and delete the branch