[git]------The basic commands of git------[mortal dust]

001. Initialize the warehouse and create a git warehouse

git init

 

002. Configure personal information

git config --global user.name <name> --------->: configure username

git config --global user.email <mailbox>--------->: configure the mailbox

git config -- list --------->: View configuration information

git config -- global user.name --------->: View username

git config --global user.email --------> : View mailbox

 

003. Add the workspace file to the cache area

git add <filename>

 

004. View file status

git status

 

 

 

005. Add the files in the cache area to the repository

git commit -m " Description of committing comments " ---------> Add the files in the buffer area to the repository and add comments

 

006. View the submitted version log

git log
 

 

007. View the latest changes to the file

git diff <file name> --------->: View the comparison of the workspace and the staging area file

git diff cached ------------>: View the comparison between the staging area and the repository files

git diff mester ------------>: View the comparison of the workspace and version area files

 

- lines that start with, are lines that only appear in source files

Lines starting with + are lines that only appear in the target file

Lines starting with a space are lines that appear in both source and object files

Differences are organized according to difference summaries. The first line of each difference summary is a positioning statement, starting with @@ and ending with @@

 

008. Version rollback

git reset --hard HEAD^ ---------> go back to the previous version

git reset --hard HEAD^^ ---------> go back to the previous version

git reset --hard HEAD~ N ---------> fallback to the Nth version N is an integer

git reset --hard version number ---------> back to the specified version

 

009. View all version numbers

git reflog

 

 010. Delete operation

git rm <file name> ---------> delete 暂存区or 分支above the file, and the workspace does not need this file

git rm -f <file name> ---------> force delete file

git rm -cached <file name> ---------> delete 暂存区or 分支on the file, but it needs to be used locally, but I don't want this file to be version controlled

 

011. git push

git push - u origin master ---------> upload the file to github

git remote ---------> View the default origin of the remote warehouse name

git remote -v ---------> View the current remote warehouse name and corresponding address

 

 

 

012. Cloning

git clone <repository address>

 

013. Create a branch

git branch --------->: View local branch list

git branch <branch name> --------->: new branch

git checkout -b <branch name> --------->: New and create branch

git checkout <branch name> --------->: switch branch

 

014, branch submission

git push origin <branch name>

 

015. Obtain the secret key and view the secret key

ssh-keygen -t rsa -C <mail name> -------> get the key


cat ~/ .ssh /id_rsa.pub -------> view key

 

016. Update the local warehouse

git fetch --all --------->: Update the latest commit-id of the branches contained in all remote repositories in git remote 

git pull --------->: Update the local library to The latest status of the remote library

 

017. Merge files

git merge <branch name>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325383530&siteId=291194637