关于前端:Day-88100-如何把Git仓库代码推送到另一个新的Git仓库中

(一)需要

须要把旧代码库中的指定分支,推送到新的Git仓库中。

(二)步骤

1、建设新的Git仓库

2、切换本地的代码仓库为新的Git仓库地址

# 更换remote
git remote set-url origin http://***.git
git remote set-url origin --push http://***.git

3、新建SSH证书增加到近程新的Git仓库所在的SSH认证代码库中

ssh-keygen -t rsa -C "email"
cat id_dev_rsa.pub 
# 复制生成的公钥到Git仓库的SSH账号中新增

# 可能会遇到没有权限的问题,须要设置全局明码
cd ~/.ssh/ 
git config --list
git config --global user.name "name"  
git config --global user.password "password"
git config --global user.email "email"

4、推送以后分支代码

// 推送代码
git push

5、切换本地分支,持续推送分支代码

// 推送代码
git checkout <分支名>

(三)附:

其余罕用Git命令

# 分支重命名
git branch -m old_name new_name
# 重命名后推送到近程
git push origin new_name
# 删除近程旧分支
git push origin --delete old_name

# git合并近程分支
git pull origin branch_name
# git合并本地分支
git merge branch_name
# git放弃/终止合并
git merge --abort

最初

我发动了前端共读会,感兴趣的搭档能够一起来读(ardenzhaogx)

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理