刘总的笔记小站

生活常识,娱乐搞笑,编程技巧,智能家居,深度学习,网络神经,数据挖掘

吉特git命令操作整理

#################################################################################

# 初始化主干库
git clone git@xxx # 拉库
git init xxx      # 建库

# 创建本地远端分支
git checkout -b branch_and origin/master
git push origin branch_and

# 添加变化流程:
git add -A     //添加本目录下所有新添加的文件
git commit -m "fix issue"  //描述添加文件
git push origin branch_and   //更新

# 提交远端代码
git push origin branch_and

# 提交远端主干 ---权限暂不支持
git checkout master
git merge --no-ff -m "merge master to branch" branch_and
git push origin master

# 添加变化文件:
git add -A  提交所有变化
git add -u  提交被修改(modified)和被删除(deleted)文件,不包括新文件(new)
git add .   提交新文件(new)和被修改(modified)文件,不包括被删除(deleted)文件
git status  查看未提交/提交的文件状态,指的是还未推送到远端库的本地变更
git diff    查看本次所有的改动,不包含新增文件
git log --name-status 每次修改的文件列表, 显示状态
git log --name-only 每次修改的文件列表
git log --stat 每次修改的文件列表, 及文件修改的统计
git whatchanged 每次修改的文件列表
git whatchanged --stat 每次修改的文件列表, 及文件修改的统计
git show 显示最后一次的文件改变的具体内容
git ls-files 查看已存放的文件

# 切换远端分支
git checkout master
git checkout master

# 解决冲突还原
# ---未提交
git log
git reset --soft|--mixed|--hard <commit_id> #保留源码|仅回退commit可再次commit|源码提交全部会退
git reset --hard origin/branch_and
# ---已提交
git revert <commit_id>
git push origin branch_and

# 删除本地分支
git branch -d branch_and #必须全部提交
git branch -D branch_and # -d --force强制执行

# 删除远端分支
git push origin --delete branch_and

# 主干反合分支
git checkout master
git pull
git reset --hard origin/master
git checkout branch_and
git merge --no-ff  -m "merge master to branch" master
git push origin branch_and

# 其它问题解决
git config --global core.quotepath false
git config --global core.editor vim
git config --global user.name "xxx" 
git config --global user.email "xxx"
git config -l

#################################################################################

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
搜索
«   2024年9月   »
1
2345678
9101112131415
16171819202122
23242526272829
30
网站分类
最新留言
文章归档
网站收藏
友情链接
图标汇集
Powered by Z-BlogPHP

  • Copyright ©2021 @liuzong All rights reserved.
  • 陕ICP备17016542号