./git-repo/repo sync
切换到master分支
git checkout master
git reset --mixed HEAD^
添加当前目录
git add .
提交
git commit -m "shaojiang:modify Contacts"
查看状态
git status
查看分支
git branch -a
推送到远程服务器
git push aosp HEAD:refs/for/ics-mr1
创建分支:
git branch testing
要切换到其他分支,可以执行
git checkout
命令。我们现在转换到新建的 testing 分支:
git checkout testing
git status 查看当前状态
git add 将文件纳入跟踪,将其加入git index
git commit -m "message" 提交到本地数据库
git push aosp HEAD:refs/for/ics-mr1 将文件给推到服务器上指定分支
git rm fileName 移除文件(从暂存区和工作区中删除)
git rm --cached fileName 移除文件(只从暂存区中删除)
git branch 查看本地分支
git branch -r/a 查看远程分支/所有分支
git branch newBranchName 创建本地分支
git branch -D/d branchName 删除本地分支
git checkout branch 切换本地分支
git checkout file 放弃文件修改
git remote -v 查看远程版本库
git merge workBranchName 将workBranchName分支与当前分支进行合并
git reset --soft HEAD^ 把最后一次commit的记录回退,但修改保留了。多次回退需在HEAD后面加多^号
git reset --mixed HEAD^ 回退到add前的状态
git reset --hard HEAD^ 包括文件改动都一起回退了
git log -b 远程分支名 查看指定远程分支的提交日志
git diff 查看尚未暂存的更新
git pull aosp HEAD:refs/for/ics-mr1 从远程获取最新版本并merge到本地
git fetch aosp HEAD:refs/for/ics-mr1 从远程获取最新的版本到本地,不会自动merge
git remote show aosp 显示远程库aosp里的资源
git config --list 查看用户信息