git的使用

首先在github上创建仓库,创建成功后可以看到仓库地址。

git config --global user.name "Your Real Name" 
git config --global user.email you@email.address



//first commit
git init //把这个目录变成Git可以管理的仓库
git add README.md //文件添加到仓库
git add . //不但可以跟单一文件,还可以跟通配符,更可以跟目录。一个点就把当前目录下所有未追踪的文件全部add了 
git commit -m "first commit" //把文件提交到仓库
git remote add origin 仓库地址 //关联远程仓库
git push -u origin master //把本地库的所有内容推送到远程库上



//之后的更新
git add README.md //文件添加到仓库
git commit -m "first commit" //把文件提交到仓库
git push -u origin master //把本地库的所有内容推送到远程库上

补充:关于撤销  参考

https://blog.youkuaiyun.com/u011441473/article/details/80774302

 

参考资料:https://www.cnblogs.com/specter45/p/github.html

https://blog.youkuaiyun.com/chaihuasong/article/details/37911723

 

-------------------2020.02.17更新------------------

[若git push -u origin master失败,报错! [rejected] master -> master (non-fast-forward)]

先执行git pull
然后再执行 git push --force origin master 替换原先的git push -u origin master

 

问题原因:If another person has pushed to the same branch as you, Git won't be able to push your changes. You can fix this by fetching and merging the changes made on the remote branch with the changes that you have made locally

github官网介绍:Dealing with non-fast-forward errors

https://help.github.com/en/github/using-git/dealing-with-non-fast-forward-errors

$ git fetch origin
# Fetches updates made to an online repository
$ git merge origin YOUR_BRANCH_NAME
# Merges updates made online with your local work


Or, you can simply use git pull to perform both commands at once:

$ git pull origin YOUR_BRANCH_NAME
# Grabs online updates and merges them with your local work

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值