TopGit theo dõi vasanthk/git-tips-and-tricks trên GitHub, đã đạt 66 sao. Git Cheatsheet with Tips and Tricks
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Set your push.default to upstream to push branches to their upstreams (which is the same that pull will pull from), rather than pushing branches to ones matching in name (which is the default setting for push.default, matching).
git config push.default upstream
Squash PR commits into one
Fetch from upstream (when merging clone to main upstream branch) or origin (when merging branch to master)
git fetch upstream
git checkout mybranch
git merge upstream/master
If necessary, resolve conflicts and git commit...
git reset --soft upstream/master
git commit -am 'Some cool description for a single commit'
git push --force-with-lease
More on --force-with-lease option here. Note that it's super important that you merge before resetting, and that the argument is the same master branch. Otherwise you risk messing up your local history.
The --soft parameter tells Git to reset HEAD to another commit, but that’s it. If you specify --soft Git will stop there and nothing else will change. What this means is that the index and working copy don’t get touched, so all of the files that changed between the original HEAD and the commit you reset to appear to be staged.
Extra: To squash last few commits (eg. last 2 commits) use git reset --soft HEAD~2
Bumping version and publishing upstream's branch (when you already have a fork)
You will need to create local branches tracking remote branches.
Assuming that you've got only one remote called origin, this snippet will create local branches for all remote tracking ones:
for b in `git branch -r | grep -v -- '->'`; do git branch --track ${b##origin/} $b; done
After that, git fetch --all will update all local copies of remote branches.
Also, git pull --all will update your local tracking branches, but depending on your local commits and how the 'merge' configure option is set it might create a merge commit, fast-forward or fail.
Keep & Manage different project sources in the current repository externally using git submodule
You are in the your project directory which need use external sources!
Add / map external sources:
git submodule add <project_repo>
Pull updated code from submodule repository
git submodule update --remote
Reset submodule code to initial state
git pull --update --resource-submodules
To clone project with submodule sources
git clone --recurse <main_project_repo>
In case you've cloned project without --recurse flag you will not have submodule data in your repository.
To load required data you need try next instruction:
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/vasanthk/git-tips-and-tricks là nguồn chính thức.
vasanthk/git-tips-and-tricks có bao nhiêu sao?
vasanthk/git-tips-and-tricks có 66 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/vasanthk/git-tips-and-tricks. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
vasanthk/git-tips-and-tricks có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho vasanthk/git-tips-and-tricks. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
vasanthk/git-tips-and-tricks có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho vasanthk/git-tips-and-tricks. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
vasanthk/git-tips-and-tricks có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho vasanthk/git-tips-and-tricks. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
vasanthk/git-tips-and-tricks còn đang phát triển không?
Commit gần nhất trên vasanthk/git-tips-and-tricks là 4.6 năm trước (theo timestamp GitHub). Repo có 20 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
Đọc đầy đủ README ở tab phía trên.
git-tips-and-tricks có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về git-tips-and-tricks.