TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Git Cheat Sheet

67 点作者 dallamaneni超过 9 年前

9 条评论

AceJohnny2超过 9 年前
I really like this one by Zack Rusin from 2007:<p><a href="http:&#x2F;&#x2F;zrusin.blogspot.com&#x2F;2007&#x2F;09&#x2F;git-cheat-sheet.html" rel="nofollow">http:&#x2F;&#x2F;zrusin.blogspot.com&#x2F;2007&#x2F;09&#x2F;git-cheat-sheet.html</a><p>In nice printable format with a sort of &quot;state diagram&quot; for commits (workspace &lt;-&gt; index &lt;-&gt; local commit &lt;-&gt; remote commit)
castratikron超过 9 年前
Another one: git pull --rebase. If you&#x27;ve made a commit or two but others have pushed before you&#x27;ve had a change to pull, you can do a rebase to avoid the separate branch and merge that a regular git pull will attempt to do. I don&#x27;t know if I&#x27;d trust it on very out of date branches though.
评论 #10683722 未加载
zwiteof超过 9 年前
As an aerospace engineer who codes rather than a software engineer, is there a cheatsheet that talks about how to use git from a &quot;when do I commit&#x2F;merge&#x2F;etc&quot; rather than a &quot;this the command to perform commit&#x2F;merge&#x2F;etc&quot;? Basically, an &quot;Idiot&#x27;s Guide to Making My Life Easier with Git&quot;<p>I&#x27;ve tried to use git a few times at work, but I always end up forgetting to use it for awhile when deadlines start creeping up so it becomes &quot;well, the code works in it&#x27;s current state and it&#x27;s been 2 months since I committed, so I should probably update the repo&quot; which doesn&#x27;t seem much better than periodically backing up the folder.
评论 #10683868 未加载
评论 #10684358 未加载
评论 #10683885 未加载
评论 #10683838 未加载
评论 #10683977 未加载
yeukhon超过 9 年前
<p><pre><code> git add . Add all modified files to be commited </code></pre> I think this adds only files relative to the current path?<p>One I use from time to time is <i>git add -p</i> (-p stands for patch) , useful if you have a large set of changes, you keep forgetting to commit incrementally upfront, and you want to split your changes into one or more commits.<p><i>git checkout -b BRANCH_NAME</i> will create a new branch locally.<p>Also, if you have time, look at pre-commit hook for your project :-) tired of running your favorite test harness plugin for your project manually or waiting for your Jenkins server to get the job?<p>Last, is git fetch vs git pull still a debate? I always use git fetch because that seems to be most preferable, fetch then rebase is the right path, most clean way to merge changes with some upstream &#x2F; branch.
评论 #10683803 未加载
base698超过 9 年前
I made the below presentation for a talk a while ago. The notes have roughly what I said in the presentation to try to demystify the internals.<p><a href="https:&#x2F;&#x2F;docs.google.com&#x2F;presentation&#x2F;d&#x2F;1t8grwHN0SB7HGgD9Jv9gRjJthoRzBDHK6Iw77TFhXXc&#x2F;edit#slide=id.ge423a65cf_0_84" rel="nofollow">https:&#x2F;&#x2F;docs.google.com&#x2F;presentation&#x2F;d&#x2F;1t8grwHN0SB7HGgD9Jv9g...</a>
Trufa超过 9 年前
I&#x27;ve set up a collaborative cheatsheet in github some time ago, if anyone wants to collaborate, you&#x27;re more than welcome:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;trufa&#x2F;git-cheatsheet" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;trufa&#x2F;git-cheatsheet</a>
obituary_latte超过 9 年前
Thanks. I love git but can only be generously considered as a casual user. There are still many things that confuse me (e.g. Tags) and as such there is a ton of functionality I still don&#x27;t understand. These types of posts help. It&#x27;s appreciated.
评论 #10683732 未加载
vectored超过 9 年前
Thank you. I work in a very old-fashioned research lab that we managed to drag to git recently. I haven&#x27;t been able to convince the team to read the git book. This could be more helpful.
bonobo3000超过 9 年前
heres one i like:<p>&quot;git stash branch &lt;branchname&gt;&quot;<p>like &quot;git stash&quot; it stashes away all the untracked modifications you have, but it puts them onto another branch. i often end up making partial progress on things that should be conceptually in different branches at once - this way, you can stash unrelated changes into different branches, and then merge each branch as you finish.