Installing Git:sudo apt-get install git config git:git config--global user.name "Your name" git config--global user Email "You Email"--global: This configuration is used by all git repositories on this machine, and of course you can specify a different username and email address for a warehouse. Create git repository: git init add File: Git add commit file: Git commit view repository current status: Git Status View File sync: Git diff view git commit log: git log--pretty= Oneline (optional) version fallback: git reset--hard head^ in Git, with HEAD for the current version, which is the latest submitted version, the previous version is head^, last is head^^, the last 100 versions are represented as head~ 100 record every git command: The git reflog workspace and the staging area workspace are the directories you see on your computer. The index in Git is the staging area. When we add the file to the Git repository, it is executed in two steps: The first step is to use the git Add adds files to the file, actually adds the file changes to the staging area, and the second step is to commit the changes with Git commit, which is actually to commit all the contents of staging area to the current branch. Undo changes: Git checkout--file git checkout-- File: means to undo all changes to the file in the workspace Readme.txt has not been placed in the staging area since the modification, now, undo the changes back to the same state as the repository; git reset HEAD File: The file in the staging area modification of the undo Readme.txt has been added to the staging area, and modified, and now, undo the changes back to the state added to the staging area. is to get this file back to the state of the last Git commit or Git add. Git checkout is actually replacing the workspace version with the version in the repository, which can be "one-click Restore", regardless of whether the workspace is modified or deleted. Scenario 1: When you mess up the contents of a file in your workspace and want to discard changes to the workspace directly, use the command git checkout -- file. Scenario 2: When you're not just messing aroundThe contents of a file in the workspace, but also added to the staging area, want to discard changes, two steps, the first step with the command Git reset head file, back to Scene 1, the second step by scene 1 operation. Scenario 3: When an inappropriate modification to the repository has been submitted, you want to revoke this commit, refer to the version fallback section, but only if it is not pushed to the remote library. Delete files: git rm filegit commit-m ' remove file ' if the files are deleted incorrectly, you can also use git checkout-file to restore the transfer encryption of git local warehouse and remote repository: 1, create SSH Key Ssh-keygen-t rsa-c "[email protected]" 2, Login to GitHub, open "account settings", "Ssh keys" page: point "Add ssh key ", fill in any title, paste the contents of the Id_rsa.pub file in the Key text box: associated remote repository and local repository: Git remote add origin [email protected]: Themoonstone/ubuntu_git.git (must be in the GIT directory) to push local content to the remote repository: Git push-u origin master ("git SSH permission when you perform this step") Denied PublicKey "error, troubleshooting the SSH service did not start (akzent)) the-u parameter associates the local and remote master to clone from the remote library: Git clone[email protected]: themoonstone/ubuntu_git.git Create and switch new branch: git checkout-b newbranch parameter-B to create and switch branch merge: git merge newbranch git Merge: Merge specified branch to current branch Delete branch: git branch-d oldbranch Force Delete branch: git branch-d oldbranch View branch merge graph: git log--graph when merging branches , plus the--NO-FF parameter can be combined using normal mode, and the merged history has branches. Another is the fast forward mode, but in this mode, delete branch will lose branch information save current work: Git stash view work site: Git stash list recovery work site: git stash apply ( Recover without deleting stash content) git stash pop (recover and delete stash content) Delete work site: Git stash drop restore specified work site: git stash [email protected]{0} To view remote Repository information: Git remote branches for local creation and remote branch: git checkout-b branch-name origin/branch-name view remote repository details: git remote-v Displays the address push branch that can be used for crawling and pushing: Git push origin master to set up the local Dev branch connection to the remote dev branch: Git branch--set-upstream dev origin/dev Crawl branch: Git pull create tag: git tag tagname specify tag information: git tag-a tagname-m ' infomation ' View all tags: git tag view specified tag: Git show tagname delete local tag: git tag-d tagname push a tag: Git push origin tagname push all tags: git push origin--tags Delete remote tag: git push origin:refs/tags/tagname Configure git display color: git config--global color.ui true ignore specifiedFile, create a. Gitignore the file to be ignored is written to the file .gitignore the file itself is put into the repository and can be versioned for. Gitignore! Force add Files: git add-f file check. gitignore:git check-ignore-v file configuration alias: Git config --global alias.st status configure git last to display the final commit message: git config--global alias.last ' log-1 ' GIT&NBSP;CONFIG&NBSP;--GLOBAL&NBSP;ALIAS.LG "Log --color --graph --pretty=format: '%cred%h%creset -%c (yellow)%d%creset %s %cgreen (%CR) %c (bold blue) <%an>%creset ' --abbrev-commit ' (
This line hasn't been studied yet.Configuration file: Git configuration information for each repository is placed in the. git/config file and the current user's Git configuration information is placed in the user's home directory. Gitcofig build git server: www.liaoxuefeng.com/wiki/ 0013739516305929606dd18361248578c67b8067c8c017b000/00137583770360579bc4b458f044ce7afed3df579123eca000
Gitlab Basic command (go to the website of Arrogant God)