{"id":20330693,"url":"https://github.com/leafney/gitupdate","last_synced_at":"2026-05-07T18:32:06.774Z","repository":{"id":92802857,"uuid":"200864569","full_name":"leafney/gitupdate","owner":"leafney","description":"自动拉取本地Git仓库最新的分支版本","archived":false,"fork":false,"pushed_at":"2019-08-06T14:32:38.000Z","size":112,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-04T09:25:08.788Z","etag":null,"topics":["git","golang"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leafney.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-06T14:09:44.000Z","updated_at":"2023-07-05T03:00:29.000Z","dependencies_parsed_at":"2023-04-07T23:07:10.021Z","dependency_job_id":null,"html_url":"https://github.com/leafney/gitupdate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leafney/gitupdate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafney%2Fgitupdate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafney%2Fgitupdate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafney%2Fgitupdate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafney%2Fgitupdate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leafney","download_url":"https://codeload.github.com/leafney/gitupdate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafney%2Fgitupdate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32750490,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","golang"],"created_at":"2024-11-14T20:17:21.940Z","updated_at":"2026-05-07T18:32:06.733Z","avatar_url":"https://github.com/leafney.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"### GitUpdate\n\n**自动拉取本地Git仓库最新的分支版本**\n\n#### 项目初衷\n\n当本地有多个参与的项目需要更新拉取最新分支代码时，每个项目中都要执行 `git pull` 命令也是一件很繁琐的事情。所以一时兴起，用Golang实现了一个自动拉取Git项目最新分支版本的程序。\n\n正所谓：**Sharpening your axe will not delay your job of chopping wood.**\n\n由于原始项目涉及到一些原公司内部项目文件，所以此版本是经过整理后的开源版本（以下示例中的项目名称仅供参考）。\n\n*****\n\n#### 参数说明\n\n```\n./gitupdate -bd=./test -od=my_proxy -bc=5 -ck=true\n```\n\n* `-bd` - `defalut current path` 指定要检索的基目录\n* `-od` - `only one or some dir name mutiple between with ,` 设置只检索基目录下的一个目录或多个目录\n* `-bc` - `pull branch count default 3` 获取最近提交分支总数\n* `-ed` - `exclude one or some dir name mutiple between with ,` 排除基目录下的某一个或多个目录\n* `-ck` - `verify directory filtering results` 检查模式，仅验证目录筛选结果\n\n*****\n\n#### 执行\n\n设置检索的基目录为 `./test` ，设置只检索基目录下的 `celery` 项目目录：\n\n```\n./gitupdate -bd=./test -od=celery\n```\n\n#### 执行示例\n\n```\n➜ ./gitupdate -bd=./my_project\nbasepath: ./my_project ; oneDirName:\n检索到目录: my_project/logger\n检索到目录: my_project/client_lib\n检索到目录: my_project/options\n检索到目录: my_project/abc_loger\n[my_project/logger my_project/client_lib my_project/options my_project/abc_loger]\nstart range\nStart for path: my_project/logger\n↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\n\nAlready up to date.\n\n↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑\nStart for path: my_project/client_lib\n↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\n\nFrom ssh://the_company/my_project/client_lib\n   2a4c8fe..4ad287f  master     -\u003e master\n   2a4c8fe..4ad287f  master     -\u003e origin/master\nwarning: fetch updated the current branch head.\nfast-forwarding your working tree from\ncommit 2a4c8fe9101ee1d5738336ce01e5de2ea90776a9.\nAlready up to date.\n\n↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑\nStart for path: my_project/options\n↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓\nAlready on 'master'\nYour branch is up to date with 'origin/master'.\n\nAlready up to date.\n\n↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑\nStart for path: my_project/abc_loger\n↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\n\nAlready up to date.\n\n↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑\n\n```\n\n\n![](show.png)\n\n*****\n\n#### 相关git命令参考\n\n##### 按照最近的提交排序前n个分支\n\n```\n$ git for-each-ref --sort=-committerdate --format='%(committerdate:short) %(refname:short)' --count=15 refs/remotes/origin/\n```\n\n* [git – 如何获取未合并到master的分支列表,按最近提交的顺序排序？ - 代码日志](https://codeday.me/bug/20181218/461363.html)\n\n执行结果如：\n\n```\n2019-02-22 origin/login-aaa\n2018-11-28 origin/login-bbb\n2018-11-21 origin/login-ccc\n2018-09-20 origin/vvv-ddd\n2018-09-06 origin/vvv-eee\n2018-08-08 origin/vvv-fff\n2018-07-25 origin/release_0.6\n2018-07-04 origin/zzz-hhh\n2018-06-14 origin/zzz-kkk\n2018-04-17 origin/HCC-181\n2018-04-16 origin/master\n2018-04-16 origin/HEAD\n2018-03-29 origin/develop\n```\n\n对以上命令进行调整，将输出内容更改：\n\n获取远端分支的具体分支名 `refs/remotes/origin/`\n\n```\ngit for-each-ref --sort=-committerdate --format='%(refname:short)' --count=3 refs/remotes/origin/\n\n\n➜ git for-each-ref --sort=-committerdate --format='%(refname:short)' --count=3 refs/remotes/origin/\norigin/login-aaa\norigin/login-bbb\norigin/login-ccc\n```\n\n获取本地分支的分支名称，可以使用 `refs/heads/` :\n\n```\ngit for-each-ref --sort=-committerdate --format='%(refname:short)' --count=3 refs/heads/\n\n\n➜ git for-each-ref --sort=-committerdate --format='%(refname:short)' --count=3 refs/heads/\nlogin-aaa\nlogin-bbb\nlogin-ccc\n```\n\n* [Git the last 10 branches you've worked on (Example)](https://coderwall.com/p/jhucga/git-the-last-10-branches-you-ve-worked-on)\n\n\n*****\n\n##### test\n\n```\ngit branch --sort=-committerdate\n\ngit branch --sort=-committerdate --format='%(committerdate:short) %(refname:short)'\n\n\ngit for-each-ref --sort=-committerdate --format='%(refname:short)' --count=3 refs/heads/\n\n\nheads：描述当前仓库所有本地分支\ntags：描述当前仓库的tag信息\nremotes：remotes文件夹将所有由 git remote 命令创建的所有远程分支存储为单独的子目录\n```\n\n******\n\n\n* Last Updated: 2019-03-28\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafney%2Fgitupdate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleafney%2Fgitupdate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafney%2Fgitupdate/lists"}