Git 操作
用户名和密码
设置用户名密码
git config user.name "xxxxx"
git config user.email "xxxxx@sina.com"
清空当前保存的用户名和密码
git config --system --unset credential.helper
当使用不同账户checkout时,会遇到权限问题,此时需要清除用户名和密码,输入新的账户
保存用户名和密码
在.git/config文件中加入
[credential]
helper = store
新建本地分支并提交到远程
git checkout -b 本地分分支
git push origin 本地分支
新建本地分支关联远程分支
git checkout -b 本地分支 远程分支
删除分支
git branch -d 本地分支名
强制删除
git branch -D 本地分支名
回滚某个文件
git checkout 文件名 提交版本号
强制回滚到跟远程一致
git reset --hard FETCH_HEAD
git reset --mixed
切换本地分支指向的远程分支
git branch -u origin/other-branch 切换分支
```git pull`` 更新
git push origin 分支名 -f 强制提交到远程
LFS
初始化
git lfs install
LFS追踪
使用LFS追踪文件:
git lfs track *.dll
取消追踪
git lfs untrack *.dll
显示追踪列表
git lfs track
Submodule
#查看当前submodule
git submodule
#添加子模块
git submodule add <repoUrl> <directory name>
git submodule sync
#初始化子模块
git submodule update --init --recursive
#跟新子模块
git submodule foreach git submodule update
#清缓存
git rm --cached 子模块目录名
#删除submodule
git submodule deinit -f <directory name> #
git rm -f <directory name>
GitHub
Token访问
-
设置token: Settings -> Develop Settings -> Personal Access Tokens ->
-
设置访问token: git remote set-url origin https://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@github.com/shazi129/UnrealEngine.git