Skip to content

.gitignore文件 ​

html
.gitignore文件是用来告诉Git哪些文件或目录不需要被版本控制的。当你在项目中创建
gitignore文件并列出需要被忽略的文件或目录时,Git就会在进行版本控制时自动忽略这些文
件,不会将它们包含在提交中。这对于排除编译生成的文件、临时文件、日志文件、依赖库等非
必要文件非常有用,可以保持代码仓库的整洁性和减少不必要的提交。通常.gitignore文件的
语法规则包括使用通配符(如*和?)来匹配文件名、使用斜杠(/)来指定路径、使用感叹号
(!)来取反匹配等。通过.gitignore文件,可以有效管理Git仓库中的文件和目录,确保只提
交和跟踪必要的内容。

git的基本使用 ​

git
git init
git add -A
git commit -m "msg"
git push -f url master:分支名   //直接推会覆盖指定分支


git log   //查看所有commit
git checkout <commit>   //切换commit

git分支 ​

git
git branch -a  //查看所有分支
git branch 分支名  //创建分支
git checkout 分支名  //切换分支
git merge 分支名  //合并分支
git branch -d 分支名  //删除分支

git tag ​

git
git tag -a 标签名 -m "msg"  //创建标签
git tag -d 标签名  //删除标签

设置/查看远程仓库 ​

shell
PS E:\Learning\my_blog> git remote show         //展示远程仓库
Blog
origin
PS E:\Learning\my_blog> git remote show Blog    //展示Blog仓库的url
* remote Blog
  Fetch URL: git@github.com:dudaiqi12/Blog.git
  Push  URL: git@github.com:dudaiqi12/Blog.git
  HEAD branch: main
  Remote branch:
    main tracked
PS E:\Learning\my_blog> git remote -v           //查看所有远程仓库 
Blog    git@github.com:dudaiqi12/Blog.git (fetch)
Blog    git@github.com:dudaiqi12/Blog.git (push)
origin  https://github.com/dudaiqi12/my_blog.git (fetch)     
origin  https://github.com/dudaiqi12/my_blog.git (push)      
PS E:\Learning\my_blog> git remote add 测试 地址 //添加远程仓库
PS E:\Learning\my_blog> git remote -v
Blog    git@github.com:dudaiqi12/Blog.git (fetch)
Blog    git@github.com:dudaiqi12/Blog.git (push)
origin  https://github.com/dudaiqi12/my_blog.git (fetch)     
origin  https://github.com/dudaiqi12/my_blog.git (push)      
测试    地址 (fetch)
测试    地址 (push)
PS E:\Learning\my_blog>

学 习 记 录