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

首次建立仓库上传项目操做在上一篇http://www.javashuo.com/article/p-ebpzcvsz-ht.htmlhtml

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

 

 

 


再次更新到仓库

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

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

找回本地误删文件

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

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
相关文章
相关标签/搜索