Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.
- Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
- https://git-scm.com/downloads
Git comes with built-in GUI tools for committing (git-gui) and browsing (gitk), but there are several third-party tools for users looking for platform-specific experience.
- ⭐Fork for Windows and Mac
- Sourcetree: A free Git client for Windows and Mac
- GitKraken: Legendary Git client for Windows, Mac & Linux. Free for open source
- lazygit: simple terminal UI for git commands
- Official Documentation
- Pro Git book - zh-CN
- A Fast Intro to Git Internals
- Flight rules for Git - zh-CN
- 猴子都能懂的git入门
- git - the simple guide: just a simple guide for getting started with git. no deep shit ;)
- Backlog Git Tutorial - 猴子都能懂的GIT入门
- Git for Computer Scientists: Quick introduction to git internals for people who are not scared by words like Directed Acyclic Graph .
- Githug is designed to give you a practical way of learning git. It has a series of levels, each requiring you to use git commands to arrive at a correct answer.
- Git 菜单: Git recipes in Chinese by Zhongyi Tong. 高质量的Git中文教程. https://geeeeeeeeek.github.io/git-recipes/
- Git的奇技淫巧
git log --oneline $fromId..$toId
- Commit message 和 Change log 编写指南
- AngularJS Git Commit Message Conventions
- 删除本地所有未提交的更改
git clean -df
只删除所有untracked的文件,可后接指定目录git clean -xdf
删除untracked以及ignore的文件git reset --hard
把tracked的文件revert到前一个版本
- 永久删除某个文件,包括服务器端
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch FILENAME' --prune-empty --tag-name-filter cat -- --all git push origin master --force
- github/gitignore: A collection of useful .gitignore templates
- 忽略特定结构目录
- 忽略一个特定的文件:
/filename.extension
- 忽略所有同名的文件:
filename.extension
- 忽略一个特定的目录:
folder/
(这会连同其下所有子目录及文件都被忽略) - 但是排除一个特定的模式:(在 3 的基础上)
!folder/some/important/filename.extension
- 忽略指定目录下所有子目录下的特定文件:
folder/**/filename.extension
- 同上,但是只匹配文件扩展名:
folder/**/*.extension
- 同上,但是只匹配特定的目录:
folder/**/tmp/
- 忽略一个特定的文件:
- GitHub CLI: GitHub’s official command line tool
- GitHub Cheat Sheet: A list of cool features of Git and GitHub.
- The gist gem provides a gist command that you can use from your terminal to upload content to https://gist.github.com/.
- enhanced-github, Chrome extension to display size of each file, download link and copy file contents directly to clipboard
- GitHub Audio: Listen to music generated by events happening across GitHub
🎷
- GitHub 漫游指南- a Chinese ebook on how to build a good project on Github. Explore the users' behavior. Find some thing interest.
- github-rank: 🕷️Github 中国和全球用户排名,全球仓库 Star 最多排名(自动日更)。
- GitHunt: Hunt the most starred projects on any date on GitHub
- HelloGitHub: Find pearls on open-source seashore 分享 GitHub 上有趣、入门级的开源项目
- GitHub Résumé, A service that creates a résumé based on your GitHub repos/activity.
- profile-summary-for-github: Tool for visualizing GitHub profiles
- 🦄 Sourcerer app makes a visual profile from your GitHub and git repositories.
- GitHub Readme Stats⚡ Dynamically generated stats for your github readmes
- git filter-repo is a versatile tool for rewriting history
- Lepton is a lean code snippet manager based on GitHub Gist. Check out its latest release.
- GRV is a terminal interface for viewing git repositories
- git-crypt enables transparent encryption and decryption of files in a git repository.
- Git Extensions is a standalone UI tool for managing git repositories. It also integrates with Windows Explorer and Microsoft Visual Studio
- hexo: A fast, simple & powerful blog framework
- dulwich: Pure-Python Git implementation
- ▁▅▆▃▅ Git quick statistics is a simple and efficient way to access various statistics in git repository.
- git-fame is a command-line tool that helps you summarize and pretty-print collaborators in a git repository based on contributions.
- Gitalk is a modern comment component based on Github Issue and Preact.
- git-bug: Distributed, offline-first bug tracker embedded in git, with bridges
- Gitlab, 可自建的Git服务器,web可视化界面、操作便捷,适合公司/团体使用
- GitLab architecture
- Running GitLab in a memory-constrained environment
- 自建 Docker 版本,端口映射内外不一致时(容器内部端口为默认), 项目页面点击
clone
按钮后的 URL 展示问题- 假设:
--publish 8443:443 --publish 8080:80 --publish 8022:22
- 编辑配置
vi /etc/gitlab/gitlab.rb
- 选项
Clone with SSH
下的 URLgitlab_rails['gitlab_shell_ssh_port'] = 8022
- 选项
Clone with HTTP[S]
下的 URL- 修改
external_url
并带上端口(如果 docker 启动时未设置正确的话) - 重写
nginx['listen_port'] = 80
(如不重写此端口,将会根据external_url
改变监听端口)
- 修改
gitlab-ctl reconfigure
- 假设:
- Gogs is a painless self-hosted Git service https://gogs.io
- gitea Git with a cup of tea, painless self-hosted git service https://gitea.io
- onedev Super Easy All-In-One DevOps Platform
- Gource is a visualization tool for source control repositories.
- [[svn]] 迁移到 git
- 官方文档:迁移到 Git
- 换行符 CRLF 问题
- Q 换行符自动转换
- A 换行符问题 - Git权威指南
- 不要手动去设置
core.autocrlf
,默认即可(linux
,macosx
为false
,win
为true
) - 设置:
git config --global core.safecrlf true
- 特别需求添加
.gitattributes
去约束- 由于
win
为true
,会对文本文件自动添加CR
,如不希望此行为,将其视为二进制文件
- 由于
- 不要手动去设置
- push卡住的问题
- Q push时卡在write objects.后续报fatal:The remote end hung up unexpectedly
- A 问题原因是http.postBuffer默认上限为1M所致。将上限设为500M:
git config --global http.postBuffer 524288000
- gitlab fetch/pull 失败
- error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
git config --global http.version HTTP/1.1
- 解决冲突出错
git reset --hard
无效fatal: Unable to create '/.git/index.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue.
- How do I fix a failed git commit?
Removing index.lock file manually from .git directory worked.
or From command line:
$ rm -rf .git/index.lock
Note: Make sure that only one index file exist on .git directory
- office文档的diff方案
- Pushing to Multiple Git Repos
- How to restore a deleted branch
- 重命名某个文件时,仅改变大小写问题。如:
a.c
->A.c
- 备份并删除
a.c
提交;添加并提交A.c
git mv a.c A.c
- 备份并删除
- 本地 repo 瘦身
git reflog expire --expire=now --all && git gc --prune=now --aggressive
- clean history and re-init
git checkout --orphan latest_branch git add -A git commit -am "init" git branch -D master git branch -m master git push -f origin master
- Push an existing folder
cd existing_folder git init --initial-branch=main git remote add origin XXXURL git add . git commit -m "Initial commit" git push -u origin main
- should have been pointers, but weren't
git lfs uninstall && git reset --hard && git lfs install && git lfs pull
- GIT LFS file lock/unlocking and unable to write the file after unlock with --force option.
- git lfs untrack
- pull/update all lfs to local
git lfs pull
- remove all tracks
git lfs untrack "*.filetype1" "*.filetype2" ...
- refresh all cache
git rm --cached "*.filetype1" "*.filetype2" ...
- add
.gitattributes
- commit all previous lfs files
- pull/update all lfs to local
- Unload submodule from project but not remove/delete it.
git submodule deinit -f SUB_PATH
- 远程分支推送
git push --prune <new-remote> +refs/remotes/<old-remote>/*:refs/heads/* +refs/tags/*:refs/tags/*
- 检查忽略源头
git check-ignore -v Data~
- 查看全局忽略文件
git config --global core.excludesFile
- git clone: warning: --depth is ignored in local clones; use file:// instead
git clone --depth 1 file://$(pwd)/src_repo new_repo