github仓库repository下创建多个⽂件夹
github仓库repository下创建多个⽂件夹
步骤:
⼀、登录github创建仓库repository链接:
⼆、上传本地⽂件file1、file2
1、本地任意地⽅新建⽂件夹file并进⼊该⽂件夹,创建file1、file2,同时在file内使⽤命令初始化本地仓库:
1、git init
2、关联远程仓库
git remote add orign 远程仓库的https地址,如 # github/GitHub-xxx/my_repos.git
kkk@DESKTOP-GOHUBOC MINGW64 ~/Desktop/file
$ git init
Initialized empty Git repository in C:/Users/kkk/Desktop/file/.git/
kkk@DESKTOP-GOHUBOC MINGW64 ~/Desktop/file (master)
$ git remote add origin github/GitHub-xxx/my_repos.git
3、进⼊file1⽬录,依次使⽤如下命令:
git add .
git commit -m ‘注释’
kkk@DESKTOP-GOHUBOC MINGW64 ~/Desktop/file/file1 (master)
$ git add.
kkk@DESKTOP-GOHUBOC MINGW64 ~/Desktop/file/file1 (master)
$ git commit -m 'add file1'
[master (root-commit) 643b4c1]add file1
1file changed, 0 insertions(+), 0 deletions(-)
create mode 100644
kkk@DESKTOP-GOHUBOC MINGW64 ~/Desktop/file/file1 (master)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
../file2/
接下来push file1到远程仓库:
git push 出现失败提⽰:
$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
根据提⽰执⾏命令,可能出现以下问题:
kkk@DESKTOP-GOHUBOC MINGW64 ~/Desktop/file/file1 (master)
$ git push --set-upstream origin master
To github/GitHub-xxx/my_repos.git
![rejected]        master -> master (fetch first)
error: failed to push some refs to 'github/GitHub-KANG/my_repos.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards'in'git push --help'for details.
原因:
⼤概两个分⽀是两个不同的版本,具有不同的提交历史。
解决:
⽅法⼀:git pull origin master --allow-unrelated-histories 【允许不相关历史提交,并强制合并】
⽅法⼆:git push --force origin master 【强制提交】
我使⽤了⽅法⼀,该命令会拉仓库下的所有⽂件到本地
git pull origin master --allow-unrelated-histories
kkk@DESKTOP-GOHUBOC MINGW64 ~/Desktop/file/file1 (master)
$ git pull origin master --allow-unrelated-histories
From github/GitHub-xxx/my_repos
* branch            master    -> FETCH_HEAD
Merge made by the 'recursive' strategy.
再次使⽤git push推送file1到远程仓库,出现异常提⽰:
$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
根据提⽰输⼊命令:git push --set-upstream origin master,如果不报错则成功推送,否则如果出现OpenSSL SSL_read: Connection was reset, errno 10054,则可能是⽹络问题,可多尝试⼏次,也可使⽤命令:git config --global http.sslVerify "false"尝试解决
kkk@DESKTOP-GOHUBOC MINGW64 ~/Desktop/file/file1 (master)
repository文件夹可以删除吗
$ git push --set-upstream origin master
fatal: unable to access 'github/GitHub-xxx/my_repos.git/': OpenSSL SSL_read: Connection was reset, errno 10054
kkk@DESKTOP-GOHUBOC MINGW64 ~/Desktop/file/file1 (master)
$ git push --set-upstream origin master
Enumerating objects: 7, done.
........
file2操作同上
本⽂谨以做⽇常⼯作学习记录,如有纰漏望指点,必虚⼼学习,共同进步