Git Out - Don't be Scared to Commit
Command Line Challenges
Learning to use the command line to navigate and manipulate files has been a surprisingly challenging task this week. This post is a repository of common comand line and Git commands we’ve been using in Bootcamp. I plan to update it occasionally when needed.
Git the Big Picture
Git creates snapshots of our saves and changes - it does not save the files. It’s similar to save points in a video game. Every time we create a save point (commit a snapshot), git allows us to revert to the state the file was at when we saved it.
Quick Commands
history - shows everything you’ve just typed in
clear - deletes everything from the window to make visual space
cd - change directory
git ls - get a list of things in your folder
Changing directories between jsquire and tag
AKA - Looking at a different folder
If I see | I type | To do |
---|---|---|
C:\source\jsquire [master ↑1]> | cd /source/tag | Change directories to tag |
C:\source\tag [master +2 ~0 -0 | +0 ~3 -0 !]> | git status | See what has been changed since the last time we committed |
Commiting a change in a file
This is how we save versions of jsquire and tag in GitHub.
If I see | I type | To do |
---|---|---|
C:\source\jsquire [master ↑1]> | cd /source/tag | Make sure you’re in the right folder (cd if needed) |
C:\source\tag [master +2 ~0 -0 | +0 ~3 -0 !]> | git status | See what has been changed since the last time we committed (to see if we need to commit anything |
C:\source\tag [master +2 ~0 -0 | +0 ~3 -0 !]> | git add . | Tells the command line we’re about to add a snapshot |
C:\source\tag [master +2 ~1 -0 ~]> | git commit -m "constructors and person" | Creates a new snapshot of our latest changes called “constructors and person” |
C:\source\tag [master]> | git push origin master | Git please push my code to GitHub (named origin), and please push the master branch specifically. Shortcut: git pom |
Commits
Committing changes in jsquire and resetting to the master
If I see | I type | To do |
---|---|---|
C:\source\jsquire [ThursdayAMdrill]> | git checkout master | Switched to branch 'master' |
C:\source\jsquire [master ↑1]> | git reset --hard origin/master | This makes it so jquire is now pointing to the original file |
Checkout a branch
This saves a new snapshot of our latest changes called “constructors and person”
If I see | I can type | To do |
---|---|---|
C:\source\tag [master]> | git checkout -b ioc | Moves our file to a new branch 'ioc'? |
Find the differences between files
Checking what has been changed in a file since it was committed
If I see | I type | To do |
---|---|---|
C:\source\jsquire [master ↑1]> | git diff | This lets you see what you’ve changed in a filesince you last commited |
Merging with the master file
If I see | I type | To do |
---|---|---|
C:\source\jsquire [ThursdayAMdrill]> | git checkout master | Points you at the master branch so that the program knows where to combine the files |
C:\source\jsquire [master ↑1]> | git merge ioc | Lets you integrate all the changes you’ve made into the master file |
posted by Rachel Turek Sullivan