git常用命令及工具

创建并切换到新分支

$ git branch chunhong/recordTest //创建分支
$ git checkout chunhong/recordTest //切换到新分支
$ git branch //显示分支 粗略
$ git show-branch //显示分支 详细
将自己的分支push到远程仓库

$ git status //查看文件更改状态
$ git diff //对比文件更改 samples/algo_app/src/main/jni/app_auto_recharge/AutoRechargeStateMachine.cpp
$ git add . //将所有更改添加到暂存
$ git commit -m “add datarecord loop file” //提交暂存
$ git push //推到远程仓库
使用 git push 时,有时会提示fatal the current branch xxx has no upstream branch …问题,出现上述问题,说明远程并没有感知到本地新建的这个分支,可执行

$git branch --set-upstream
$git push -u origin chunhong/test // chunhong/test 是本地新建的分支
将自己的分支与dev合并

$git checkout chunhong/recordTest //切换到自己的分支
$git merge dev //与dev合并
获取别人新加的分支

git fetch origin //更新
git checkout 分支 //
git pull //将远程存储库中的更改合并到当前分支中
配置用户名和密码等

$ git config -l //列出所有配置列表
$ git config --global user.name “lichunhong” //设置git全局用户名
$ git config --unset --global user.email //移除设置
其他参考网址:

冲突解决办法:https://mp.csdn.net/mdeditor/82011703#

发布了5 篇原创文章 · 获赞 4 · 访问量 8576

猜你喜欢

转载自blog.csdn.net/zx_yangyi/article/details/100575712