# thanks to Mr.Chan 的私教课!
# 其他资源:
https://www.runoob.com/git/git-tutorial.html
https://www.runoob.com/w3cnote/git-guide.html
廖雪峰的教程
1. 在github平台建立一个仓库,设置权限,名字需要跟本地仓库名字一样
2. 建立本地仓库
在需要建立仓库的文件夹底下 启动 git bash
输入 git init
输入行会变成有个小括号(master),这就说明成功了
3. 编辑哪些文件需要进行同步,使用 touch .gitignore
使用记事本或者vim进行编辑,具体格式参考如下
参考链接: https://www.jianshu.com/p/ea6341224e89
# ignore .a file
# *.a
# not ignore lib.a file
# !lib.a
# only ignore TODO file under the catalogue
# /TODO
# ignore all the file under file build/
# build/
# ignore doc/notes.txt but not doc/server/arch.txt
# doc/*.txt
# ignore all .pdf files under doc/ directory
# doc/**/*.pdf
# for directory
design/
manuscript_writing/
potential articles/
4. git status
这个代码用于随时观察操作的更新
同时,如果有装 TortoiseGit 的话会看到一些变化, 比如被ignore的文件是红色感叹号等等;但是这个是真的乌龟,实时更新很慢。。。
5. commit file
在file还没有commit之前,status的输出窗口会一直说他们是untracked
(1) 用 git add . (注意,是有个 点的!)进行commit
然后会看见 status的窗口里面他们都变成绿色了,commit掉了,成功了这一步!
tortoise会把那些成功commit的文件都变成蓝色加号(ignore文件也会,加号很丑,只是为了方便识别)
(2) git commit -m "for your log file name"
e.g. git commit -m "log_adding files to master"
tortoise会把那些成功commit的文件都变成绿色打钩
6. 接下来是建立分支
以上前面的操作都是在master上的。在建立分支之前,最好保证你的master已经建立好了,这样后面建立完分支之后,他们就会自动同步到分支上,如果上面的哪一步有改动,请再次进行commit。。。
(1) git branch branchname
create a new branch
(2) git branch
check branch status
7. git to github remote 远端同步master
远端同步,其实代码就在你建完仓库的时候它会给你提供的
git remote add origin http.. git push -u origin master
8. 切换分支,远端同步分支
git checkout branchname
git push origin branchname