一、Git 安装与配置:
1.安装Git
2.生成SSH key
ssh-keygen -t rsa -C "youremail@example.com"
3.查看SSH key
cd ~/.ssh
4.生成好的公钥id_rsa.pub放到gitlab的setting->SSH keys
4.配置Git
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
6.修改.hosts文件
cd C:\Windows\System32\drivers\etc
添加一行:
0.0.0.0(ip) gitlab
7.然后在本地测试git clone
二、安装gitlab-ci-runner
三、gitlab上merge请求小建议
1.New Merge Request时一定要看Changes,检查代码。
2.合并请求时一定要检查Changes。
3.项目定制管理需谨慎。
四、git的简单使用
1.回退分支的commit状态
git reset --HEAD
git add . #这一步如果只是修改commit message不用输入
git commit -m "new commit message" #或者git commit -c ORIG_HEAD
git push <remote> <branch> -f #若还没有推送到远端,不用输入
2. 修改上一次commit的内容
git add . #这一步如果只是修改commit message不用输入
git commit --amend
#输入修改后的commit message,保存
git push <remote> <branch> -f #若还没有推送到远端,不用输入
3.清理缓存
git clean -fdx #强制清理缓存目录及文件
4.修改远程分支名
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
或者git push -u origin new_branch
浙公网安备 33010602011771号