8 Daily Git Practice: Cheat Sheet
Use these instructions each day you are working in your repository for good practice!
- Go to your terminal and type
git checkout main
andenter
. - Type
git pull
andenter
. This will pull the changes you made the day before and get you ready to start on a clean branch today. - Type
git branch -d {branch-name}
andenter
. Remember to replace{branch-name}
with your branch name. - You are now on
main
and we will do this again for the next lab! - Before starting anything on the lab, go to your terminal.
- Navigate to your repository using
cd
. - Create and checkout a new branch by typing
git checkout -b {new-branch-name}
. Replace the{new-branch-name}
with a new branch name. This may be something like{your-initials_date}
. - Do your work for the day.
- Once you are done, add your changes to the staging area by going back to your terminal (where you should be in your repository directory) and typing
git add {file-names}
. You can add all the files that you edited that day. If you are unsure which files changed, typegit status
to see which files have been modified and thus which should be staged for a commit! - Commit your changes by typing
git commit -m "{commit-message}"
. Replace{commit-message}
with your commit message. - Push your changes to the remote repository by typing
git push origin {new-branch-name}
. Replace{new-branch-name}
with your new branch name. - Go to your repository on GitHub.
- First go to the Code tab, change to your branch, and you will see the code that you just worked on! It is now up on GitHub!
- Click on the
Pull requests
tab. - Click on the green
New pull request
button. - Click on the green
Create pull request
button. - Click on the green
Merge pull request
button. - Click on the green
Confirm merge
button. - Delete your branch when prompted.
- You are now ready to do this all over the next day!