git常用命令
来源:互联网 发布:网络连接错误711 编辑:程序博客网 时间:2024/06/08 11:01
1. 参考资料
2. git tag
git tag [-a | -s | -u <keyid>] [-f] [-m <msg> | -F <file>]<tagname> [<commit> | <object>]git tag -d <tagname>…git tag [-n[<num>]] -l [--contains <commit>] [--points-at <object>][--column[=<options>] | --no-column] [--create-reflog] [<pattern>…]git tag -v <tagname>…
$ git tag -m "Tag version 1.0" V1.0 3ede462
查看标签:git tag
3. 删除文件&目录
git rm a.txt
git rm -r ./abc/
git rm -rf ./abc/
4. 删除不属于git库的文件或目录
git clean -dxf: 清除git库下面相对于库本身多出的文件或目录
5. 增加文件
git add a.txt
6. 设置编辑器
export GIT_EDITOR=VI
7. 提交的时候指定模版
这个模版将用前面设置的编辑器打开
git commit -t ~/git_commit.template
8. 查看日志
git log --author=Joy
git log --author=Joy -p
git log a.java
git log --author=Joy a.java
git log --author=Joy -p a.java
9. git clone之后,回到指定的commit
10. 分支
查看所有分支,即有哪些分支:
git branch
这个命令会列出所有的分支,且前面有*的表示当前使用的分支。
切换分支:
git checkout branch_name
切换到指定的分支
merge其他分支的内容:
假如有两个分支:master(缺省会有的分支),first_branch。然后在master分支上做了一些修改,commit&push到远程了。那么在checkout到first_branch之后,可以git merge master命令,把master上所有的修改同步到当前的分支上。即命令格式为:
git merge the_other_branch_name
push时指定分支名称:
通常都是git push origin master,即推送到主分支。——小项目通常如此。
在创建了新的分支之后,就可以推送到这个新分支上,从而不影响主分支。命令:
git push origin the_branch_name
10. 回退到某个版本
git reset --hard commit_id
用这个命令会把本地的修改全部删除掉,而变成commit_id的样子。但不允许远程git库。
11. warning: LF will be replaced by CRLF
git config --gobal core.autocrlf false
12. 其他
git clone ssh://127.0.0.1/test.git -b the_main_branch
git show commit_id
git status
- git 常用命令
- Git常用命令
- git 常用命令
- git 常用命令
- git 常用命令
- git 常用命令
- GIT常用命令
- git 常用命令
- git 常用命令
- Git 常用命令
- git 常用命令
- Git常用命令
- Git常用命令
- git 常用命令
- Git 常用命令
- git常用命令
- git 常用命令
- Git 常用命令
- ACM-C+作业复数运算符重载(+与<<)
- 《星期几》 蓝桥杯复赛试题
- linux解压命令
- android中的ellipsize属性应用
- 关于结构体初始化的相关总结
- git常用命令
- 【LeetCode】Edit Distance
- AJAX技术
- 相似度度量 距离
- 数据结构与面向对象学习1
- 写给准备参加秋招的学弟学妹们~一定要来看哦~
- PCA 主成分分析
- Effective C++ Item 11 在operator= 中处理“自我赋值”
- 第十二周作业 private 继承方式下