比如说有一个文件路径是这样的:code/ridesharing_for_py27/然后里面是各种代码;code/ridesharing_for_py36/first_outbound_next_inbound/里面各种代码;code/ridesharing_for_py36/no_sequence/里面各种代码,你不想每一个代码开一个repository,然后想按照这样的路径存起来,方法如下(reference: https://stackoverflow.com/questions/8775850/how-do-i-add-files-and-folders-into-github-repos):
yanglan@yanglan-IdeaPad-U430p:~/Documents/ridesharing$ git rm --cached ./code
rm 'code'
yanglan@yanglan-IdeaPad-U430p:~/Documents/ridesharing$ git add ./code
yanglan@yanglan-IdeaPad-U430p:~/Documents/ridesharing$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: code
new file: code/ridesharing_for_py27
new file: code/ridesharing_for_py36
......
deleted: ridesharing_for_py36/start time_212000_end time_213500.png
deleted: ridesharing_for_py36/start time_212500_end time_222000.png
deleted: ridesharing_for_py36/start time_214500_end time_220000.png
deleted: ridesharing_for_py36/start time_220500_end time_222000.png
deleted: scaling law of urban ride sharing.pdf
deleted: shared-vehicle mobility-on-demand systems.pdf
deleted: sid-talksimons.pdf
Untracked files:
(use "git add <file>..." to include in what will be committed)
paper/
yanglan@yanglan-IdeaPad-U430p:~/Documents/ridesharing$ git commit -m "your commit"
[master be5e9a6] your commit
3 files changed, 2 insertions(+), 1 deletion(-)
delete mode 160000 code
create mode 160000 code/ridesharing_for_py27
create mode 160000 code/ridesharing_for_py36
yanglan@yanglan-IdeaPad-U430p:~/Documents/ridesharing$ git push -u origin master
Username for 'https://github.com': YanglanWang
Password for 'https://YanglanWang@github.com':
Counting objects: 564, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (564/564), done.
Writing objects: 100% (564/564), 33.07 MiB | 3.19 MiB/s, done.
Total 564 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), done.
To https://github.com/YanglanWang/ridehsharing.git
67a9f60..942900d master -> master
Branch master set up to track remote branch master from origin.
yanglan@yanglan-IdeaPad-U430p:~/Documents/ridesharing$
最终的结果是ridesharing里的所有文件都上去了,其实我不想让下载的那些论文也上去,so, 接着调整了一下:将这些论文打包放到paper文件里上传:
yanglan@yanglan-IdeaPad-U430p:~/Documents/ridesharing$ git add ./paper
yanglan@yanglan-IdeaPad-U430p:~/Documents/ridesharing$ 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: paper/2014_tlc_factbook_data for addressing the minimum fleet problem in on-demand urban mobility.pdf
new file: paper/addressing the minimum fleet problem in on-demand urban mobility.pdf
new file: paper/efficient algorithms for finding maximum matching in graphs.pdf
new file: paper/literature review.odt
new file: paper/quantifying supplement.pdf
new file: paper/quantifying the benefits of vehicle pooling with shareability networks.pdf
new file: paper/scaling law of urban ride sharing.pdf
new file: paper/shared-vehicle mobility-on-demand systems.pdf
new file: paper/sid-talksimons.pdf
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
deleted: 2014_tlc_factbook_data for addressing the minimum fleet problem in on-demand urban mobility.pdf
deleted: addressing the minimum fleet problem in on-demand urban mobility.pdf
modified: code/ridesharing_for_py27 (modified content, untracked content)
modified: code/ridesharing_for_py36 (modified content, untracked content)
deleted: efficient algorithms for finding maximum matching in graphs.pdf
deleted: literature review.odt
deleted: quantifying supplement.pdf
deleted: quantifying the benefits of vehicle pooling with shareability networks.pdf
deleted: ridesharing_for_py36/.idea/encodings.xml
deleted: ridesharing_for_py36/.idea/misc.xml
deleted: ridesharing_for_py36/.idea/modules.xml
deleted: ridesharing_for_py36/.idea/ridesharing_for_py36.iml
deleted: ridesharing_for_py36/.idea/vcs.xml
deleted: ridesharing_for_py36/.idea/workspace.xml
deleted: ridesharing_for_py36/20150803_gaode_offboard.txt
deleted: ridesharing_for_py36/20150803_gaode_onboard.txt
......
deleted: ridesharing_for_py36/start time_220500_end time_222000.png
deleted: scaling law of urban ride sharing.pdf
deleted: shared-vehicle mobility-on-demand systems.pdf
deleted: sid-talksimons.pdf
Untracked files:
(use "git add <file>..." to include in what will be committed)
ridesharing_for_py36/without sequence/
yanglan@yanglan-IdeaPad-U430p:~/Documents/ridesharing$ git commit -m "paper"
[master 915be5c] paper
9 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 paper/2014_tlc_factbook_data for addressing the minimum fleet problem in on-demand urban mobility.pdf
create mode 100644 paper/addressing the minimum fleet problem in on-demand urban mobility.pdf
create mode 100644 paper/efficient algorithms for finding maximum matching in graphs.pdf
create mode 100644 paper/literature review.odt
create mode 100644 paper/quantifying supplement.pdf
create mode 100644 paper/quantifying the benefits of vehicle pooling with shareability networks.pdf
create mode 100644 paper/scaling law of urban ride sharing.pdf
create mode 100644 paper/shared-vehicle mobility-on-demand systems.pdf
create mode 100644 paper/sid-talksimons.pdf
yanglan@yanglan-IdeaPad-U430p:~/Documents/ridesharing$ git push -u origin masterUsername for 'https://github.com': YanglanWang
Password for 'https://YanglanWang@github.com':
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 797 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/YanglanWang/ridehsharing.git
942900d..915be5c master -> master
Branch master set up to track remote branch master from origin.
yanglan@yanglan-IdeaPad-U430p:~/Documents/ridesharing$ ^C
yanglan@yanglan-IdeaPad-U430p:~/Documents/ridesharing$