git workflow
1) fork map-matcher.git repo
2) add ssh-keygen public key to gitlab
3) clone repo
git clone git@xxx/map-matcher.git
4) create branch proj2dist and add new files
git checkout -b branch-proj2dist
git add 1.txt
git commit -m "add 1.txt"
5) push branch to remote branch
git remote
# origin
git push origin branch-proj2dist:branch-proj2dist
6) update branch files
git add 2.txt
git commit -m "add 2.txt"
git push origin branch-proj2dist:branch-proj2dist
#config
git config --global user.name "Bob"
git config --global user.email "bob@example.com"
git config --global color.status auto
git config --global color.branch auto
git config --list
#list log
git log -5
git log --pretty=oneline --abbrev-commit
#list local branch
git branch
# list remote branch
git branch -r
# create new branch
git checkout -b new-branch origin/master
#update local branch from remote branch
git pull origin remote-branch:local-branch
#update remote branch from local branch
git push origin local-branch:remote-branch
#delete remote branch
git checkout xxx
git push origin :branch-test
git push origin --delete branch-test
#delete local branch
#for not merged branch
git checkout master
git branch -D branch-test
#for merged branch
git branch -d branch-test
error: Cannot delete the branch 'branch-test' which you are currently on.
git checkout master
git branch -d branch-test
#merge branch test1 into master
git checkout master
git merge -m "merge test1 into master" test1
# tags
git tag -a v0.1 -m "version 0.1"
git tag -l
#push tag
git push origin refs/tags/v0.1
git pull origin refs/tags/v0.1
#push/fetch all tags
git push --tags
git fetch --tags
#delete local tag
git tag -d v0.1
#delete remote tag
git push origin :refs/tags/v0.1
git push origin --delete refs/tags/v0.1
git ls-remote --heads --tags origin
# warning: LF will be replaced by CRLF
windows中的换行符为 CRLF, 而在Linux下的换行符为LF,所以在执行add . 时出现提示,解决办法:
$ rm -rf .git // 删除.git
$ git config --global core.autocrlf false //禁用自动转换
git修改远程仓库地址
1.修改命令
git remote origin set-url [url]
2.先删后加
git remote rm origin
git remote add origin [url]
git查看远程仓库
git remote -v
推送本地所有分支到远程
1 | git push --all origin |
上面命令表示,将所有本地分支都推送到origin主机。
【推荐】博客园的心动:当一群程序员决定开源共建一个真诚相亲平台
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】Flutter适配HarmonyOS 5知识地图,实战解析+高频避坑指南
【推荐】开源 Linux 服务器运维管理面板 1Panel V2 版本正式发布
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 为什么说方法的参数最好不要超过4个?
· C#.Net 筑基-优雅 LINQ 的查询艺术
· 一个自认为理想主义者的程序员,写了5年公众号、博客的初衷
· 大数据高并发核心场景实战,数据持久化之冷热分离
· 运维排查 | SaltStack 远程命令执行中文乱码问题
· C#.Net筑基-优雅LINQ的查询艺术
· 博客园众包平台:诚征3D影像景深延拓实时处理方案(预算8-15万)
· Cursor生成UI,加一步封神
· 为什么说方法的参数最好不要超过4个?
· 一个基于 .NET 8 开源免费、高性能、低占用的博客系统