Loading the lesson
Loading the lesson
Forward Deployed Engineer · Programming Foundations · Lesson 9 of 10
Commits, branches, pull requests and code review.
Read the short notes and pictures.Do everything inside a blue frame.
git init
Start tracking a folder.
git add
Choose which changes go into the next snapshot.
git commit -m "message"
Save the snapshot with a note.
git push
Send your snapshots to GitHub.
Each snapshot is a commit. A change travels through three places before it reaches other people.
git addgit commitgit pushYou ran git commit. Can your teammate see the change on GitHub?
Try it. Make a commit, start a branch, commit there, switch back to main and merge.
$ git init $ git commit -m "First commit"
You are on feature and make a commit. What happens to main?
git pushopen PRrequest reviewapprovegit status
What has changed, and what is staged.
git diff
The exact lines that changed.
git log
The history of commits.
git pull
Bring down commits others have pushed.
You changed README.md and want it on GitHub. Write the three commands, in order.
Hint: Stage it, save it, share it.
Some files should never be committed: passwords and keys, large data files, and folders your tools rebuild. List them in a file called .gitignore and Git leaves them alone.
.gitignore
.env __pycache__/ *.csv node_modules/
What it keeps out
secrets and keys Python’s cache data files installed packages
Git stops and says CONFLICT
Two branches changed the same lines. Git will not guess which one you want.
Open the file
Between <<<<<<< and >>>>>>> you will see both versions.
Keep what is right
Edit the lines to what they should be and delete the markers.
Commit
git add the file and commit. The merge is finished.
You committed your API key, then deleted it in the next commit. Is it safe?
Keep these