Git

初始化

1
2
3
4
5
6
    git init  
    git add .  
    git commit -m "first commit"  
    git branch -M main  
    git remote add origin {你的github仓库地址}  
    git push -u origin main

克隆

1
2
3
4
    git clone {github仓库地址} -c http.proxy="http://127.0.0.1:7890"
    # 下载大文件时
    git lfs install
    git lfs clone {github仓库地址}

后续上传

1
2
3
    git add .  
    git commit  
    git push //若要无视pull则添加(--force)

第一行将修改同步至本地缓存区,第二行将缓存区的修改提交至本地仓库,第三行将本地仓库的修改推送至远端仓库。

分支

建立分支

1
    git checkout -b [branchname] //git 切换分支 建立并切换至新分支 新分支名

推送分支

1
    git push origin [branchname]  //git 推送 远端名称 本地分支名

版本回退

1
2
    git log //查看各提交版本  
    git reset [head~n/commit ID] --soft/hard  //回退n个版本/回退到ID表示的版本  

详细见:https://www.bilibili.com/video/BV14C4y1q78x

文件回退

1
    git checkout [版本ID] --文件名

gitignore失效

使用git rm (-r) –cached file_path移除与缓存的连接

失效解决方法

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus