We’ll work in pairs: User A and User B
Set up a new repository, locally
mkdir TestRepo
cd TestRepo
git initCreate or copy over a file or two and add them to the repository.
touch ReadMe.md
[edit the file]
git add ReadMe.md
git commitGo to your GitHub account and create a new repository
Connect your local repository to GitHub
git remote add origin https://github.com/userA/TestRepoPush your local repository to GitHub
git push -u origin masterFork user A’s repository on GitHub: go to http://github.com/userA/TestRepo and click the “Fork” button.
Clone your version of that repository locally
git clone https://github.com/userB/TestRepoChange a file, and add another file
cd TestRepo
[change/copy files]
git add [filenames]
git commitPush the changes to GitHub
git pushMake a pull request:
http://github.com/userB/TestRepo)Connect to User B’s repository
git remote add userB git://github.com/userB/TestRepoFetch the changes from User B
git fetch userBCheckout their version of the repository as a local branch
git checkout -b userB userB/masterCheck that you like the changes
Use git branch to see your branches; the asterisk indicates the one you’re currently on.
Switch back to (“checkout”) your master branch
git checkout masterNote that the files are in the state that you left them.
Merge their work into your master branch.
git merge userBPush the work to github.
git pushMake another change to the file; then add, commit, and push.
Add a connection to User A’s repository
git remote add userA git://github.com/userA/TestRepoFetch User A’s latest
git fetch userACheck it out as a local branch
git checkout -b userA userA/masterTest things
Checkout your master, merge the change from User A, and push to github.
git checkout master
git merge userA
git pushadd, commit, and push.Pull User A’s change
git checkout userA
git pull userA masterGo back to your master branch and merge the change from User A.
git checkout master
git merge userAFix the merge conflict; then add, commit, push.
Make another pull request
Fetch User B’s repository
git checkout userB
git pull userB masterMerge into your master branch
git checkout master
git merge userBPush back to github
git push