github 相关命令

本文详细介绍了如何使用Git进行代码管理,包括SSH密钥的创建、代码的克隆、本地代码的提交与推送,以及如何解决重复输入账号密码的问题。此外,还讲解了如何通过回滚特定的commit来删除历史记录。

http://www.runoob.com/w3cnote/git-guide.html

创建ssh key:

$ ssh-keygen -t rsa -C "your_email@youremail.com"
一路回车,会在~/下生成.ssh文件夹,打开id_rsa.pub,复制里面的key到github上:https://github.com/settings/keys

验证是否成功
$ ssh -T git@github.com
会看到:You've successfully authenticated, but GitHub does not provide shell access ,这就表示已成功连上github。

 

克隆代码:
git clone /path/to/repository 
git clone https://github.com/xxxx/xxxxx.git


本地修改代码然后上传到github:
git add <filename>
git add *
git commit -m "代码提交信息"

上传代码:
git push origin master
 

 

每次提交都需要输入账号密码,可用以下方式解决:
git config --global credential.helper store

https://blog.youkuaiyun.com/nongweiyilady/article/details/77772602?locationNum=7&fps=1

 

 

删除commit:

$ git log 查看commit
commit 9ac4e2f3a192fbeaab4764df6ae3e0d35226024 (HEAD -> master, origin/master, origin/HEAD)
Author: xxx<xxx@xxx.com>

    just test.

commit 9e70777126c74f14c51294283348fbb6cdea483
...

commit 81b1cdd17ba7c91d011e98d58c62ac38be375a8
 

回滚到指定位置:

git reset --hard 9ac4e2f3a192fbeaab4764df6ae3e0d35226024

git push origin HEAD --force

https://blog.youkuaiyun.com/cai6811376/article/details/54248764

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值