0. Sign up on github; Install git
(When you work on someone else's existing repository, you would click Fork button here instead.)
(Open terminal $
. After entering a command, you're expected to read the output to follow this tutorial.)
$ git clone [copied-url]
creates a directory grocery-list
$ cd grocery-list
cd
stands for change directory
Open README.md
in a text editor; add orange
.
$ git status
$ git commit -m "Add orange"
-m
stands for message
The last line did nothing. An additional step is required.
$ git add README.md
$ git status
$ git commit -m "Add orange"
$ git push
This is for when working with other people.
$ git status
$ git branch
$ git branch add-pear
creates a branch
$ git branch add-watermelon
This simulates another person modifying the file before you upload your change (in step B3).
$ git checkout add-pear
switch to a branch
In README.md
, add pear
and commit it.
$ git push origin add-pear
(Back to github.)
Compare & pull request
Merge pull request
Delete branch
(Back to terminal.)
Switch to the other branch.
In README.md
, add watermelon
and commit it.
$ git pull --rebase origin main
see the first 3 diagrams of this explanation of rebase
$ git status
Edit README.md
so that we have:
apple
orange
pear
watermelon
$ git rebase --continue
$ git push origin add-watermelon
(Back to github.)
Pull request, merge, and delete branch.
(Alternatively, delete the directory and then clone
as in section 2.)
$ git checkout main
$ git pull
$ git branch -d add-pear add-watermelon
-d
stands for delete
That's it!
If you found something unclear or erroneous, please make an issue.