git的使用
git安装地址
git.exe windows
git的使用
git cmd --help
- clone命令,从远程仓库中copy代码到本地,方式一般常用的有两种方法
1.1. https
1.2. ssh
git clone git@github.com:liweijieok/android-open-project.git
git clone https:
- 本地基本配置,git config,配置用户名和邮箱,下面是配置全局的。就是整个git环境下的,还可以去配置一些快捷,比如commit命令可以配置为cm
git config --list
git config --global user.name "youname"
git config --global user.email "youemail"
git config --gloabl alias.co checkout
git init
- 添加到git暂存区,就是可以把该文件列为git版本控制的范围
git add <filename>
git add -A
git commit -m"提交描述"
git checkout branchName
git checkout -b newBranch originBranch
git remote add origin git@github.com:liweijie/xxx.git
//其中git@github.com:liweijie/xxx.git是远程仓库的地址,有些是是ssh,有些时候是https
git remote // 不带参数,列出已经存在的远程分支
git remote -v //列出详细的信息,每一个远程分支都会带有一个url
ssh-keygen -t rsa -C youemail
git brach
git branch -a
git bracnh -r
git branch branchName
git branch -d branchName
git branch -D branchName
git branch newbranch
git checkout newbranch
git merge otherName
git pull <远程主机名> <远程分支名>:<本地分支名>
git pull origin master:master
git pull origin master
git fetch origin
git merge origin/master
git pull origin
git pull
git branch
git fetch <远程主机名>
git fetch origin
git fetch origin
git push origin localBranch:remoteBranch
git push origin localBranch
git push origin :remoteBranch
git push origin
git push -u 远程主机名 localBranch:remoteBranch
git push --all origin
git push origin --tags
git tag -a 标签号-m"标签描述"
git tag -a V1.0 -m"1.0版本完成"
git tag
git tag -l
git tag -d 标签号
//合并别的分支到当前分支
git merge branchName
git merge resultBranch feature 后者是被合并到前者那里
git status
git log localBranch ^origin/remoteBranch
git cherry -v
git stash
git stash pop
git stash list
git log
git log -n
git log --stat -n
git log -p -n
git log --pretty=online
git log --pretty=format:"格式化内容" --graph
git log --pretty=format:"%H %s" --graph -n
%H 提交对象(commit)的完整哈希字串
%h 提交对象的简短哈希字串
%T 树对象(tree)的完整哈希字串
%t 树对象的简短哈希字串
%P 父对象(parent)的完整哈希字串
%p 父对象的简短哈希字串
%an 作者(author)的名字
%ae 作者的电子邮件地址
%ad 作者修订日期(可以用 -date= 选项定制格式)
%ar 作者修订日期,按多久以前的方式显示
%cn 提交者(committer)的名字
%ce 提交者的电子邮件地址
%cd 提交日期
%cr 提交日期,按多久以前的方式显示
%s 提交说明
git rm -r --cached .
git add .
git commit -m"update .gitignore"
vi <filename>
j
k
i
Esc+":"+"wq"
Esc+":"+"q"
Esc+":"+"q!"
Esc+":"+"!"、
cat <filename>
cd <dirPath>
mkdir <dirname> <dirname2>
rm
ls
pwd
注意:命令都是小写