首次创建仓库上传项目操作在上一篇https://www.cnblogs.com/tk55/p/11795644.html

----好记性不如烂笔头

Git笔记----Git仓库常见经典操作命令

 

 

 


不是首次更新内容或文件到远程仓库

git add .
git commit -m '注释'
// 可写可不写 git remote  add origin 仓库地址
git push -u origin master
//强制上传 git push -u origin master -f

找回本地误删文件

假如文件上传到了远程,本地不小心删了。操作如颜色所示

git status

出现
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    "\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt"

git reset HEAD \346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt
Unstaged changes after reset:
D       新建文本文档.txt
        
git checkout 新建文本文档.txt
Updated 1 path from the index

 

本地删除文件,再更新到远程

git status

$ git add .
$ git commit -m "删除本地已有的文件再更新到服务端"

$ git push -u origin master

 

 

其他操作

git pull –rebase origin master // 合并到本地git代码

git push -u origin master -f  // 强制合并远程git代码
其中 
x —–删除忽略文件已经对git来说不识别的文件 
d —–删除未被添加到git的路径中的文件 
f —–强制运行
方案1: 
git clean -d -fx “” 
git push origin master

2.git clean -i 
git pull origfin master

覆盖本地代码(或者回到上一个版本在执行git reset –hard ) 
3.git pull origin master –allow-unrelated-histories

 

相关文章:

  • 2021-07-04
  • 2021-11-30
  • 2021-08-08
  • 2021-12-25
  • 2021-12-27
  • 2021-09-21
  • 2021-08-27
  • 2021-04-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2021-09-11
  • 2021-04-03
  • 2021-10-27
  • 2021-08-10
相关资源
相似解决方案