git常见命令
git cli
号表示注释,asterisk(*)星号表示可选,curly brace{}大括号表示参数
配置用户信息
git config --global user.name {your name} #to tell git who you are
git config --global user.email {your email} #to tell git what‘s your email
git提交与状态
git status #display status of current git
git add {filename} #add the file which hasn't been commit, a point(.) denotes all,git add .
git commit -m {some detail about this commit} # submit the revision and comment
git日志
git log #display detailed information about history submission records
git log --pretty=oneline #show information by one line
git log --abrev-commit #only display the first few digits of hash value
git log --all #show all of commits information
git log --graph #reflect the submission relation intuitively
题外话,alias
Oh on,it's difficult to remember!!! just use alias to abbrev code's length;
alias ll="ls -al" #use ll instead of "ls -al"
回退提交
git reset --hard {commitID} #reset to the specify version;such as "git reset --hard a3b4efd"
git reflog #view historical operational information
.gitignore
How to ignore the file which you don't want to manage? Add wildcards to ".gitignore" file to ignore which file you don't want manage;
分支
Branch
git branch #view all branch
git branch {branch_name} #create branch
git checkout {branch_name} #switch to specify branch
git checkout -b {branch_name} #create and siwtch to the branch
git merge A #merge A to current branch
git branch -d {branch_name} #delete branch
git branch -D {branch_name} #force delete
密钥
ssh -keygen -t rsa #create public key of ssh
ssh -T git@gitee.com #test connecting
cat ~/.ssh/id_rsa.pub #browse public key
远程仓库
git remote add {nickname} {your remote repository} #add remote repository
git push {remote repository nickname} {local branch} #push local branch to remote repository
git push {remote repository nickname} {local branch}:{remote branch} #Push local branch to remote branch,if local name is same of remote's ,you can omit the remote branch;
git push --set-upstream {remote repository nickname} {local branch}:{remote branch} #band local branch to remote branch,after this,you can use "git push" to intead of that;
git branch -vv #check the banding relationship
获取远程仓库
git clone {remote repository address} {*nick name} #get a remote repository,asterisk(*) denotes an optional item
git fetch {remote repository name} {remote branch name} #fetch a remote branch,but not merge;
git fetch #same with "git fetch origin,fetch all branch of origin
git pull {remote repository nickname} {remote branch} #fetch remote branch and merge to current branch;
浙公网安备 33010602011771号