Git常用操作命令

 

1.全局设置

git config --global user.name "lizhengguang"

git config --global user.email "zzlxxi@163.com"

 

 

2.克隆代码到本地

git clone http://192.168.2.107:30000/lizhengguang/learn-blade.git

cd learn-blade

touch README.md

git add README.md

git commit -m "add README.md"

git push -u origin master

 

 

3.推送本地代码到分支

cd learn-blade

git init

git remote add origin http://192.168.2.107:30000/lizhengguang/learn-blade.git

git add .

git commit -m "Initial commit"

git push -u origin master

 

 

4.推送本地代码到新分支

 

cd learn-blade

git remote rename origin old-origin

git remote add origin http://192.168.2.107:30000/lizhengguang/learn-blade.git

git push -u origin --all

git push -u origin --tags

 

 

5.删除远程分支

 

// view local remote addresses

git remote -v

 

// delete local remote address

git remote remove origin

 

 

6.回退指定版本

 

// https://blog.csdn.net/yxlshk/article/details/79944535

// https://www.cnblogs.com/aligege/p/10221174.html

6.1 git revert

-----------------------------------------------------

git revert -n commit

git commit -m "revert"

git push

 

6.2 git reset

-----------------------------------------------------

git log

git reset --hard commit

git push -f -u origin branch

 

 

7.本地代码合并

 

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin

git checkout -b 1.0.1-dev origin/1.0.1-dev

 

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git checkout v1.0.1

git merge --no-ff 1.0.1-dev

 

Step 4. Push the result of the merge to GitLab

git push origin v1.0.1

Tip: You can also checkout merge requests locally by following these guidelines.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值