Directory
Create an alias Configure user identity View user information create a repository delete a repository add a file to staging area submit a file to a repository to ignore a File View workspace status View the modified content view the differences in a file in the repository and workspace undo modification to workspace file Undo modification to workspace file has been Co MMIT Submission from workspace and buffer delete file workspace file mistakenly deleted recover in repository not deleted view History submission filter Submit Log view Brief History submission View details of a Commit view branch merge View Repository action record fallback repository see which branches are currently being created branch cut Switches to the specified branch to create and switch to the branch merge the specified branch to the current branch need to manually resolve the branch conflict disable the Fast ForWord mode Merge branch recommended Delete Branch add label for current Branch add a label with description to see all the tags that exist see the information of a tag remove tag push a tag to a remote push Send all local tags for push to remote delete remote label store current workspace State view stored workspace State Restore specified stash delete stash restore and remove the specified stash associate a local repository with a remote repository clone project from a remote repository cloning item cannot be first in the local Init version library Synchronize local content to a remote repository modify remote repository modifications to local view changes to remote repository Specifies the modification of a remote repository specified branch to a local branch that specifies a link to a remote Branch view remote Library information parameter description create an SSH KEY to build a git server
To Create an alias:
$ git config--global alias. Custom command name original command name
To Configure user identities:
$ git config--global user.name "username"
$ git config--global user.email "UserEmail"
The--global parameter indicates that this configuration is used by all git repositories on this machine. To View user information:
$ git config--global user.name
$ git config--global user.email
To create a repository:
$ git init
To delete a repository:
$ RM-RF Path/.git
add files to Staging area:
$ git add filename
You add multiple files separated by a space.
The deletion of files is also submitted to staging area using the
$ git add--all/-a filename1 filename2 ...
submit file to repository:
$ git commit-m "descriptive information for this submission"
files to ignore:
In the project directory, create a new . Gitignore file that will ignore the file or folder name when writing to the file to view the workspace status:
$ git status
to view the content that was modified:
$ git diff
Or
$ git diff filename
to view the differences between a file in a repository and a workspace:
$ git diff HEAD--filename
undo changes to the workspace file (not committed):
$ git checkout filename
undo changes to Workspace files (commit commits):
$ git reset HEAD filename
$ git checkout filename
To delete files from the workspace and buffer:
$ git RM filename
workspace file deleted by mistake (not removed in repository):
$ git checkout--filename
View Historical submission information:
$ git log
filtering the Commit log
$ git log--grep=keyword
View Brief Historical submission information:
$ git log--pretty=oneline
to view the details of a commit:
$ git log id-p
To view the branch consolidation situation:
$ git log--graph
Or
$ git log--graph--pretty=oneline--abbrev-commit
To View repository operation Records:
$ git Reflog
Fallback repository:
$ git reset--hard Commit-id
Or
$ git reset--hard head^
Or
$ git reset--hard head~n
The HEAD represents the current version, ^ represents the second-to-last version, can be used with multiple,~n to fall back to the first n versions, and the next to the penultimate version. See which branches are currently included:
$ git branch-a
There is an * number in front of the current branch. To Create a branch:
$ git Branch Branch-name
switch to the specified branch:
$ git checkout branch-name
to create and switch to a branch:
$ git checkout-b branch-name
merge the specified branch to the current branch (you need to resolve the branch conflict manually):
$ git Merge Branch-name
When a branch conflict occurs, the conflicting contents of the two branch are written to the file, but no commit is made and the file is modified before committing. Disable Fast ForWord mode Merge branch (recommended):
$ git merge--no-ff-m "as a description of commit" Branch-name
To Delete a branch:
$ git branch-d branch-name
Use-D to force delete. to add a label to the current branch:
$ git tag tag-name commit-id
If you do not set Commit-id , add the label to the latest submission. to add a label with a description:
$ git tag-a tag-name-m "explanatory text" Commit-id
to view all the tags that exist:
$ git tag
to view information about a tag:
$ git show tag-name
To delete a label:
$ git tag-d tag-name
push a tag to the remote:
$ GIT push origin Tag-name
push all local tags to the remote for push:
$ GIT push origin--tags
To delete a remote tag:
$ git tag-d tag-name
$ git push origin:refs/tags/tag-name
To store the current workspace state:
$ git stash
to view the stored workspace status:
$ git Stash list
restores the specified stash:
$ git stash apply Stash@{namber}
Delete Stash:
$ git stash Drop Stash@{number}
Restore and delete the specified stash:
$ git stash pop Stash@{number}
to associate a local repository with a remote repository:
$ git Remote Add origin address
cloning a project from a remote repository (not first in the local init repository):
$ git clone address
to synchronize local content to the remote repository:
$ git push address branch-name
If the remote repository is empty (first push) plus the-u parameter. to synchronize modifications of the remote repository to Local:
$ git fetch address branchname
to see what the remote repository has modified:
$ git diff address/branch-name
to merge modifications of the specified branch of the remote repository to Local:
$ git Merge Address/branch-name
Or
$ git Pull address branch-name
When sending conflicts to a remote repository, use the pull command to fetch the latest commits from the remote branch and then merge and push them locally. Specify a link to a local branch to a remote branch:
$ git branch--set-upstream local-branch-name origin/remote-branch-name
To view Remote Library information:
$ git remote-v
parameter Description
--soft– buffers and working directories will not be changed
--mixed– default options, buffers and specified commits are synchronized, but working directory is not affected
--hard– buffers and working directories are synchronized to the specified commit
To create an SSH KEY:
$ ssh-keygen-t rsa-c "email"
The private key Id_rsa and public key Id_rsa.pubare generated in the . SSH folder of the user's home directory, and the public key contents are copied to the appropriate area of the net industry when the public key is added. build a git server:
Install Git
Create a git user to run the GIT service
$ sudo adduser git
To create a login certificate:
Import the public key of all users who need to log in to the **/home/git/.ssh/authorized_keys** file, one per line
Initialize the GIT repository:
$ sudo git init--bare name.git
Change owner to Git:
$ sudo chown-r git:git name.git
Disable Shell login:
Add the /etc/password file in the
git:x:1001:1001:,,,:/home/git:/bin/bash
Switch
git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell
The user clones the repository with the Clone command:
$ git clone git@server:/pash/name.git