关于gitlab常用操作

1.关于gitlab添加文件

添加文件:新建文件test,执行

        git pull --rebase
        git add .
        git commit
        #git commit -m 'add test'
        git push
        或者等价于
        
        git fetch 
        git rebase
        git add .
        git commit
        #git commit -m 'add test'
        git push
特殊情况处理:
1. git add . 出错,使用 git rebase --abort重来
2. git commit 出错,使用 git stash保存回退
3. git status //查看当前状态
4. git commit -amend 需要重新对上次提交进行修改

2.设置和清除用户名邮箱

查看git全局配置信息
git config --list --global
清除用户名和邮箱
git config --global --unset user.name
git config --global --unset user.email
设置用户名和邮箱
git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"

3. 撤销commit操作

git reset --soft HEAD^
git commit -m 'add'

4. 删除文件 test

1.删除名为test文件或者文件夹(本地不删除),需要自己手动删除一下本地

        git fetch
        git rebase
        git rm test
        git commit -m 'delete test'
        git push
  2.不使用git rm -r命令删除,直接从本地删除
        
        git fetch
        git rebase
        rm -rf test
        git add .
        git commit -m 'delete test'
        git push

5. 更改文件名

 git mv <oldpath> <newpath> 	#rename file or dir

6.获取最近提交内容

 git log -1   #查看最近1次的提交历史记录

7.获取当前branch,切换branch

git branch
git checkout branch_name

8 . 克隆文件

        mkdir gittest
        cd gittest/
        git clone ssh:// ***链接
        

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值