5 ms·
Here is my personal recommendation for getting more comfortable with git. Use "git status" a lot. Everytime you do something in git, and before you do something
by cyborgx7 8y ago
Here is my personal recommendation for getting more comfortable with git. Use "git status" a lot. Everytime you do something in git, and before you do something, do a "git status" and see what you change with your commands. And what you didn't change.
Also "git log".
- Ajedi32 8y ago`git log` on its own (with no flags) isn't that useful, as it's missing a lot of important information. I prefer `git config --global alias.lg "log --color --graph --oneline --decorate"`. Then you can just type `git lg` and get a much more useful overview of the state of your current branch.
- deleted 8y ago[deleted]
- creeble 8y ago+1 these, I wish they were default for git. Much better both for beginners and experienced users.
- hoorayimhelping 8y agogit config --global alias.lg "log --color --graph --oneline --decorate" for easy copy-pasting. HN doesn't support backticks or triple backticks like a lot of markdown parsers. To get fixed-width fonts, you have to insert 4 paces at the beginning of the 'code' block.
- Stratoscope 8y agoTwo spaces (unlike Markdown). Of course four will work, it just adds more indentation.
- u801e 8y agoIn some mobile browsers, doing this will result in the fixed-width font line getting cut off when viewing the resulting post.
- oblio 8y agoGit in many occasions (including when using git log) feels like the designer just threw their hands up and said: "F*ck this shit, make your own UI on top if you want to use this tool!" I don't think Torvalds has a proper excuse for the pain and suffering he's inflicted on millions of developers worldwide :( (To the people going: "Oh, it's Open Source!". Sure, so are Mercurial, Fossil, etc.)
- pjc50 8y agoI don't think it was ever really intended for worldwide use by Linus, it was intended to exactly replicate his workflow and his alone. The real responsible party is github; I'm not sure how they came to dominate?
- delian66 8y agoBy being much, much, much better than the competition at the time (sourceforge) - github was faster, without ads, used superior vcs. Github also had Octopuss/Octocat as a logo :-) .
- pjc50 8y agoSure, but why github rather than mercurialhub etc? The website has great usability but the git CLI does not. Maybe the github gui was also critical.
- delian66 8y agoYes, the gui was good (and it still is, or may be I am too familiar with it at this point, I do not know). Another factor is that git was always FAST, and the most common operations (init, log, status, commit, checkout, push, pull) are not that complicated as people make them to be, so you can very easily start to use it for new local projects, and continue without installing additional plugins, unlike mercurial ... And at some point, when you wanted a colaboration hub or just a public remote repo, you just pushed your code to github.
- 8y ago
- WorldMaker 8y agoI got into the habit of teaching people `gitk`. It's not the prettiest tool, but it's included with most distributions of git, defaults to a decorated color graph log, and thus avoids the "copy paste this weird config line" step on other people's machines.
- gglitch 8y agoI have a soft spot for Tk interfaces. I hope they become cool again (or, I mean, for the first time).
- 99052882514569 8y agoI just use a GUI for that. I don't like using applications like Sourcetree for any actions, but they really are superior for visualisation of the commit tree, diffs between non-adjacent commits or between branches, etc.
- Fellshard 8y agoI'd recommend Git Extensions, still, as a good compromise between porcelain and plumbing. The most useful commands are all at your fingertips, with deeper ones available if necessary. Visualization is best I've seen - clean graph display, easy to read, and _doesn't lie in complex cases like SourceTree does._ SourceTree tends to treat commits with multiple ancestry in a very weird way that has led to difficulty on multiple occasions, where people think changes 'went missing' because SourceTree decided the other ancestor wasn't important enough to show.
- 99052882514569 8y agoI don't use Windows. Seems a little clunky to get it to work on Linux, even more so on the Mac. Haven't had any multiple-ancestry issues with SourceTree - perhaps resolved in an update since you encountered it?
- miccah 8y agoZsh users can use glgga to get a nice full detailed graph log as well. It's not as concise as the custom config, but I use it quite often.
- IshKebab 8y agoClassic git CLI. The option everyone wants is behind 5 optional flags.
- war1025 8y ago`git log -p` is my favorite obscure git command. Shows you commit by commit changes. If you specify a path, it limits to only those files. If you do a single file you can do `git log -p --follow <file_path>` and it will track the file across moves and renames. Also `git whatchanged` is a super helpful command to see just the list of files that changed in each commit
- rachelmcarmena 8y agoI didn't know "whatchanged", thanks! However, look at the description: https://git-scm.com/docs/git-whatchanged https://git-scm.com/docs/git-whatchanged
- war1025 8y agoYea. It's technically deprecated, but it is also super useful so I don't see any reason not to use it.
- LyndsySimon 8y ago`git add -p` is also very, very useful. I use it all the time, to the point that I've aliased it to `a`. If you're interested, here's my .gitconfig, including all of my aliases: https://gitlab.com/lyndsysimon/dotfiles/blob/master/git/gitconfig https://gitlab.com/lyndsysimon/dotfiles/blob/master/git/gitc...
- tome 8y agoYikes, do people consider `git log -p` obscure? I can't live without it!
- tkjef 8y agohere's my git log alias: alias gl='git log --date=local --pretty=format:"%C(124)%ad %C(24)%h %C(34)%an %C(252)%s%C(178)%d" --stat -p' has nice color coding around the date, person committing, commit hash, and message.
- wyclif 8y agoBetter yet, alias "git status" and "git log" so you'll be more inclined to use them frequently.