常用git整理

作者: steamed_bun | 来源:发表于2020-10-16 12:34 被阅读0次

约定 :

  1. repository_url: git项目地址 e.g.: https://XXX/test.git
  2. repository_name: git项目名称 e.g.: test
git全局配置名字和邮箱
git config --global user.name "ccwangxue"
git config --global user.email "ccwangxue@didiglobal.com"
创建一个新仓库,并推到远程项目分支
git clone repository_url
cd test #本地一个文件目录(随便)
touch README.md # 创建一个README.md文件
git add README.md #添加文件到git
git commit -m "add README" # commit
git push -u origin master # 提交代码到远程master分支
创建一个新仓库,本地已经存在项目文件,并推到远程项目分支
git init # 初始化
git remote add origin  repository_url
git add .
git commit -m "Initial commit"
git push -u origin master

本地项目已有关联的git项目,想把本地文件推送到远程另一个项目地址(保留当前所有提交日志)

cd existing_repo # 进入本地已经存在的git地址 .git 目录
git remote rename origin old-origin # 将之前的origin修改为old-origin
git remote add origin repository_url # 将新的远程项目地址关联到origin这个名字上,注意此处的 repository_url是新项目的git地址
git push -u origin --all # 将所有的本地分支推送到远程并建立对应的远程分支
git push -u origin --tags # 推送所有的tag到远程

注:如果要指定本地分支推送的话最后两条语句换成下面的

git checkout -b branch # 切换到本地对应分支
git push origin # 再推送到远程

更新远程分支目录

git remote update origin --prune

相关文章

  • Git 常用命令整理

    Git 常用命令整理 Git 删除本地分支 git branch -D/-d branchID 例如 Git 批量...

  • 2018-07-20

    git常用命令整理 //删除远程分支 git push origin : git push origin --de...

  • 常用git整理

    约定 : repository_url: git项目地址 e.g.: https://XXX/test.git[h...

  • git 常用整理

    Git初始化项目 git 初始化 1.Git init: 创建仓库并初始化——>终端 cd到代码根目录——>git...

  • git基本命令

    整理下git常用的命令 1. 安装git(Linux环境) sudo apt-get install git 2....

  • Git常用命令整理

    一、Git 常用命令整理 命令 简要说明 git branch 查看本地所有分支 git status 查看...

  • git 常用命令

    记不住整理下, Git 常用命令 git branch 查看本地所有分支 git status 查看当前状态 gi...

  • 常用 Git 命令

    Git最常用的命令示意图 下面是我整理的常用 Git 命令清单。几个专用名词的译名如下。 Workspace:工作...

  • git简单命令手册

    常用的git命令整理 基本操作 与远程仓库的交互 rebase(变基) git pull 相当于git fetch...

  • Git 常用命令

    整理了一下在测试过程中常用的Git 命令,持续更新....... 1.git branch git branch ...

网友评论

    本文标题:常用git整理

    本文链接:https://www.haomeiwen.com/subject/ridzpktx.html