GIT常用命令(小白)

95 阅读1分钟
git init # 初始化git仓库
#(执行完git init命令后,会生成一个.git目录,该目录包含了资源数据,且只会在仓库的根目录生成,并且会默认生成一个master分支。)
git init newDir #(在指定的目录下生成仓库)
git clone # 克隆一个git仓库
git clone <url> [directory]
git config #配置全局变量
git config --global user.name '你的用户名'
git config --global user.email '你的邮箱'
git status #查看文件的状态命令
git add #添加文件到缓存命令
git commit #将缓存区内容添加到仓库中,可以在后面加-m选项,以在命令行中提供提交注释
git commit -m "注释" 
git commit -am "注释"
git push #推送到远程仓库
git push -u origin master # 提交到master分支
git remote add [shortname] [url] #
git branch #查看分支命令
git branch (branchname) #创建分支命令
git checkout (branchname) #切换分支命令
git merge #合并分支命令
git branch -d (branchname) #删除分支命令
git remote rm [别名] # 删除远程仓库
git fetch # 提取远程仓库的数据,如果有多个远程仓库,我们可以在后面加仓库的别名
git merge [branchname] #将任意分支合并到到当前分支中去
git pull #相当于是从远程获取最新版本并merge到本地
git push #