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

//git config --global user.email "[email protected]"
\\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 [email protected]:phtstudy/psr.git //添加本地仓库  名字为 origin 地址为  [email protected]:phtstudy/psr.git 的仓库
git remote rename <旧名称> <新名称> 修改仓库名称
5.  $ ssh-keygen -t rsa -C "[email protected]"   //设置公钥[email protected] 为  git上设置的用户$ git config --global user.email "[email protected]"


 6.设置公钥 
在第五步上出现公钥在本机存放的地址
$ ssh-keygen -t rsa -C "[email protected]"
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 [email protected]
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 上



猜你喜欢

转载自blog.csdn.net/qq_35786291/article/details/80943709