git命令更新上传分支代码
2020-07-13 本文已影响0人
g_ices
- 前言
小乌龟就是封装了git命令的界面可视化工具
也就是傻瓜式操作,个人感觉有可视化界面很傻,体现不出程序员,
不想用也不喜欢用
前戏
新建项目上传代码到git
在git网页端新建一个项目
新建项目

空项目

上传本地代码到git
git init
git add . 或者 git add filename
git commit -m 'first'
git remote add origin git@github.com:g-ices/test.git
git push -u origin master



成功上传

前面的网上一搜一大把
接下来网上搜的很迷惑的,有点不懂的
git命令更新上传主分支(master)代码
首先新建一个空的文件夹然后git bash here

克隆下来项目
git clone git@github.com:g-ices/test.git


添加文件或修改文件

上传就OK了
git add . 或者git add filename
git commit -m 'second' 引号中的文本内容每次需要和以前的不一样,每次上传都需要要写
git push -u origin master

主分支的代码更新网上也很多
git命令创建子分支(ices)并上传分支代码
首先新建一个空的文件夹然后git bash here

克隆下来项目
git clone git@github.com:g-ices/test.git


添加文件或修改文件

上传
git add .
git commit -m 'third'
git branch ices
git checkout ices
git push -u origin ices


上传成功


git命令对原有子分支(ices)上传分支代码
克隆子分支代码
git clone -b ices git@github.com:g-ices/test.git
##### -b ices 代表 branch 子分支名

创建test4.py

上传代码
git add .
git commit -m 'fourth'
git push -u origin ices

成功

git 回退版本
git log 查看旧版本号
## 回退到指定版本,不保留原更改代码
git reset --hard e377f60e28c8b84158
## 回退到指定版本,保留原更改代码,且生成新的提交
git revert e377f60e28c8b84158
## 提交代码
git push -f origin master
git 克隆指定版本代码
# 克隆项目
git clone git@github.com:g-ices/test.git
# 进入项目目录
cd test
# 查看版本号
git log
# git checkout 2d2b20f8a3a71427318664fdfdcdf484bc84ad8c(版本号)
# 回退到最新版
git pull origin master
结语:
要是子分支没有代码,需要修改主分支代码上传子分支
直接克隆主分支代码
然后上传的时候在git bash 中:
创建子分支 git branch g_ices
切换到子分支 git checkout g_ices
上传 git push -u origin g_ices
这样就ok了
一个不想做程序员的程序员