Git basics
[Alias]
lg = log --graph --pretty=format:'%Cred%h%Creset %ad %s %C(yellow)%d%Creset %C(bold blue)<%an>%Creset' --date=short
hist = log --graph --full-history --all --pretty=format:'%Cred%h%Creset %ad %s %C(yellow)%d%Creset %C(bold blue)<%an>%Creset' --date=short
git log --oneline --graph --all --decorate
Do you want to hide your silly mistakes before pushing your changes? If so, git pull --rebase is perfect. It allows you to later squash your commits to a few (or one) commits. If you have merges in your (unpushed) history, it is not so easy to do a git rebase later one.
I personally don't mind publishing all my silly mistakes, so I tend to merge instead of rebase.
If you have a ton of small merge commits, it's easy to lose focus of the bigger picture that's happening in your history.
This is actually the only time I do rebasing(*), and the rest of my workflow is merge based. But as long as your most frequent committers do this, history looks a whole lot better in the end.
# locate xcode utilities
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
# set "opendiff" as the default mergetool globally
git config --global merge.tool opendiff
down vote
accepted
You need to use the commands git difftool (instead of git diff) and git mergetool(instead of git merge) for git to use opendiff.
like git difftool file
down vote
accepted
You could instruct Git to use it automatically for git-mergetool with:
git config --global merge.tool opendiff
If you want it for git-difftool as well:
git config --global diff.tool opendiff
And you could also disable the prompting for every file with:
git config --global difftool.prompt false
- git reset is specifically about updating the index, moving the HEAD.
- git checkout is about updating the working tree (to the index or the specified tree). It will update the HEAD only if you checkout a branch (if not, you end up with a detached HEAD).
????check todo
detached head state?
git index???
what will it do?i mean the concept?
revise
To review, git reset is a powerful command that is used to undo local changes to the state of a Git repo. Git reset operates on "The Three Trees of Git". These trees are the Commit History (HEAD), the Staging Index, and the Working Directory. There are three command line options that correspond to the three trees. The options --soft, --mixed, and --hard can be passed to git reset.
Remove all reds:
git clean -fd
git clean -nd
git checkout stash@{0} -- <filename>
git show stash@{0}:<full filename> > <newfile>
If you want to select manually which changes you want to apply from that file:
git difftool stash@{0}..HEAD -- <filename>
The first line is the chunk header. Each chunk is prepended by a header inclosed within @@ symbols. The content of the header is a summary of changes made to the file. In our simplified example, we have -1 +1 meaning line one had changes. In a more realistic diff, you would see a header like:
@@ -34,6 +34,8 @@
In this header example, 6 lines have been extracted starting from line number 34. Additionally, 8 lines have been added starting at line number 34.
The remaining content of the diff chunk displays the recent changes. Each changed line is prepended with a + or - symbol indicating which version of the diff input the changes come from. As we previously discussed, - indicates changes from the a/diff_test.txt and + indicates changes from b/diff_test.txt
git diff can be passed Git refs to commits to diff. Some example refs are, HEAD, tags, and branch names. Every commit in Git has a commit ID which you can get when you execute GIT LOG. You can also pass this commit ID to git diff.
git diff branch1..other-feature-branch
git diff master new_branch ./diff_test.txt
Comments
Post a Comment