Git 简单使用

资料来源: https://docs.gitlab.com/ee/gitlab-basics/start-using-git.html

gitlab搭建:https://www.jianshu.com/p/f1a3d7517572

设置分支提交人名称

git config --global user.name "YOUR_USERNAME"

设置分支提交人 邮箱

git config --global user.email "[email protected]"

查看设置的信息:

git config --global --list

查看远程仓库组:

git remote -v

查看所有分支

git branch -a

切换分支

git checkout branch_name

创建本地分支

git checkout -b branch_name

删除本地分支

git branch -d branch_name # -d means --delete
git branch -D branch_name # -D means --delete --force

修改分支名称:

git branch -m branch_name new_ branch_name

添加远程分支

git push --set-upstream origin branch_name
or
git remote add origin branch_name

删除远程分支

git branch -r -d origin/branch_name
git push origin :branch_name

本地分支上传到远程分支

git push -u origin branch_name

查看本地分支和远程分支的代码区别:

git diff

提交代码

git add filename
git commit -a -m "commit note"
git pull

撤销最后一次本地提交

git reset --hard HEAD~1    #不可找回撤销的更改记录
git reset --soft HEAD~1     #工作副本中可以找到未撤销更改记录

取消所有暂存区的更改

git reset .

删除所有未merge的更改

git clean -f

删除本地未提交的修改

git checkout .

回退到某个commit

git reset --hard 

你可能感兴趣的:(Git 简单使用)