GIT远程版本管理

it2024-10-16  36

学无止境,精益求精!

十年河东,十年河西,莫欺少年穷!

1.远程仓库(https://gitee.com/)的连接

常用地址有两种形式:分别是https和SSH两种方式。区别是https需要输入gitee官方注册的用户名和密码,而SSH可以实现免密登录

仓库的创建在注册gitee后点击添加仓库即可!!!

2.如何将本地仓库关联到远程仓库?

git remote add <服务器名称> <服务器地址>

git remote add orgin <https地址>

git remote add orgin <SSH地址>

3.如何将本地仓库推送到远程仓库?

git push -u <服务器名称> <本地分支名称> 如果失败了, 1、查看远程仓储地址是否正确 git remote -v 2、查看用户名 git config user.name git config user.email 3、如果用户没有权限,则使用Admin来操作 git config --global user.name "Your_username" 4、设置下邮箱 git config --global user.email "Your_email" 5、更换到Admin的远程仓储地址 --删除 git remote rm origin --添加 git remote add origin 你的远程仓储地址

4.从远程仓库克隆

将远程仓库克隆到本地 git clone <远程仓库地址> <本地目录名>

git clont <远程仓库地址> e:\demo1

5.拉取远程仓库中的更改到本地仓库

git pull <远程仓库地址> <远程分支名>:<本地分支名>

git pull <远程仓库地址> master:master

6.删除本地仓库到远程仓库的关联

git remote rm <服务器名称>

使用SSH连接 使用SSH相对于HTTPS的优势在于通过非对称加密保护的,并可以实现免密登录,推荐使用SSH。 1 客户端生成公钥私匙 ssh-keygen -t rsa -C “email@example.com” 2 在码云中配置公钥

​ 点击创建的仓库,

点击分支

常用命令:

列出所有分支

git branch

列出所有远程分支

git branch -r

列出所有本地和远程分支

git branch -a

新建一个分支,但依然停留在当前分支

git branch [branch-name]

新建一个分支,并切换到该分支

git checkout -b [branch]

切换到上一个分支

git checkout -

删除分支

git branch -d[branch-name]

删除远程分支

git push origin --delete[branch-name]

合并分支

git merge <branch-name>

最新回复(0)