今天做ctf题时涉及到git源码泄漏的问题,顺便就学一下git吧
GitHack工具下载
使用:python GitHack.py http://www.target.com/.git/
git学习
这个git教程网站还是挺好的
git暂存区文件查看
阮一峰的博客
记录以一下,以后忘记时随时查看
基础
新建文件夹下初始化
git init
添加到暂存区
git add file
暂存区提交
git commit -m "destribute"
保存现场(工作进行一半还不能git add时)
git stash
恢复现场
git stash apply
删除stash
git stash drop
恢复现场并删除
git stash pop
查看比较
查看提交历史
git log
树状图查看提交历史
git log --graph --pretty=oneline --abbrev-commit
查看编辑过的命令历史
git reflog
查看暂存区的文件
git ls-files -s
查看缓存区文件的具体内容
git cat-file -p 8ef0
和e43b开头的版本比较不同(diff = difference)
git diff e43b
查看远程库信息
git remote -v
分支操作
查看分支
git branch
创建分支
git branch name
删除分支
git branch -d name
切换分支
git checkout name
git switch name
创建并切换分支
git checkout -b name (selectname)
git switch -c name (selectname)
将name分支和当前分支合并(使用fast forward模式)
(两个分支操作同一个文件,合并后会报错,需要手动修改合并文件并提交)
git merge name
保留合并前的分支(使用normal模式)
git merge --no-ff -m "description" name
丢弃一个没有被合并过的分支,强行删除
git branch -D name
把本地未push的分叉提交历史整理成直线
git rebase
操作文件
工作区回退1层版本
git reset --hard HEAD^
工作区回退100层版本
git reset --hard HEAD-100
工作区回退到e43b开头的版本
git reset --hard e43b
工作区file恢复到最近一次git add或者git commit的状态
git checkout -\- file
删除暂存区的file,并且转移到工作区
git reset HEAD file
从版本库删除文件
git rm file
提交
首次
git remote add origin https://github.com/username/test.git
git branch -M main
git push -u origin main
以后
git push origin branchname
多人合作时同时提交一个文件,除了第一个人成功提交外,其他人会接收到一个冲突报错
git push origin branchname
有冲突
git branch --set-upstream-to=origin/name name
远程抓取分支并且在本地合并
git pull
本地解决冲突提交
设置仓库地址
git remote set-url origin https://github.com/...
下载
git clone https://github.com/username/dir ~/Document/dir
标签
在某个分支上加标签
git tag v1.2
git tag -a tagname -m "discription"
查看所以标签
git tag
删除
git tag -d tagname
上传
git push origin tagname(一个)
git push origin --tags(所有)
其他
修改颜色
git config --global color.ui true
报错
fatal: refusing to merge unrelated histories
ctf中使用的命令
git log
git diff
git stash apply
多出了个文件
等