Git命令备忘

分支

查看远程分支: $ git branch -a
查看本地分支: $ git branch
创建本地分支:$ git branch [name] ----注意新分支创建后不会自动切换为当前分支
切换分支:$ git checkout [name]
创建新分支并立即切换到新分支:$ git checkout -b [name]

远程仓库相关

检出: $ git clone [url]
查看远程仓库:$ git remote -v
查看远程仓库:$ git remote -v
添加远程仓库:$ git remote add [name] [url]
或 git remote add origin [name] [url](如:git remote add origin git@192.168.1.2:laonan_net)

注意添加远程仓库之前要用git init初始化目录,之后要执行git add及git commit命令之后再git push

删除远程仓库:$ git remote rm [name]
修改远程仓库:$ git remote set-url --push [name] [newUrl]
For example, "name@something.com". If someone replies to you it will be via email.
For example, "http://someaddress.com"