TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Git Tips And Workflows

148 pointsby durdnover 12 years ago

11 comments

blhackover 12 years ago
Has anybody seen a "git for people who have no idea how to use git" tutorial?<p>I use git for keeping track of some personal projects, but the extent to which I understand how to use it is:<p>"git commit origin master"<p>We had a hackathon this weekend, and our team had three people on it. I wanted to make it so that they could also commit code into the same repo (I think this it the right term?), but had absolutely no idea how to actually make this happen, and googling didn't seem to give answers that were geared towards somebody with my level-of-understanding of git.
评论 #4877854 未加载
评论 #4877441 未加载
评论 #4877487 未加载
评论 #4877577 未加载
评论 #4877427 未加载
评论 #4879785 未加载
评论 #4878622 未加载
评论 #4877773 未加载
FuzzyDunlopover 12 years ago
&#62;&#62; Zero a branch to do something radically different<p>There's another way to do this:<p><pre><code> git checkout --orphan new-branch</code></pre>
评论 #4877161 未加载
评论 #4877435 未加载
JonnieCacheover 12 years ago
Curated eh?
评论 #4876913 未加载
ExpiredLinkover 12 years ago
&#62; Making ‘git diff’ wrap long lines ... My git diff would not wrap lines and leave a lot of information hidden from view in my terminal.<p>Git is so ... stone age!
评论 #4879333 未加载
Nyctoover 12 years ago
&#62; Search for a string in all revisions of entire git history<p>The example they show can be shortened by using xargs:<p><pre><code> git rev-list --all | xargs -n1 git --no-pager grep -F "search string" </code></pre> And here it is as an alias that you can add to your .gitconfig:<p><pre><code> grepall = "!f() { git rev-list --all | xargs -n1 git --no-pager grep -F \"$1\"; }; f"</code></pre>
nicholassmithover 12 years ago
I was not aware of the `git config` option for wrapping long files, worth the price of admission just for that for me.<p>Edit: there's a `git diff` tip in there, but this comes up a few times so if anyone needs to do patches from git for svn repos do `git patch --prefix=none $DIFF1 $DIFF2 &#62; some.patch` share and apply with `patch -p0 &#60; some.patch`.
评论 #4877331 未加载
评论 #4877112 未加载
评论 #4877273 未加载
temp453463343over 12 years ago
These seem like the kind of things you'd end up using once in a blue moon. No point in memorizing them.<p>Am I alone in using git extensions? I've been very happy with it and its ability to display git's "state" right in the window. I usually have one monitor with VS and one with GitExtentions
antirezover 12 years ago
&#62;&#62; Making a more recent branch the new master<p>Why don't just use "git reset --hard &#60;sha-of-the-better-branch&#62;"?<p>At least if the better-branch and master commit in common is the last commit in master so no history rewrite will happen when pushing.
anilguptaover 12 years ago
Git is full of nice tricks, this is a good collection. One it didn't mention that I use a lot, is manipulating history with human-readable dates:<p><pre><code> git whatchanged --since="yesterday" git revert master@{"1 month ago"}</code></pre>
ruswickover 12 years ago
I saw the words "curated tips" included on the title and promptly closed the page.
TommyDANGerousover 12 years ago
I ask the same thing as blhack, I would like a tutorial. I only know how to use the basics, pushing to github and heroku, and I've been using it for a long time.
评论 #4880383 未加载