常用命令#
1
2
3
4
5
|
git init
git add *
git add -A
git commit -m "your message"
git push -u origin master
|
git添加空文件夹的方法#
在要添加的文件夹下面新建名为.gitkeep
或.keep
的空文本文件
打标签#
删除已提交文件#
1
|
git rm -r --cached floder
|
git配合github的使用流程#
先建立本地git,编写.gitignore
文件, 然后add
和commit
#
1
2
3
|
git init
git add -A
git commit -m 'init'
|
在github上新建repository, 然后给本地项目添加远程仓库#
1
|
git remote add origin git@github.com:your_account/your_repository
|
做成这些的前提是已经将SSH Key
公钥添加到了自己的github账户列表中
push
到远程仓库#
1
|
git push -u origin master
|
从远程仓库获取更新到本地#
用fetch不会merge#
1
|
git fetch origin master
|
用pull会merge#
将远方仓库回滚#
reset有多种模式
- soft
- mixed
- hard: 回滚到指定的提交commit_id,之后的提交全部被清除
- keep
先将本地回滚
1
|
git reset --hard commit_id
|
然后强制push到远端仓库
1
|
git push -u origin main -f
|
文件add后未commit如何撤销#