- https://robots.thoughtbot.com/intent-to-add
git add --intent-to-add
, the specified untracked files will be added to the index, but without content.
$ echo hello > target-file
$ git add --patch
No chagnes.
$ git add --intent-to-add target-file
$ git add --patch
index e69de29..ce01362 100644
--- a/sub1/target-file
+++ b/sub1/target-file
@@ -0,0 +1 @@
+hello
# Mark all files including untracked to add
git add --intent-to-add --all
$ git checkout master
# Show targets before deleting
$ git branch --merged
$ git branch -d old-merged-feature
$ git branch --no-merged
$ git branch -D old-abandoned-feature
# Delete all merged, except master
$ git branch --merged | grep -vE '(master|develop)' | xargs git branch -d
# Show targets
$ git branch --remotes
$ git remote prune origin
# prune when fetching
$ git fetch --prune
git diff --exit-code # Exits 0: no differences, 1: differences
git diff --quiet # No outputs. Implies --exit-code
Make sure the local develop
and master
branches are fresh.
When trigger finish
, the merge flow is following:
- merges
release/something
intomaster
- creates a tag on the
master
commit. - merges
master
intodevelop
git flow feature finish
just merges into develop without code review.
To work around this, just don’t use finish
but make a pull request
and delete the branch manually after it merged.
# lists all of the already committed files being tracked by your git repo.
$ git ls-tree --full-tree -r HEAD
git log --all --full-history -- **/thefile.*
git log --all --full-history -- <path-to-file> # if you know the exact path
# Reveal the content
git show <SHA> -- <path-to-file>
# Note '^', checking out from the previous commit.
# There won't exist the file in <SHA> because it has been deleted.
git checkout <SHA>^ -- <path-to-file>
- http://stackoverflow.com/questions/30208928/can-git-pull-automatically-stash-and-pop-pending-changes
git pull --rebase --autostash # git pull accepts '--autostash' from 2.9
git fetch
git rebase --autostash
# Untrack <file> recursively
$ git rm -r --cached <file>
$ git tag -l | xargs git tag -d # remove all local tags
$ git fetch -t # fetch remote tags
# Basics
$ git fetch
$ git worktree add -b bugfix-1234 ../bugfix origin/master
# Temporary
$ git worktree add --detach ../project-build HEAD
# Cleanup
$ rm -rf ../bugfix && git worktree prune
-b bugfix-1234
option creates a new branch namedbugfix-1234
../bugfix
is the new local copy- Based on
origin/master
--detach
makes the working copy detached.
git rev-parse --show-toplevel
git -C ~/foo status # equivalent to (cd ~/foo && git status)
- https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/
- https://backlogtool.com/git-guide/en/stepup/stepup2_8.html
If you have questions, please <<<<<<< HEAD open an issue ======= ask your question in IRC. >>>>>>> branch-a
Fix the conflict like this:
If you have questions, please open an issue or ask in our IRC channel if it's more urgent
Stage it:
$ git add guide.md
- Case1. commit when merging
$ git commit -m "Resolved merge conflict"
- Case2. rebase –continue when rebasing
$ git rebase --continue
- BFG Repo-Cleaner
- https://rtyley.github.io/bfg-repo-cleaner/
git clone --mirror [email protected]:yeonghoey/yeonghoey.git
java -jar ~/.local/bin/bfg.jar --strip-blobs-bigger-than 1M yeonghoey.git
cd yeonghoey.git
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push
if ! git diff --quiet --cached; then
git commit --verbose
fi
# or just
git diff --quiet --cached || git commit