-
Create a new repository on GitHub
-
Clone that repository locally onto your computer
git clone [email protected]:dmil/mehta-simple-website.git
-
cd
into the folder containing your project.cd ~/path/to/project
-
Check the status of your local repository to make sure you didn't forget to commit any work.
git status
-
Then pull the latest changes from the remote repository on GitHub.
git pull
-
Do a discrete chunk of work on your project (lets say you added a basic FAQ page"
-
Check the status again, then add the files you'd like to commit to the staging area.
git status git add faq.html git status
-
Commit with a descriptive summary of exactly what you did
git commit -m "add a basic FAQ page"
-
Push that change back to GitHub
git push
-
cd
into the folder containing your project.cd ~/path/to/project
-
Check the status of your local repository to make sure you didn't forget to commit any work. Run
git branch
to see which branch you're on. You should ideally be on themaster
branch.git status git branch
-
Then pull the latest changes from the master branch of the remote repository on GitHub.
git pull
-
Create a new branch with a descriptive name (remember the
-b
option will create a new branch, you can check out an existing branch by not using that option)git checkout -b faq-page
-
Do your work in discrete chunks. at the end of each chunk, add the file to the staging area, then commit it. Its usually a good idea to also push the latest to GitHub, although some people prefer to do that at the end.
Do some work
git status git add faq.html git commit -m "add blank FAQ page" git push git status
Do more work
git status git add faq.html git commit -m "add information to FAQ page" git push git status
Do more work
git status git add faq.html git commit -m "fix bug" git push git status
Do more work - lets imagine this work took place across two files, an html file and a stylesheet file.
git status git add faq.html git add style.css git commit -m "make it look pretty" git push git status
-
Once everything has been pushed to GitHub, issue a pull request from your branch back to the master branch.
-
You can have a discussion on this pull request using GitHub's social features, and then merge it into the master branch when everyone agrees its a good idea to do so.
-
Finally, once the pull request has been merged into the master branch in the remote repository on GitHub, you'll want to get the latest version of the master branch on your local machine. Checkout the master branch locally and then pull.
git checkout master git pull
- If you're stuck, ask (or come to office hours). Ihsaan and I should also be on Slack.
- Here is a video I made last year that might be of some use: https://www.youtube.com/watch?v=O4Zc8DJ9MdQ
- Here the diagram from class