先在本地已有的程序文件夹创建本地仓库,将本地仓库push到远程仓库时经常报错推送失败,后来选择先创建远程仓库,将远程仓库克隆到本地,再将已有的程序文件夹复制到克隆的本地仓库中,再push,就没有报错。
下面总结一下我在项目中常用的git命令:
- 克隆远程仓库:git clone [url]
例如:$ git clone https://github.com/libgit2/libgit2
- 克隆远程仓库指定分支:git clone -b <指定分支名> <远程仓库地址>
例如:$ git clone ljy https://github.com/libgit2/libgit2
- 在克隆远程仓库的时候,自定义本地仓库的名字:git clone [url] [name]
例如:$ git clone https://github.com/libgit2/libgit2 mylibgit
- 检查当前文件状态:$ git status
- 将项目的所有文件添加到缓存中:$ git add .
- 提交更新:$ git commit
- 提交更新并带注释:$ git commit -m “信息”
例如:$ git commit -m "Story 182: Fix benchmarks for speed"
- 推送到远程仓库:git push [remote-name] [branch-name]
例如:$ git push origin master
- 提交到远程仓库的某个分支上:git push origin [本地分支名]:[远程分支名]
例如:将hello_git_branch分支提交到远程仓库的master上面:git push origin hello_git_branch:master
- 新建分支:$ git checkout -b [分支名]
例如:$ git checkout -b iss53
它是下面两条命令的简写:
$ git branch iss53
$ git checkout iss53
- 切换回 master 分支:$ git checkout master
- 分支的合并:$ git merge [分支名]
例如:$ git merge iss53
- 查看远程分支(包括本地和远程):$ git branch
- 修改本地分支名:$ git branch -m old_name new_name
- 删除本地分支:$ git branch -d <BranchName>
- 删除远程分支:$ git push origin --delete <BranchName>
1460

被折叠的 条评论
为什么被折叠?



