- One team member creates a repo, and adds others as collaborators.
- Everyone clones the repo (no forking necessary).
- Switch to the master branch and get the lastest version
git checkout master
.git pull origin master
.
- Checkout a feature branch
git checkout -b my_branch_name
- Do your work
git add
git commit -m "your message"
- Periodically, push your branch to master so others can see it
- First time:
git push -u origin my_branch_name
- Subsequent pushes of that branch:
git push
- Your partners can checkout that branch to view your progress and give intermediate feedback.
git fetch
git checkout your_branch_name
- Push the latest version of your branch:
- switch to that branch and
git push
- Go to the github page for that repository
- Click create a new pull request
- Everyone sits down and reviews the PR for bugs, style, readability, etc.
- If any changes need to be made, they can be made on that branch and then pushed up.
- Once the branch is approved, someone clicks the
merge
button.
- Switch to master branch
git checkout master
- Pull in the lastest changes that have been merged:
git pull
- Option: merge those changes into any feature branches you've been working on:
git checkout your_branch_name
git merge master
- Identify that you're in a merge conflict:
git status
- note the files that are listed as both modified
- Open those files in your text editor.
- Identify areas tagged with
>>>>>>>>>
,==========
, and<<<<<<<<<<
.
<<<<<<< HEAD:file.txt
This is the original code in your current branch
=======
This is the modified code
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt
- Fix all the code between those lines, and remove the lines.
- Ideally, run the code locally and confirm it works.
- Commit your changes:
git add file1 file2
git commit -m "your message describing how you fixed conflict"
- Push your updated branch:
git push origin branch_name