来个常用Git代码共享命令记录

git init

初始化本地git仓库

git pull <url>

拉取远程库

git remote add <name> <url>

关联远程仓库

git add .

添加全部

git commit .

每次修改(包括增/删)都要执行

git rm --cached

不删除物理文件,仅将该文件从缓存中删除

git rm -r

不仅将该文件从缓存中删除,还会将物理文件删除,且不会回收到垃圾桶

git tag v0.1

创建轻量标签

git push yuan v0.1

需显式推送指定标签,或–tags推送所以标签

实例git push ban1(远程库) newone(本地分支):newone(远程分支)

创建并推送远程分支,git push在此后直接可用

git checkout -b/B <name>

创建本地分支,(-B)名字重复将重置

实例git remote remove yuan

删除远端库

git log --oneline --graph

查看提交历史

外链

rebase相关

问题

On branch master
nothing to commit, working tree clean

检查是否有文件可以提交

To https://github.com/zjw715/PFA2020RM-.git
 ! [rejected]        ben -> ben (fetch first)
error: failed to push some refs to 'https://github.com/zjw715/PFA2020RM-.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

==分支冲突,需要rebase ==

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值