The Magical git--https://github.com/gitzhengbin Basic configuration:
1. Local warehouse manager user name and email for version notes, and SSH key generation
git config--global user.name "Your name"
git config--global user.email "[Email protected]"
2. Create a repository->git init
To program the current directory git can manage the warehouse
(mkdir ABC) create a folder named ABC
(RM-RF ABC) delete a folder named ABC
-R is recursive down, no matter how many levels of directory, delete
-F is directly forcibly deleted, without any hint of meaning
(PWD) View current path
(ls-ah) View all files in a folder, including hidden fields
Basic operation:
View Warehouse current status->git status
See what changes the warehouse is currently making->git diff
See the difference between the workspace and the latest version of the repository->git diff HEAD--readme.txt
View command History->git Reflog
View commit History->git Log
Information Brief version->git log--pretty=oneline
Update files to the GIT repository
1.git Add file modification to staging area
2.git Commit Changes to commit all contents of staging area to the current branch
Attention:
Pay attention to the concept of work area and staging area
* The second modification, git add, for the first time modified->git commit
Git manages the modification, and when the git add command is placed, the first modification in the workspace is put into staging area, waiting to be committed (commit), but the second modification is not put into staging area (that is, the git add command is not executed), so git commit is only responsible for the staging area of the changes submitted, that is, only the first modification was submitted, and the second modification did not submit
Version fallback:
Back to previous version->git reset--hard head^
Back to the specified version->git reset--hard commit_id
Remote repository:
Clone a repository from GitHub to local git
->git Clone [Email protected]:gitzhengbin/gitskills.git
Remotely synchronize a local git repository with a git repository in GitHub
1. Create a new warehouse in GitHub with the warehouse named Learngit as an example
2.->git remote Add origin [email protected]:gitzhengbin/learngit.git
This step is considered to add an origin (remote library)
3.->git Push-u Origin Master
This step is to push origin to remote (GITHUB)
Which is to push the current branch master to the remote
Since the remote library is empty, when we first push the master branch, with the-u parameter, git will not only push the local master branch content to the remote new Master branch, but also associate the local master branch with the remote Master branch. Simplify commands at a later push or pull
If you update to this warehouse later, you can use->git to push Origin master.
Thank you: Teacher Liao's Blog tutorial
Git Learning Summary