Git 操作 以及详细的 远程上传操作步骤

//git config --global user.email "xxxx@qq.com"
\\git config --global user.name "xxx"
git init  创建仓库 
git commit -m  "init"  提交仓库  -m init代表注释
git add .   //添加所有当前文件到暂存区
git commit -m "执行解释内容"  //提交到仓库
git rm a.txt 
 git commit -m "执行解释"   
每次执行完都要进行 git commit -m "执行解释内容"
git status 查看状态

git log //查看日志
git reflog 查看版本日志克通过$ git reset --hard d112e42 //d112e42 为版本号 来返回上一个版本
$ git reflog
d112e42 (HEAD -> master, origin/master) HEAD@{0}: commit: modify
b65ac1f HEAD@{1}: commit (initial): 测试


git branch dev //建立分支  dev 为分支名称 
git branch -d dev  //删除分支
git checkout dev //切换到  dev 分支

 git merge dev  //合并分支


//实现远程上传文件 到oschina  或 github 上 
1. git remote -v   查看当前的仓库
 origin  https://gitee.com/phtstudy/psr.git (fetch)  
origin  https://gitee.com/phtstudy/psr.git (push)
2. git remote remove origin //清除原来的本地仓库
3. git remote -v   //查看远程仓库
git remote remove origin  //删除仓库  origin为本地为仓库起名称
4. $git remote add origin git@gitee.com:phtstudy/psr.git //添加本地仓库  名字为 origin 地址为  git@gitee.com:phtstudy/psr.git 的仓库
git remote rename <旧名称> <新名称> 修改仓库名称
5.  $ ssh-keygen -t rsa -C "xxx@qq.com"   //设置公钥xxx@qq.com 为  git上设置的用户$ git config --global user.email "xxx@qq.com"


 6.设置公钥 
在第五步上出现公钥在本机存放的地址
$ ssh-keygen -t rsa -C "xxxx@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/lenovo-pc/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/lenovo-pc/.ssh/id_rsa.
Your public key has been saved in /c/Users/lenovo-pc/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:1nVlr+G24Blkk1rJpusH1LdbWi5McQuirs1oYpoiL+M xxxx@qq.com
The key's randomart image is:
 
//6复制  C:\Users\lenovo-pc\.ssh\id-rsa.pub文件中内容 到  https://gitee.com/profile/sshkeys  或者github中 中设置公钥


7然后通过 $ git push origin master
 可以上传内容到 github 或 oschina 上



  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值