您的位置:首页 > 其它

Git 常用指令

2016-04-09 14:52 190 查看
设置用户名和邮箱

git config - -global user.email “tony@gmail.com”

git config - -global user.name “Tony”

创建git库

git init

未add之前,撤销当前所有修改

git checkout .

创建一个branch到另一个已有commit

git branch branchname sha1-of-commit

创建一个branch到当前commit

git branch branchname head

查看操作历史

git reflog

删除分支

git branch -d “branchName”

查看所有分支

git branch -a

创建分支

git branch “branchName”

回到特定分支

git checkout “branchName”

提交

git commit -m “commitName”

git remote add命令用于添加远程主机。

git remote add <主机名> <网址>

git remote add PC-AndroidWithSocket https://github.com/MichaleChang/PC-AndroidWithSocket.git

git push命令用于将本地分支的更新,推送到远程主机。

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

git remote命令列出所有远程主机

git remote

参看远程主机的网址

git remote -v

克隆版本库的时候,所使用的远程主机自动被Git命名为origin。如果想用其他的主机名,需要用git clone命令的-o选项指定

git clone -o jQuery https://github.com/jquery/jquery.git

git remote rm命令用于删除远程主机

git remote rm <主机名>

git remote rename命令用于远程主机的改名

git remote rename <原主机名> <新主机名>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: