准备上传一个项目到github上,所以在github上新建一个空项目clone到本地,然后将自己的项目放到git目录,发现提交的时候出现了很多不需要上传的文件,百度搜索git如何忽略文件和文件夹
一、在git根目录新建.gitignore文件,touch .gitignore。
二、编辑.gitignore,常用配置
- target/
- .idea/
- *.iml
- *.class
------------------------------------------------------------------------------------------------------
git回滚代码
一、回退命令
git reset --hard HEAD^ 回退到上个版本
git reset --hard HEAD~3 回退到前3次提交之前,以此类推,回退到n次提交之前
git reset --hard commit_id 退到/进到 指定commit的sha码
二、强推到远程
git push origin HEAD --force
------------------------------------------------------------------------------------------------------
git删除某一次提交
1.找到要删除commit的前一次commitid
2.git rebase -i 前一次commitid
git rebase -i 1d6b81b138f89735265900b94fcd1ec39375e7b4
3.出现编辑框,然后将需要删除的commit 前面的pick改为drop
4.保存退出
5.git push origin HEAD --force
$ git push
To http://192.168.3.208/jkstack-itsm/itsm.git
! [rejected] dsm-release/ID100002 -> dsm-release/ID100002 (fetch first)
error: failed to push some refs to 'http://192.168.3.208/jkstack-itsm/itsm.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.
需要pull 代码
------------------------------------------------------------------------------------------------------
查看包之间的依赖
mvn dependency:tree
------------------------------------------------------------------------------------------------------
git push 代码一直报错
1. 关闭翻墙软件。
2. 刷新本地dns缓存,ipconfig /flushdns。