git/github 【繼續更新】

# 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

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章