git 使用前的配置
在使用git前,我们需要告诉git自己是谁以及自己的邮箱是什么,所以我们需要对git进行一些基本设置。
#git config --global user.name "vperson"# git config --global user.email "123465789@qq.com"
克隆远程仓库,默认克隆的是默认分支也就是master
# git clone https://git.oschina.net/fangqi96/check.gitCloning into 'check'...remote: Counting objects: 73, done.remote: Compressing objects: 100% (67/67), done.Unpacking objects: 100% (73/73), done.remote: Total 73 (delta 27), reused 0 (delta 0)Checking connectivity... done.
克隆远程仓库并指定分支
# git clone -b dev https://git.oschina.net/fangqi96/check.gitCloning into 'check'...remote: Counting objects: 73, done.remote: Compressing objects: 100% (67/67), done.remote: Total 73 (delta 27), reused 0 (delta 0)Unpacking objects: 100% (73/73), done.Checking connectivity... done.
注意:以下操作必须要进入git的目录,也就是含有.git文件的目录,否则出错
查看本地git分支:
#git branch new11* new22 new4
创建本地分支
#git checkout -b new3Switched to a new branch 'new3'
查看本地分支的hash值和说明
# git branch -v new11 fd12931 重命名文件ch_8080.sh为fsadfsdaf new22 1011eac fsafd* new3 1011eac fsafd new4 607f134 sdf
查看所有分支(本地+远程)
# git branch -a new11 new22* new3 new4 remotes/origin/dev remotes/origin/master remotes/origin/test remotes/origin/testtest
查看远程仓库地址
# git remote -vorigin git@git.oschina.net:..此处隐私..... (fetch)origin git@git.oschina.net:...此处隐私..... (push)
切换分支
# git branch new11 new22* new3 new4 # git checkout new22Switched to branch 'new22'# git branch new11* new22 new3 new4