2016年6月12日 星期日

Github 的遠端檔案操作

新增一個檔案

$ ls > test.txt
$ ls
1 README.md node-crawler.js node_modules result.json test.txt

把檔案加入git

$ git add test.txt
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

new file:   test.txt


對加入檔案的動作下個註解

$ git commit -m 'add test.txt'
[master 1b9d497] add test.txt
 1 file changed, 6 insertions(+)
 create mode 100644 test.txt

$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

推送到遠端

$ git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 323 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To https://github.com/david0932/node-crawler.git
   45e24d1..1b9d497  master -> master









刪除檔案的操作

$ git rm test.txt
rm 'test.txt'

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

deleted:    test.txt

$ git commit -m 'delete test.txt'
[master f6e5af2] delete test.txt
 1 file changed, 6 deletions(-)
 delete mode 100644 test.txt

$ git push
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 218 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
To https://github.com/david0932/node-crawler.git
   1b9d497..f6e5af2  master -> master


沒有留言: