首页 > 其他 > 详细

git使用

时间:2019-06-02 13:33:50      阅读:86      评论:0      收藏:0      [点我收藏+]

大多数Git服务器使用SSH公钥进行授权。
使用ssh-kengen为账户生成公私钥
ssh-kengen -t rsa -C ‘346255609@qq.com
会在用户.ssh目录生成公私钥文件
Generating public/private rsa key pair.
Enter file in which to save the key (/home/cc/.ssh/id_rsa): 私钥文件
Enter passphrase (empty for no passphrase): 公私钥文件是否需要密码,空不需要
Enter same passphrase again:
Your identification has been saved in /home/cc/.ssh/id_rsa.
Your public key has been saved in /home/cc/.ssh/id_rsa.pub.

登录github、gitlab平台上传公钥授权

本地设置全局git用户信息:
git config —global user.name ‘caohongchang’
git config —global user.email ‘346255609@qq.com

git下载指定分支
git clone -b 分支 giturl

git status 查看工作区相对于暂存区的差别

git add 将修改、新增从工作区添加到暂存区

git commit -m ‘注释’ 将暂存区内容添加到本地仓库

git push origin master 将本地版本库推送到远程

origin是远程主机,master表示远程的master分支

 

git log --pretty=oneline 查看日志

git reset --hard commitid 回退到指定版本

git checkout commitid /path/file  指定文件回退到指定版本

git checkout -- /path/file  撤销更改

 

git branch -a  查看所有分支,*代表当前处于哪个分支

git checkout -b 分支名字  创建并切换到新分支

git checkout dev  切换到dev分支

git branch -d dev  删除新建的本地分支dev

git push origin dev  推送新创建的分支dev到远程

git push origin --delete dev  删除远程分支

 

git remote  不带参数,列出已经存在的远程分支

git remote -v  列出详细信息

 

git使用

原文:https://www.cnblogs.com/caohongchang/p/10962581.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!