GIT 常用命令
来源:互联网 发布:随机密码生成算法 编辑:程序博客网 时间:2024/06/16 21:38
GIT 常用命令
git
参考:码云 - Git OSChina、Git使用说明
- 配置Git
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
git config --global http.proxy http://127.0.0.1:8088 配置代理
git config --global credential.helper store 免输密码
- 创建SSH Key
ssh-keygen -t rsa -C "youremail@example.com"
- 远程添加-关联仓库、删除远程仓库
git remote add origin git@git.oschina.net:lvmq/m2.git
git remote add origin https://git.oschina.net/lvmq/m2.git
git remote remove (branch name) 取消远程仓库的关联
git push -u origin master 第一次提交代码至远程仓库需要用 -u参数
git push origin --delete serverfix 删除远程serverfix分支
If you already have a file checked in, and you want to ignore it, Git will not ignore the file if you add a rule later. In those cases, you must untrack the file first, by running the following command in your terminal:
git rm --cached readme.txt 删除版本管理文件,忽略不必要的管理文件
git rm --cached FILENAME 忽略文件的变动,不提交,相当于先从版本控制中删除,再加入ignore file中
- 删除版本管理文件,忽略不必要的管理文件
If you already have a file checked in, and you want to ignore it, Git will not ignore the file if you add a rule later. In those cases, you must untrack the file first, by running the following command in your terminal:
git rm --cached FILENAME 忽略文件的变动,不提交,相当于先从版本控制中删除,再加入ignore file中
- Git 代码常用命令
git init 在指定目录下,使其成为一个repository
rm -rf .git 指定目录下,删除.git文件,取消repository
git clone https://**/zhongche.git Clone远程仓库
git status 查看文件当前状态
git add readme.txt
git add 一次命令只添加一个文件 用*代替可多个
git update-index --assume-unchanged PATH 在PATH处输入要忽略的文件
git commit -m "write some messages"
git commit 一次提交前N次Add的文件
git diff readme.txt 查看文件改动的地方
git checkout (--) readme.txt 放弃修改或删除 改动会被回滚
git log (--pretty=oneline)查看提交历史
git reflog 查看历史操作命令
cat filename 查看文件内容
git reset --hard commitId 回退到某一版本并且放弃所有的修改
git reset commitId 回退到某一版本但保存自该版本起的修改
git commit --amend 修改最后一次提交的信息描述
git push origin master 与远程代码同步
- Git 分支管理
git checkout -b dev 创建并切换至新的分支
git branch dev 创建dev分支
git checkout dev 切换分支
git branch 查看分支情况
git merge dev 把dev分支合并到当前分支
git merge --no-ff -m "merge with no-ff" dev 普通模式合并 可查看合并历史记录
git branch -d dev删除dev 分支
git branch -D feature-vulcan 合并失败后 强制删除分支
git Merge保存后有冲突 先手工处理 然后重新Add、Commit一次 提交处理冲突
git log --graph --pretty=oneline --abbrev-commit 查看分支合并情况
- Git stash 保存分支
git stash 保存现场工作
git stash list 查看保存现场的记录
git stash pop 恢复现场
- Git 多人协作
git remote 查看远程库情况
git remote -v 查看远程库详细信息
- Git 标签
命令git tag <name> 用于新建一个标签,也可以指定一个commit id
git tag -a <tagname> -m "blablabla..." 可以指定标签信息;
git tag -s <tagname> -m "blablabla..." 可以用PGP签名标签;
git tag 可以查看所有标签。
git push origin <tagname> 可以推送一个本地标签;
git push origin --tags 可以推送全部未推送过的本地标签;
git tag -d <tagname> 可以删除一个本地标签;
git push origin :refs/tags/<tagname> 可以删除一个远程标签。
阅读全文
0 0
- git 常用命令
- Git常用命令
- git 常用命令
- git 常用命令
- git 常用命令
- git 常用命令
- GIT常用命令
- git 常用命令
- git 常用命令
- Git 常用命令
- git 常用命令
- Git常用命令
- Git常用命令
- git 常用命令
- Git 常用命令
- git常用命令
- git 常用命令
- Git 常用命令
- C语言笔记——C语言编程01
- pycharm 选中多个单词,类似于sublime的 Ctrl + D
- object detection学习
- 世上最完美redis操作工具类
- socket使用
- GIT 常用命令
- Unity进阶修炼之路(一)——MonoBehaviour
- repo小技巧(持续updatingV2017.08.17)
- python 机器学习实战KNN
- 【拜小白opencv】13-Mat类中几种常用函数用法;行、列显示等
- ubuntu16.04中安装Kinect v2的ROS接口出错
- 树状数组求区间最大值(树状数组)(复习)
- #426 (Div. 2) A. The Useless Toy
- G