1、初始化:一个项目只执行一次 只要有.git隐藏文件夹就ok了
git init 或者 git clone url
2、为远程github仓库生成别名(remote-name就是远程仓库的别名)
git remote add <remote-name> <url> git remote add origin git@github.com:yourName/yourRepo.git # origin是默认的远程仓库别名 (这个需要在git init 之后才能实现,方便push和clone)
3、忽略提交文件
4、修改代码后并放入暂存区
git add ./test.txt
5、提交到本地仓库
git commit "描述"
6、拉取要提交分支的最新的内容
git fetch 远程仓库名 远程的分支名:本地分支名 #本地分支名不存在的话会新建
7、检查代码冲突
git diff tmp // 将当前分支和tmp进行对比
8、合并分支
git merge tmp //合并tmp分支到当前分支
迷之自信确定代码不会冲突(比如就一个人贡献代码)可以将678合并
git fetch <remote_store_short_name> <remote_branch>[:local_branch]
9、同步到远程仓库
#将本地仓库同步到github远程仓库中 git push [remote-name] [branch-name] git push origin master #把本地分支推到远程仓库origin(origin为别名)的master默认主分支下 #注意:没有第一步设置别名那么需要改成这样: git push https://github.com/lichihua/codedemogit.git master
原文:https://www.cnblogs.com/lichihua/p/11179599.html