git basic operation process
git status View this modification, new creation, deletion and other information (new file: new file, modified: modified file, deleted: deleted file)
git pull pull code
git add. Add all upcoming files
git add fileNamePath to add a file
git commit-'Submitted log' submitted to the local
git push submit to the git server
git another way to submit
git commit -a -m'Submitted log' Add all the files to be submitted and submit them to the local
git commit -a -m is equivalent to a collection of git add. and git commi -''commands. When you use the git commit -a -m' 'command, the above two operations will be performed
git staging
Git stash temporary storage (stored locally, and restore the project this time)
git stash pop uses the last temporary storage and deletes this temporary storage. After using this command, if there is a conflict, the terminal will display it. If there is a conflict, you need to resolve the conflict first (this avoids the conflict and submits the server to the server and keeps the conflict locally And then resolve)
git stash list view all staging
git stash clear clear all temporary storage
git stash drop [-q|--quiet] [] Delete a temporary storage, put the temporary storage ID that needs to be deleted in the brackets
git stash apply uses a temporary storage, but does not delete the temporary storage
The temporary storage is accidentally emptied, and the result is that there are needed codes in it, and there is also a way to retrieve
The git fsck --lost-found command finds out the commit object in the branch just deleted.
Then use the git show command to check whether it is correct and how to use the git merge command to retrieve it correctly
Give a chestnut :
git fsck --lost-found
Terminal display
-
Checking object directories: 100% (256/256), done.
-
Checking objects: 100% (109977/109977), done.
-
dangling commit bb01f8dfaa14ea7960d294304c61c4b401eaf2c6
-
dangling commit 0203281d5dee10835022ff6cfdcda5050a372762
And then view the version that
git show bb01f8dfaa14ea7960d294304c61c4b401eaf2c6
records the date and will be described in summary, you git stash date is a date, you will record summary is git stash operation on which a commit, found after executiongit merge bb01f8dfaa14ea7960d294304c61c4b401eaf2c6
git creates a local branch and pushes it to the server
Create and switch to branch branchName
git checkout -b branchName
Push the local branchName (before the colon) branch to the remote origin branchName (behind the colon) branch (if not, it will be created automatically)
git push origin branchName:branchName
Under such a command, if you have code locally, it will automatically switch to the new branch, so don t worry, after you make a lot of changes, you will be able to switch the branch normally and create unsuccessfully because of uncommitted code. .
problem found
If the command line promptsgit branch --set-upstream dev origin/branchName
You need to enter in the terminalgit push -u origin branchName
git rollback
Rollback version git reset --hard HEAD^
git reset --hard 1094a
Record command: git log
git reflog
Delete branch
Delete the local branch: git branch -d [branchname]
Delete the remote branch: git push origin --delete [branchname]
Transfer link: www.jianshu.com/p/afeeaea8c...