git

git的常用操作

Posted by Liao on 2019-07-12

git常用操作

github上传laravel项目

1
2
3
4
5
6
7
8
9
git init

git remote add origin git@github.com:pistachioL/xxx.git

git add .

git commit -m "xxxx"

git push origin master -f

删除远程关联

git remote rm origin

创建新分支

1
2
3
4
5
6
7
git branch deepin    #新分支deepin

git branch -a #查看所有分支

git checkout -b dev origin/dev # 在本地创建一个分之dev,并且与上游的origin/dev保持一致

git checkout dev # 切换分支

git全局的用户名和密码

保存密码到硬盘

1
git config credential.helper store
1
2
3
git config --global user.name "用户名"

git config --global user.email "邮箱"

git删除远程分支操作

1
git push origin --delete branch-name

git 回滚

1
2
3
4
5
6
7
8
# 回退到上个版本
$ git reset --hard HEAD^

# 退到/进到 指定commit_id
$ git reset --hard commit_id

# 推送到远程
$ git push origin HEAD --force

git查看配置信息

1
git config --global -l

设置代理 & 取消设置

1
2
3
4
5
6
7
8
9
# 设置代理
git config --global http.proxy http://127.0.0.1:1080

git config --global https.proxy http://127.0.0.1:1080

# 取消设置
git config --global --unset http.proxy

git config --global --unset https.proxy