Git
常用命令
1 | git init |
快速别名
vim ~/.gitconfig
1 | [alias] |
常用操作
- 本地初始化并上传工程
1 | # gitee 创建一个代码仓库并复制仓库的http链接 http://gitee.com/xxx/xx.git |
如果本地工程和远程仓库内容完全不同切需要合并在一起
1
git merge --no-ff master --allow-unrelated-historires
合并最近的三次提交
1
git rebase -i HEAD~3
删除远程分支
1
git push origin --delete origin_branch_name
项目提交包含pyc如何将其删除
添加.gitignore文件到工程根目录
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83# sphinx build directories
_build/
# dotfiles
.*
!.gitignore
!.mailmap
# compiled python files
*.py[co]
__pycache__/
# setup.py egg_info
*.egg-info
# emacs backup files
*~
# hg stuff
*.orig
status
# odoo filestore
odoo/filestore
# maintenance migration scripts
odoo/addons/base/maintenance
# generated for windows installer?
install/win32/*.bat
install/win32/meta.py
# needed only when building for win32
setup/win32/static/less/
setup/win32/static/wkhtmltopdf/
setup/win32/static/postgresql*.exe
.idea
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
cmake-build-release/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# various virtualenv
/bin/
/build/
/dist/
/include/
/lib/
/man/
/share/
/src/
然后执行
1
2
3
4
5
6// 用rm命令清除一下相关的缓存内容
git rm -r --cached .
// 然重新添加提交一下
git add .
// .gitignore文件里的规则就起作用了
git commit -m 'update .gitignore'本地代码设置远程环境
1
2
3git add remote [name] [url]
git add remote origin git@xxx.git
git add remote fork git@xxx.gitPULL最后一个提交的分支
1
git clone XXX --depth=1 -b XXX
depth=1后如何获取所有提交记录
1
2git fetch origin dev:dev --unshallow
git pull dev --unshallowgit 防止提交时每次都输入账户密码
1
git config --global credential.helper store
清除缓存
1
git credential-manager uninstall