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

4次阅读

共计 707 个字符,预计需要花费 2 分钟才能阅读完成。

(一)需要

须要把旧代码库中的指定分支,推送到新的 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)

正文完
 0