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:// ***链接