1. create the Repo 1 $ git init new-git-project
2. move to correct project
3. Chek Status (IMPORTANT!)
4. Make Changes (Create Files) 1 2 $ touch index.html$ open -a /Applications/Subli* index.html
1 2 $ mkdir css$ touch css/app.css
5. Check Status Again
6. Staging Files(git add
) 6.1 Staging all files and directories
6.2 Staging specific files 1 2 3 $ git add <file1> <file2> ... <fileN>$ git add index* css/app.css js/app.js
7. Check Status
8. Make a Commitment If not configured, configure it first
1 $ git config --global core.editor <your-editor's-config-went-here>
Commit it
Then open it in the code editor, Edit, save and close the file, then return back to the terminal
Note: you can directly add message with -m
1 $ git commit -m 'Initial commit'
Git Commit Recap The git commit
command takes files from the Staging Index and saves them in the repository.
This command:
will open the code editor that is specified in your configuration
(check out the Git configuration step from the first lesson to configure your editor)
Inside the code editor:
a commit message must be supplied
lines that start with a #
are comments and will not be recorded
save the file after adding a commit message
close the editor to make the commit
Then, use git log
to review the commit you just made!
9. git diff
see changes that have been made but haven’t been committed, yet:
10. Commit Message 书写建议
Udacity Style (For reference)
11. Having Git Ignore Files the .gitignore
file is used to tell Git about the files that Git should not track. This file should be placed in the same directory that the .git
directory is in.
Step1: Add file .gitignore
, in the same directory as .git
Step2: write the ignored file name in the .gitignore
Add the following line in it.
1 2 3 4 project.docx samples/*.jpg # All the .jpg files in 'samples' directory