Questions in category: GitHub (git)
软件 >> GitHub

1. git 删除远程仓库中的文件

Posted by haifeng on 2019-03-11 12:39:45 last update 2019-03-11 12:39:45 | Answers (0) | 收藏


haife@hp MINGW64 /d/download/github/haifeng2017/calculator (master)             
$ git pull                                                                      
Already up to date.  

或者先下载

haife@hp MINGW64 /d/download/github/haifeng2017                                 
$ git clone https://github.com/haifeng2017/calculator.git                       
Cloning into 'calculator'...                                                    
remote: Enumerating objects: 42, done.                                          
remote: Counting objects: 100% (42/42), done.                                   
remote: Compressing objects: 100% (24/24), done.                                
remote: Total 42 (delta 9), reused 38 (delta 8), pack-reused 0                  
Unpacking objects: 100% (42/42), done.                                          

 

haife@hp MINGW64 /d/download/github/haifeng2017                                 
$ cd calculator                                                                 

 

haife@hp MINGW64 /d/download/github/haifeng2017/calculator (master)             
$ ls -la                                                                        
total 214                                                                       
drwxr-xr-x 1 haife 197609      0 3月  11 12:28 ./                               
drwxr-xr-x 1 haife 197609      0 3月  11 12:28 ../                              
drwxr-xr-x 1 haife 197609      0 3月  11 12:28 .git/                            
drwxr-xr-x 1 haife 197609      0 3月  11 12:28 .vs/                             
drwxr-xr-x 1 haife 197609      0 3月  11 12:28 calculator/                      
-rw-r--r-- 1 haife 197609    902 3月  11 12:28 calculator.sln                   
-rw-r--r-- 1 haife 197609 199680 3月  11 12:28 calculator.suo                   
-rw-r--r-- 1 haife 197609    131 3月  11 12:28 README.md                        
-rw-r--r-- 1 haife 197609    108 3月  11 12:28 readme.txt                       
drwxr-xr-x 1 haife 197609      0 3月  11 12:28 Release/                         

我们要删除文件 calculator.suo, 文件夹 .vs/  和 Release/

以及 calculator/calculator.vcxproj.filters 和 calculator/calculator.vcxproj.user

 

haife@hp MINGW64 /d/download/github/haifeng2017/calculator (master)             
$ cd calculator                                                                 
                                                                                
haife@hp MINGW64 /d/download/github/haifeng2017/calculator/calculator (master)  
$ ls                                                                            
BigNumber.cpp   calculator.vcxproj          ReadMe.txt  stdafx.h                
BigNumber.h     calculator.vcxproj.filters  sqrt.cpp    targetver.h             
calculator.cpp  calculator.vcxproj.user     stdafx.cpp  Variable.h              
                                                                                
haife@hp MINGW64 /d/download/github/haifeng2017/calculator/calculator (master)  
$ git rm calculator.vcxproj.filters                                             
rm 'calculator/calculator.vcxproj.filters'                                      
                                                                                
haife@hp MINGW64 /d/download/github/haifeng2017/calculator/calculator (master)  
$ git rm calculator.vcxproj.user                                                
rm 'calculator/calculator.vcxproj.user'                                         
                                                                                
haife@hp MINGW64 /d/download/github/haifeng2017/calculator/calculator (master)  
$ ls                                                                            
BigNumber.cpp  calculator.cpp      ReadMe.txt  stdafx.cpp  targetver.h          
BigNumber.h    calculator.vcxproj  sqrt.cpp    stdafx.h    Variable.h           

 

haife@hp MINGW64 /d/download/github/haifeng2017/calculator/calculator (master)  
$ cd ..                                                                         
                                                                                
haife@hp MINGW64 /d/download/github/haifeng2017/calculator (master)             
$ ls                                                                            
calculator/  calculator.sln  calculator.suo  README.md  readme.txt  Release/    
                                                                                
haife@hp MINGW64 /d/download/github/haifeng2017/calculator (master)             
$ git rm calculator.suo                                                         
rm 'calculator.suo'                                                             

 

haife@hp MINGW64 /d/download/github/haifeng2017/calculator (master)             
$ git rm -r .vs/                                                                
rm '.vs/calculator/v14/.suo'                                                    

 

haife@hp MINGW64 /d/download/github/haifeng2017/calculator (master)             
$ git commit -m "delete some nonrelated files"                                  
[master a68286d] delete some nonrelated files                                   
 5 files changed, 51 deletions(-)                                               
 delete mode 100644 .vs/calculator/v14/.suo                                     
 delete mode 100644 calculator.suo                                              
 delete mode 100644 calculator/calculator.vcxproj.filters                       
 delete mode 100644 calculator/calculator.vcxproj.user                          
 delete mode 100644 readme.txt                                                  
                                                                                
haife@hp MINGW64 /d/download/github/haifeng2017/calculator (master)             
$ git push                                                                      
Enumerating objects: 5, done.                                                   
Counting objects: 100% (5/5), done.                                             
Delta compression using up to 4 threads                                         
Compressing objects: 100% (3/3), done.                                          
Writing objects: 100% (3/3), 308 bytes | 154.00 KiB/s, done.                    
Total 3 (delta 2), reused 0 (delta 0)                                           
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.           
To https://github.com/haifeng2017/calculator.git                                
   3487c12..a68286d  master -> master                                           

 

 

2. [git] 更新仓库中的内容并上传

Posted by haifeng on 2019-03-08 23:39:34 last update 2019-04-07 10:35:10 | Answers (0) | 收藏


haife@hp MINGW64 /d/download/github/calculator (master)                         
$ git status                                                                    
On branch master                                                                
Your branch is up to date with 'origin/master'.                                 
                                                                                
Changes not staged for commit:                                                  
  (use "git add ..." to update what will be committed)                    
  (use "git checkout -- ..." to discard changes in working directory)     
                                                                                
        modified:   .vs/calculator/v14/.suo                                     
        modified:   Release/calculator.exe                                      
        modified:   calculator/BigNumber.cpp                                    
        modified:   calculator/BigNumber.h                                      
        modified:   calculator/calculator.cpp                                   
                                                                                
no changes added to commit (use "git add" and/or "git commit -a")               
                                                                                
haife@hp MINGW64 /d/download/github/calculator (master)                         

然后执行 git add -u 或者 git add .

重新查询状态

git status

git commit (写评注)

haife@hp MINGW64 /d/download/github/calculator (master)                         
$ git commit                                                                    
[master 3487c12] 1. BigNumber.cpp 中的 ChangeInfix() 函数在debug时导致如下错误:
 String subscript out of Range 现在已经修复, 详见 ChangeInfix()的定义.          
 5 files changed, 335 insertions(+), 29 deletions(-)                            
 rewrite .vs/calculator/v14/.suo (66%)                                          
 rewrite Release/calculator.exe (82%)                                           
                                                                                
haife@hp MINGW64 /d/download/github/calculator (master)                         
$ git push origin master  

 

 

3. git 出错

Posted by haifeng on 2019-02-18 10:40:20 last update 2019-02-18 10:40:20 | Answers (0) | 收藏


$ git push origin master
fatal: HttpRequestException encountered.
   发送请求时出错。
Everything up-to-date

 

References:

https://www.cnblogs.com/suntao666/p/9298571.html

这个的原因是github禁用了TLS1.0/1.1协议,github禁用了对弱加密的支持,我们可以对 git for windows 更新到最新的版本或者去更新windows的git凭证管理器,这样就可以了。

 

4. 首次提交 calculator 至 github

Posted by haifeng on 2019-02-18 10:11:07 last update 2019-05-02 20:07:29 | Answers (0) | 收藏


首先登录 github.com, 创建一个空项目 calculator, 属性 private.

复制地址, 比如 https://github.com/haifeng2017/calculator.git

 

然后启动 git

git clone https://github.com/haifeng2017/calculator.git

haife@hp MINGW64 /d/download/github/calculator (master)
$ ls -la
total 9
drwxr-xr-x 1 haife 197609  0 2月  18 10:04 ./
drwxr-xr-x 1 haife 197609  0 2月  18 10:03 ../
drwxr-xr-x 1 haife 197609  0 2月  18 10:04 .git/
-rw-r--r-- 1 haife 197609 37 2月  18 10:04 README.md

haife@hp MINGW64 /d/download/github/calculator (master)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working tree clean

 

haife@hp MINGW64 /d/download/github/calculator (master)
$ git log
commit 5de81a63ce8e6825f088c5d833468e9f2d324dde (HEAD -> master, origin/master, origin/HEAD)
Author: Haifeng <31621528+haifeng2017@users.noreply.github.com>
Date:   Mon Feb 18 09:27:33 2019 +0800

    Initial commit

haife@hp MINGW64 /d/download/github/calculator (master)
$ ls
README.md

 

将要上传的文件拷贝到此文件夹.(对于 VS2015 C++ 项目, 下面的 .vs 文件夹和 .suo 文件不必上传)

haife@hp MINGW64 /d/download/github/calculator (master)
$ git add .vs

haife@hp MINGW64 /d/download/github/calculator (master)
$ git add calculator

haife@hp MINGW64 /d/download/github/calculator (master)
$ git add Release

haife@hp MINGW64 /d/download/github/calculator (master)
$ git add calculator.sln

haife@hp MINGW64 /d/download/github/calculator (master)
$ git add calculator.suo

haife@hp MINGW64 /d/download/github/calculator (master)
$ git add readme.txt

haife@hp MINGW64 /d/download/github/calculator (master)
$ git commit -m "First commit, version 0.444"
[master b5b10ce] First commit, version 0.444
 17 files changed, 7831 insertions(+)
 create mode 100644 .vs/calculator/v14/.suo
 create mode 100644 Release/calculator.exe
 create mode 100644 calculator.sln
 create mode 100644 calculator.suo
 create mode 100644 calculator/BigNumber.cpp
 create mode 100644 calculator/BigNumber.h
 create mode 100644 calculator/ReadMe.txt
 create mode 100644 calculator/Variable.h
 create mode 100644 calculator/calculator.cpp
 create mode 100644 calculator/calculator.vcxproj
 create mode 100644 calculator/calculator.vcxproj.filters
 create mode 100644 calculator/calculator.vcxproj.user
 create mode 100644 calculator/sqrt.cpp
 create mode 100644 calculator/stdafx.cpp
 create mode 100644 calculator/stdafx.h
 create mode 100644 calculator/targetver.h
 create mode 100644 readme.txt

 

haife@hp MINGW64 /d/download/github/calculator (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

 

haife@hp MINGW64 /d/download/github/calculator (master)
$ git push
fatal: HttpRequestException encountered.
   发送请求时出错。
Counting objects: 24, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (24/24), 121.07 KiB | 2.58 MiB/s, done.
Total 24 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), done.
To https://github.com/haifeng2017/calculator.git
   5de81a6..b5b10ce  master -> master

 

5. 在 github 上修改密码后,使用 git clone 提示用户密码错误

Posted by haifeng on 2019-02-18 09:57:06 last update 2019-02-18 10:10:05 | Answers (1) | 收藏


 

haife@hp MINGW64 /d/download/github
$ git clone https://github.com/haifeng2017/calculator.git
Cloning into 'calculator'...
fatal: HttpRequestException encountered.
   发送请求时出错。
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/haifeng2017/calculator.git/'