3 ms·
I got a little tired of running to Google every time I needed a non-trivial git command, so I set out to identify all (and only) the git commands I require for
by carodgers 7y ago
I got a little tired of running to Google every time I needed a non-trivial git command, so I set out to identify all (and only) the git commands I require for my day-to-day and capture them in one place. The result is this script. It can be run fully on your local machine, no remote accounts required. (But it still shows how to use remote repos!)
I'd also be interested to hear what git commands others use frequently (that don't involve a GUI). I'm curious to know which workloads might require some of git's more advanced features on a regular basis.
- katet 7y agoA couple of random addendums (although these aren't necessarily what you'd use day to day) git diff --color-moved (seriously, read through the man page for git diff sometime) git log -p --all -- <path/to/file> (I use this with multiple remotes, so I can track changes in my fork and in upstream when looking for context around a file) git cherry-pick -x (for automatically adding a reference to the original commit) A couple more, but I think they're really quite specific to my personal workflow and responsibilities
- carodgers 7y agogit log -p --all -- <path/to/file> I like this one. I'll remember it. Thanks for sharing!
- Myrmornis 7y ago(shameless plug): https://github.com/dandavison/delta https://github.com/dandavison/delta is a syntax-highlighting pager for git that adds syntax highlighting and within-line edit detection to all diffs displayed by git. I agree about `git log -p`. A good trick with that is to use it as a quick way to search for a commit that includes a certain string (since the pager is less, one can search back in time with `/`). Same trick for `git reflog -p`. `git stash show -p` is another less-known diff command (look at a stash without applying it).
- adrianN 7y agoI use git log -S regularly https://www.git-scm.com/docs/git-log#Documentation/git-log.txt--Sltstringgt https://www.git-scm.com/docs/git-log#Documentation/git-log.t...
- coldpie 7y ago> I got a little tired of running to Google every time I needed a non-trivial git command Have you read through the gittutorial, gittutorial-2, and especially the gitcore-tutorial manpages[1]? Reading those guides and actually following the steps and examining the results on disk was extremely helpful for me in understanding how Git actually works. Once you've got that understanding, the Git UI seems less arbitrary. You can start to see how it was put together over the years, which should help you use the tool more intuitively and effectively. > I'm curious to know which workloads might require some of git's more advanced features on a regular basis. I work on a very large and very old (mid-90s) project, so history-diving and diffing branches is very useful for me. I use all of git-blame, git-show, and git-diff to examine history to learn how the code came to be as it is. Even git-cat-file comes up occasionally when I just want to look at some old object I happen to have a hash for and don't want to look up properly through the porcelain. We also maintain a bunch of branches and backport modern commits onto legacy branches. git-rebase can help for this, but more often I find myself doing it manually (well, with a bash script) with git-cherry-pick, as it's easier to work with commits without being in the middle of a rebase operation. Knowing git-log's many options to massage history into a useful form for my work comes in very handy here, too. More details on the rebasing procedure I use: https://github.com/ValveSoftware/Proton/blob/proton_4.11/docs/REBASING_TIPS.md https://github.com/ValveSoftware/Proton/blob/proton_4.11/doc... Here's some of the tooling I use often. For Git stuff, see pick_commits and gitconfig https://gitlab.com/mywinetools/mywinetools/ https://gitlab.com/mywinetools/mywinetools/ [1] I know, I know, no one likes studying and learning how to use a tool. But sometimes you gotta if you want to use the tool effectively.
- taneq 7y agoHow much required reading should a version control tool really need before you can use it competently?
- coldpie 7y agoDepends on how many features you want it to have, and what level of control over it you want to have, I suppose. It's hardly unique in being a tool one needs training to master. How many programming language books are there? Database theory books? Adobe Photoshop guides? Safety instruction guides for power tools? Best practices for building construction... You have to learn a thing to use a thing. Git is no different.