Reprint Please indicate the source: http://blog.csdn.net/android_ls/article/details/46287879
Git local operations
1. In the directory specified on your Mac, create a new "local repository" with the following command:
Git init
The operation on my computer is as follows:
2. Enter the directory you specified on your Mac to see what's changed and find a more. Git folder (hidden by default), if you don't see it on your Mac, you can execute the following command (show hidden files):
Defaults write Com.apple.finder Appleshowallfiles-bool true
Do not want your Mac to show hidden files, you can do the following command:
3. Configure personal information (first use)
Configure your name (tell other users on git who you are?) ), the command is as follows:
git config user.name xiewendong
Configure your e-mail address (Tell other users on git how do you contact us?) ), the command is as follows:
git config user.email [email protected]
After the configuration is complete, view it locally and the directory is as follows:
Open the config file with the following contents:
Configuration with the above command is a one-time configuration, only configured in the. git folder of managed files, to be configured once and for all, use the following configuration:
git config--global user.name xiewendonggit config--global user.email [email protected]
4, how to learn the git instructions, you can use the following instructions to view the GIT user Guide.
Git--help
This guide is actually a non-editable vim
q--Exit Guide
Press Space-Next page
Control + B-prev
/What you need to search for-you can search
5, git some common instructions
Git Status View file status git Add file name add File to "staging area" git commit file name Add file to "local repository" git commit file name-M "Here is where to write notes"
Note: The color to be added is red, representing the file in the "Workspace", and after the "git Add file name" is executed, the file is added to "staging area" and the color is green. (Workspace--Staging area--local warehouse)
6. View log Information
git log View all repository logs git log file name view repository log for specified file git reflog view branch reference records
As follows:
7. Depending on the version number, we teleport (toggle) between any version.
In Git, the version number is a hash value generated by SHA1.
Back to the previous version, the instructions are as follows:
git reset--hard head^
Back to the version of the specified version number, the instructions are as follows:
Git reset--hard version number
The practical operation is as follows:
8. Modification and management of individual files
Before committing to the local repository, review the file changes and execute the following instructions:
git diff file name
Practice the following:
To undo the modification of the file, the instructions are as follows:
git checkout file name
9, add multiple files, instructions are as follows:
git Add. Git commit-m "Modify description"
10. Attach the contents of the Main.c file:
git usage on mac (i)