GIT命令整理
来源:互联网 发布:人工智能 在线课程 编辑:程序博客网 时间:2024/06/04 23:36
初始化仓库:git init
添加和提交:
git add
git commit
查看状态:git status
查看文件不同:git diff
git命令历史:git reflog
git提交历史:git log
版本回退:git reset –hard commit_id。
用版本库里的版本替换工作区的版本:git checkout – file
关联一个远程库:git remote add origin git@server-name:path/repo-name.git
查看远程库信息:git remote -v
推送到远程库:git push origin branch-name
本地分支和远程分支连接:git branch –set-upstream branch-name origin/branch-name
抓取远程分支:git pull
如果提示“no tracking information”说明本地分支和远程分支的链接关系没有创建
查看分支:git branch
创建分支:git branch
切换分支:git checkout
创建+切换分支:git checkout -b
合并某分支到当前分支:git merge
合并分支并且提交:git merge –no-ff -m “merge with no-ff”
删除分支:git branch -d
强行删除分支:git branch -D
查看分支合并图:git log –graph
保存工作现场:git stash
查看保存得工作现场列表:git stash list
删除工作现场:git stash drop
恢复工作现场:
git stash apply 恢复后要用git stash drop删除工作现场。
git stash pop 直接恢复并且删除。
git stash apply stash@{0} 指定恢复哪个工作现场。
创建标签:git tag
指定标签信息:git tag -a -m “blablabla…”
用PGP签名标签:git tag -s -m “blablabla…”
-s用私钥签名一个标签-a指定标签名,-m指定说明文字
查看标签:
git tag
git show
检查一个文件是否被.gitignore忽略: git check-ignore -v filename
.gitignore模板:https://github.com/github/gitignore
好用的git命令别名:
git config –global alias.unstage ‘reset HEAD’
git config –global alias.last ‘log -1’
git config –global alias.lg “log –color –graph –pretty=format:’%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset’ –abbrev-commit”
配置文件位置:
每个仓库的Git配置文件都放在.git/config文件中。
当前用户的Git配置文件放在用户主目录下的一个隐藏文件.gitconfig中。
- GIT命令整理
- 常用git命令整理
- Git基本命令整理
- 常用git命令整理
- Git命令整理
- Git基本命令整理
- git命令整理
- Git使用命令整理
- Git命令整理
- git使用命令整理
- git 基本命令整理
- git命令整理
- git命令整理
- git基础命令整理
- GIT命令整理
- git操作命令整理
- Git命令整理
- Git 简单命令整理
- ActionBar入门教程
- 2016 USP Try-outs Gym101064
- POJ 1386 欧拉回路
- 判断nan的方法
- 使用环境变量打开.exe文件
- GIT命令整理
- POJ 3517 找规律、递推
- 解决内存溢出问题:java.lang.OutOfMemoryError
- [leetcode] 105. Construct Binary Tree from Preorder and Inorder Traversal
- 不要再退缩再浪费
- c++数组的基础知识
- [leetcode] 200. Number of Islands
- 占位
- 占位