基本概念
工作区
暂存区
版本库

git push <远程主机名> <本地分支名>:<远程分支名>

1:将本地的 master 分支推送到 origin 主机的 master 分支。
$ git push origin master

$ git push origin master:master

origin默认为远程主机名

 

$ git push -u origin master

上面命令将本地的master分支推送到origin主机,同时指定origin为默认主机,后面就可以不加任何参数使用git push了。

 

2:删除 origin 主机的 master 分支:
git push origin --delete master

3:restore working tree files
git checkout .

4:git查看远程仓库地址命令:

$git remote -v

git show 查看提交的详情

 

5:查看 远程仓库

git log 远程仓库名

查看所有分支:git branch -a
查看远程分支log: git log remotes/origin/master

6:设置用户名和邮箱

$ git config --global user.name “ming”
$ git config --global user.email “ming@xx.com”
$ git config --list

 

7:branch相关

git branch -vv // 查看本地分支对应的远程分支

git branch -v // 查看一个分支的最后一次提交

git checkout -b dev //创建并切换到dev分支

 

8: git push

git push –set-upstream origin master //将自己的本地分支(master)发布到远程仓库(创建分支 )

9: git commit

git commit --amend

 

1. git checkout feature/source_branch
2. git checkout -b devBranch
3. git push --set-upstream origin devBranch

git fetch -p 删除远程已经不在跟踪的分支

-p, --prune
After fetching, remove any remote-tracking references that no longer exist on the remote. Tags are not subject to pruning if
they are fetched only because of the default tag auto-following or due to a --tags option. However, if tags are fetched due to
an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the
--mirror option), then they are also subject to pruning.

 

posted on 2021-10-14 11:27  码农-编程小子  阅读(47)  评论(0编辑  收藏  举报