git最小配置
git config --global user.name xxx
git config --global user.email xxx@163.com
查看配置
git config --global --list
创建git仓库
-
已有项目下创建
cd mypro
git init
-
新建项目
git init mypro
添加file.txt到暂存区
git add file.txt
添加所有被git管理的文件到暂存区
git add -u
清除暂存区和工作目录中的变动
git reset --hard
重命名文件
git mv readme readme.md
查看log简洁版
git log --oneline
指定查看log数量
git log -n2
查看是文件类型
git cat-file -t 836a3ab3cdc5ce163d33db6f49a7c36cc7176e55
查看文件内容
git cat-file -p 836a3ab3cdc5ce163d33db6f49a7c36cc7176e55
git把内容相同的文件视为同一份
git文件类型:commit,tree,blob

dongsihengdeMBP:git_learning dsh$ git cat-file -p c0f8280
tree 6badc42ed3535e832593d1ebeac6451b4f50406f
parent 836a3ab3cdc5ce163d33db6f49a7c36cc7176e55
author dongsiheng <dsh5408@163.com> 1576919080 +0800
committer dongsiheng <dsh5408@163.com> 1576919080 +0800
dongsihengdeMBP:git_learning dsh$ git cat-file -p 6badc42e
040000 tree 9a34a2c42d881a0209846e2c29ad2b1b78ae7a51 images
100644 blob 3262d2644a0b509bfbe26cb7b993f9d3145b9f70 readme.md
100644 blob 73fb67cbfbc427d6c209ed54e33b2f938d443962 style.css
dongsihengdeMBP:git_learning dsh$ git checkout 732fa8445adeeb24ed821974aab7b8d6e6fe01ac
Note: checking out '732fa8445adeeb24ed821974aab7b8d6e6fe01ac'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 732fa84 update style.css
网友评论