QuestionId stringlengths 3 8 | QuestionTitle stringlengths 15 149 | QuestionScore int64 1 27.2k | QuestionCreatedUtc stringdate 2008-08-01 18:33:08 2025-06-16 04:59:48 | QuestionBodyHtml stringlengths 40 28.2k | QuestionViewCount int64 78 16.5M | QuestionOwnerUserId float64 4 25.2M ⌀ | QuestionLastActivityUtc stringdate 2008-09-08 19:26:01 2026-01-24 22:40:25 | AcceptedAnswerId int64 266 79.7M | AnswerScore int64 2 30.1k | AnswerCreatedUtc stringdate 2008-08-01 23:40:28 2025-06-16 05:23:39 | AnswerOwnerUserId float64 1 29.5M ⌀ | AnswerLastActivityUtc stringdate 2008-08-01 23:40:28 2026-01-23 17:46:09 | QuestionLink stringlengths 31 36 | AnswerLink stringlengths 31 36 | AnswerBodyHtml stringlengths 35 33k | AnswerBodyPreview stringlengths 35 400 | AllTagIdsCsv stringlengths 2 37 | AllTagNamesCsv stringlengths 2 106 | MergedQuestion stringlengths 74 28.4k | quality_filter stringclasses 10
values | unique_id int64 0 29k | tag_major_lang stringclasses 10
values | MergedQuestion_md stringlengths 60 28.1k | AnswerBodyHtml_md stringlengths 14 29.2k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
21833870 | How do I shallow clone a repo on a specific branch? | 112 | 2014-02-17 16:07:59 | <p>How do I shallow clone a git repository, so that my clone contains only 1 history item, and starts on a specific branch?</p>
<p>I know how to do a shallow clone:</p>
<pre><code>git clone --depth 1 https://path/to/myrepo.git
</code></pre>
<p>but not start the clone on a specific branch.</p>
| 48,147 | 1,192,740 | 2016-11-19 23:28:52 | 21,833,871 | 194 | 2014-02-17 16:07:59 | 1,192,740 | 2016-11-19 23:28:52 | https://stackoverflow.com/q/21833870 | https://stackoverflow.com/a/21833871 | <p>To clone repo <em>foo.git</em> with branch <em>bar</em> do:</p>
<pre><code>git clone --depth 1 https://path/to/repo/foo.git -b bar
</code></pre>
<p>See the git-clone documentation: <a href="https://www.kernel.org/pub/software/scm/git/docs/git-clone.html" rel="noreferrer">https://www.kernel.org/pub/software/scm/git... | <p>To clone repo <em>foo.git</em> with branch <em>bar</em> do:</p> <pre><code>git clone --depth 1 https://path/to/repo/foo.git -b bar </code></pre> <p>See the git-clone documentation: <a href="https://www.kernel.org/pub/software/scm/git/docs/git-clone.html" rel="noreferrer">https://www.kernel.org/pub/software/scm/git... | 119, 1066, 34099, 74346, 76220 | continuous-integration, git, git-branch, git-clone, shallow-clone | <h1>How do I shallow clone a repo on a specific branch?</h1>
<p>How do I shallow clone a git repository, so that my clone contains only 1 history item, and starts on a specific branch?</p>
<p>I know how to do a shallow clone:</p>
<pre><code>git clone --depth 1 https://path/to/myrepo.git
</code></pre>
<p>but not star... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,122 | git | # How do I shallow clone a repo on a specific branch?
How do I shallow clone a git repository, so that my clone contains only 1 history item, and starts on a specific branch?
I know how to do a shallow clone:
```
git clone --depth 1 https://path/to/myrepo.git
```
but not start the clone on a specific branch. | To clone repo *foo.git* with branch *bar* do:
```
git clone --depth 1 https://path/to/repo/foo.git -b bar
```
See the git-clone documentation: <https://www.kernel.org/pub/software/scm/git/docs/git-clone.html> |
15806448 | Git: How to find out on which branch a tag is? | 153 | 2013-04-04 08:45:34 | <p>I'm currently busy with a project with a lot of branches and I have a tag for last changes which where done on one of the branches. But it's not clear for me on which branch this tag is. </p>
<p>How to find out on which branch a tag is?</p>
| 138,223 | 1,442,283 | 2022-06-29 21:32:58 | 15,806,668 | 193 | 2013-04-04 08:57:03 | 6,309 | 2022-05-03 08:10:53 | https://stackoverflow.com/q/15806448 | https://stackoverflow.com/a/15806668 | <p>Even shorter:</p>
<pre><code>git branch --contains tags/<tag>
</code></pre>
<p>(it works for any tree-ish reference)</p>
<hr />
<p>If you can find <a href="https://stackoverflow.com/a/1863712/6309">which commit a tag refers to</a>:</p>
<pre><code> git rev-parse --verify tags/<tag>^{commit}
# or, shorter... | <p>Even shorter:</p> <pre><code>git branch --contains tags/<tag> </code></pre> <p>(it works for any tree-ish reference)</p> <hr /> <p>If you can find <a href="https://stackoverflow.com/a/1863712/6309">which commit a tag refers to</a>:</p> <pre><code> git rev-parse --verify tags/<tag>^{commit} # or, shorter... | 115, 119, 1879 | branch, git, tags | <h1>Git: How to find out on which branch a tag is?</h1>
<p>I'm currently busy with a project with a lot of branches and I have a tag for last changes which where done on one of the branches. But it's not clear for me on which branch this tag is. </p>
<p>How to find out on which branch a tag is?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,124 | git | # Git: How to find out on which branch a tag is?
I'm currently busy with a project with a lot of branches and I have a tag for last changes which where done on one of the branches. But it's not clear for me on which branch this tag is.
How to find out on which branch a tag is? | Even shorter:
```
git branch --contains tags/<tag>
```
(it works for any tree-ish reference)
---
If you can find [which commit a tag refers to](https://stackoverflow.com/a/1863712/6309):
```
git rev-parse --verify tags/<tag>^{commit}
# or, shorter:
git rev-parse tags/<tag>~0
```
Then you can find [which branch... |
7388278 | You asked me to pull without telling me which branch you want to merge with | 129 | 2011-09-12 13:01:23 | <p>TL;DR: I have a "tracked" branch that I can't pull.</p>
<p>So here I am in "bucket-4":</p>
<pre><code>$ git branch -v
bucket-1 410f7b5 * gh-53 * gh-48 * "Share App"
bucket-2 7ed70a2 * upgrade to SOLR 3.3.0
bucket-3 400ffe4 * emergency fix prod issue
* bucket-4 64c2414 Merge branch 'bu... | 74,927 | 93,995 | 2018-09-28 12:03:47 | 7,388,440 | 193 | 2011-09-12 13:14:15 | 223,092 | 2018-09-28 12:03:47 | https://stackoverflow.com/q/7388278 | https://stackoverflow.com/a/7388440 | <p>It says <code>bucket-4 pushes to bucket-4</code> just because the default when pushing a branch is to push it to one with a matching name on the remote. (Note that this is still the default, <em>even if</em> the local branch is tracking a remote-tracking branch and the remote-tracking branch corresponds to a branch... | <p>It says <code>bucket-4 pushes to bucket-4</code> just because the default when pushing a branch is to push it to one with a matching name on the remote. (Note that this is still the default, <em>even if</em> the local branch is tracking a remote-tracking branch and the remote-tracking branch corresponds to a branch... | 119, 28896 | git, git-pull | <h1>You asked me to pull without telling me which branch you want to merge with</h1>
<p>TL;DR: I have a "tracked" branch that I can't pull.</p>
<p>So here I am in "bucket-4":</p>
<pre><code>$ git branch -v
bucket-1 410f7b5 * gh-53 * gh-48 * "Share App"
bucket-2 7ed70a2 * upgrade to SOLR 3.3.0
bucket... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,125 | git | # You asked me to pull without telling me which branch you want to merge with
TL;DR: I have a "tracked" branch that I can't pull.
So here I am in "bucket-4":
```
$ git branch -v
bucket-1 410f7b5 * gh-53 * gh-48 * "Share App"
bucket-2 7ed70a2 * upgrade to SOLR 3.3.0
bucket-3 400ffe4 * emergenc... | It says `bucket-4 pushes to bucket-4` just because the default when pushing a branch is to push it to one with a matching name on the remote. (Note that this is still the default, *even if* the local branch is tracking a remote-tracking branch and the remote-tracking branch corresponds to a branch with a different name... |
30601511 | How to see all local commits which are not pushed to the remote branch? | 105 | 2015-06-02 16:26:10 | <p>I am using the following commands to see all the local commits which are not pushed to remote branch but I am not getting all those local commits. </p>
<pre><code> git log
git log origin/master..master
</code></pre>
<p>I want to see at-least 10 local commits(only local).</p>
| 139,274 | 3,027,792 | 2021-12-09 20:35:09 | 30,601,779 | 193 | 2015-06-02 16:39:04 | 4,278,243 | 2021-11-24 12:49:48 | https://stackoverflow.com/q/30601511 | https://stackoverflow.com/a/30601779 | <p>This will show you all not pushed commits from all branches</p>
<pre><code>git log --branches --not --remotes
</code></pre>
<p>and this will show you all your local commits of branch <code>main</code></p>
<pre><code>git log origin/main..main
</code></pre>
| <p>This will show you all not pushed commits from all branches</p> <pre><code>git log --branches --not --remotes </code></pre> <p>and this will show you all your local commits of branch <code>main</code></p> <pre><code>git log origin/main..main </code></pre> | 119, 8337 | bitbucket, git | <h1>How to see all local commits which are not pushed to the remote branch?</h1>
<p>I am using the following commands to see all the local commits which are not pushed to remote branch but I am not getting all those local commits. </p>
<pre><code> git log
git log origin/master..master
</code></pre>
<p>I want to... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,126 | git | # How to see all local commits which are not pushed to the remote branch?
I am using the following commands to see all the local commits which are not pushed to remote branch but I am not getting all those local commits.
```
git log
git log origin/master..master
```
I want to see at-least 10 local commits(only l... | This will show you all not pushed commits from all branches
```
git log --branches --not --remotes
```
and this will show you all your local commits of branch `main`
```
git log origin/main..main
``` |
5359830 | How do I remove a directory subtree from the staging area? | 94 | 2011-03-19 03:20:43 | <p>I made a new repository, and ran <code>git add -A</code>. I then noticed that there was a folder containing about 100 files that shouldn't have been included, so I added it to <code>.gitignore</code>.</p>
<p>How do I now clear the staging area so that I can <code>add</code> all my files again taking into account th... | 65,065 | 311,220 | 2022-03-29 12:05:49 | 5,359,877 | 193 | 2011-03-19 03:36:06 | 123,109 | 2011-03-19 03:36:06 | https://stackoverflow.com/q/5359830 | https://stackoverflow.com/a/5359877 | <p>In #git, you said you unintentionally added a directory that should have been ignored, so run</p>
<pre><code>git rm --cached -r directory-name
</code></pre>
<p>to recursively remove the tree rooted at <code>directory-name</code> from the index.</p>
<p>Don't forget to update <code>.gitignore</code>!</p>
| <p>In #git, you said you unintentionally added a directory that should have been ignored, so run</p> <pre><code>git rm --cached -r directory-name </code></pre> <p>to recursively remove the tree rooted at <code>directory-name</code> from the index.</p> <p>Don't forget to update <code>.gitignore</code>!</p> | 119, 25056, 34792 | git, git-add, gitignore | <h1>How do I remove a directory subtree from the staging area?</h1>
<p>I made a new repository, and ran <code>git add -A</code>. I then noticed that there was a folder containing about 100 files that shouldn't have been included, so I added it to <code>.gitignore</code>.</p>
<p>How do I now clear the staging area so t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,127 | git | # How do I remove a directory subtree from the staging area?
I made a new repository, and ran `git add -A`. I then noticed that there was a folder containing about 100 files that shouldn't have been included, so I added it to `.gitignore`.
How do I now clear the staging area so that I can `add` all my files again tak... | In #git, you said you unintentionally added a directory that should have been ignored, so run
```
git rm --cached -r directory-name
```
to recursively remove the tree rooted at `directory-name` from the index.
Don't forget to update `.gitignore`! |
1006775 | How to reference the initial commit? | 173 | 2009-06-17 12:43:36 | <p>I've got a script that needs to reference the initial commit in a repository. git has the special reference <code>HEAD</code>, but doesn't have the corresponding <code>TAIL</code>. I cannot find anything in <code>git help rev-parse</code> that would seem to help me.</p>
<p>Here's what I'd like to do:</p>
<pre><... | 79,554 | 91,365 | 2026-01-24 22:40:25 | 1,007,545 | 192 | 2009-06-17 14:51:24 | 46,058 | 2019-11-20 14:14:18 | https://stackoverflow.com/q/1006775 | https://stackoverflow.com/a/1007545 | <p>Do not use git-log for scripting: use either <a href="https://git-scm.com/docs/git-rev-list" rel="noreferrer"><code>git-rev-list</code></a>, or <a href="https://git-scm.com/docs/git-log" rel="noreferrer"><code>git-log</code></a> with specified custom format (<code>--format=*<sth>*</code> option).</p>
<p>There... | <p>Do not use git-log for scripting: use either <a href="https://git-scm.com/docs/git-rev-list" rel="noreferrer"><code>git-rev-list</code></a>, or <a href="https://git-scm.com/docs/git-log" rel="noreferrer"><code>git-log</code></a> with specified custom format (<code>--format=*<sth>*</code> option).</p> <p>There... | 119, 53850 | git, git-commit | <h1>How to reference the initial commit?</h1>
<p>I've got a script that needs to reference the initial commit in a repository. git has the special reference <code>HEAD</code>, but doesn't have the corresponding <code>TAIL</code>. I cannot find anything in <code>git help rev-parse</code> that would seem to help me.</... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,129 | git | # How to reference the initial commit?
I've got a script that needs to reference the initial commit in a repository. git has the special reference `HEAD`, but doesn't have the corresponding `TAIL`. I cannot find anything in `git help rev-parse` that would seem to help me.
Here's what I'd like to do:
```
git show TAI... | Do not use git-log for scripting: use either [`git-rev-list`](https://git-scm.com/docs/git-rev-list), or [`git-log`](https://git-scm.com/docs/git-log) with specified custom format (`--format=*<sth>*` option).
There is additional problem with your question: there can exist **more than one** such TAIL root commit (paren... |
8796522 | Git Tag list, display commit sha1 hashes | 145 | 2012-01-09 23:13:06 | <p>so the <code>git tag</code> command lists the current git tags</p>
<pre><code>tag1
tag2
</code></pre>
<p><code>git tag -n</code> prints tag's message</p>
<pre><code>tag1 blah blah
tag2 blah blah
</code></pre>
<p><em>What's the best way to get the hash of tag1 & tag2 ?</em></p>
| 71,363 | 400,836 | 2020-01-17 17:01:51 | 8,796,647 | 192 | 2012-01-09 23:26:40 | 349,353 | 2020-01-17 17:01:51 | https://stackoverflow.com/q/8796522 | https://stackoverflow.com/a/8796647 | <p>To get git tags with the SHA1 hash of the Tag object, you can run:</p>
<pre><code>git show-ref --tags
</code></pre>
<p>The output will then look something like:</p>
<pre><code>0e76920bea4381cfc676825f3143fdd5fcf8c21f refs/tags/1.0.0
5ce9639ead3a54bd1cc062963804e5bcfcfe1e83 refs/tags/1.1.0
591eceaf92f99f69ea402c4c... | <p>To get git tags with the SHA1 hash of the Tag object, you can run:</p> <pre><code>git show-ref --tags </code></pre> <p>The output will then look something like:</p> <pre><code>0e76920bea4381cfc676825f3143fdd5fcf8c21f refs/tags/1.0.0 5ce9639ead3a54bd1cc062963804e5bcfcfe1e83 refs/tags/1.1.0 591eceaf92f99f69ea402c4c... | 119, 581, 942, 35061, 60718 | git, git-tag, hash, logging, verbose | <h1>Git Tag list, display commit sha1 hashes</h1>
<p>so the <code>git tag</code> command lists the current git tags</p>
<pre><code>tag1
tag2
</code></pre>
<p><code>git tag -n</code> prints tag's message</p>
<pre><code>tag1 blah blah
tag2 blah blah
</code></pre>
<p><em>What's the best way to get the hash of tag1 &... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,131 | git | # Git Tag list, display commit sha1 hashes
so the `git tag` command lists the current git tags
```
tag1
tag2
```
`git tag -n` prints tag's message
```
tag1 blah blah
tag2 blah blah
```
*What's the best way to get the hash of tag1 & tag2 ?* | To get git tags with the SHA1 hash of the Tag object, you can run:
```
git show-ref --tags
```
The output will then look something like:
```
0e76920bea4381cfc676825f3143fdd5fcf8c21f refs/tags/1.0.0
5ce9639ead3a54bd1cc062963804e5bcfcfe1e83 refs/tags/1.1.0
591eceaf92f99f69ea402c4ca639605e60963ee6 refs/tags/1.2.0
40414... |
10888300 | gitosis vs gitolite? | 140 | 2012-06-04 21:01:35 | <p>I am looking for installing a git server to share projects with my team. I don't want to create a user account on the server with SSH access for each developer that needs a git access.
It seems there is two concurrent solutions that cover this issue : gitosis & gitolite.</p>
<p>I could not find any comparison b... | 78,777 | 2,622,924 | 2024-08-14 17:52:55 | 10,888,536 | 192 | 2012-06-04 21:19:43 | 761,202 | 2012-09-19 10:40:30 | https://stackoverflow.com/q/10888300 | https://stackoverflow.com/a/10888536 | <blockquote>
<p>I am looking for installing a git server to share projects with my team.</p>
</blockquote>
<h2>You can <em>just</em> use git.</h2>
<p>To have a git server the only thing you need on the remote server is git. If you don't require fine-grained permissions (sharing with only your team suggests that's a... | <blockquote> <p>I am looking for installing a git server to share projects with my team.</p> </blockquote> <h2>You can <em>just</em> use git.</h2> <p>To have a git server the only thing you need on the remote server is git. If you don't require fine-grained permissions (sharing with only your team suggests that's a... | 119, 24526, 39151 | git, gitolite, gitosis | <h1>gitosis vs gitolite?</h1>
<p>I am looking for installing a git server to share projects with my team. I don't want to create a user account on the server with SSH access for each developer that needs a git access.
It seems there is two concurrent solutions that cover this issue : gitosis & gitolite.</p>
<p>I c... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,132 | git | # gitosis vs gitolite?
I am looking for installing a git server to share projects with my team. I don't want to create a user account on the server with SSH access for each developer that needs a git access.
It seems there is two concurrent solutions that cover this issue : gitosis & gitolite.
I could not find any co... | > I am looking for installing a git server to share projects with my team.
## You can *just* use git.
To have a git server the only thing you need on the remote server is git. If you don't require fine-grained permissions (sharing with only your team suggests that's a possibility) or any extra features, you don't nee... |
1161609 | How can I get the diff between all the commits that occurred between two dates with Git? | 135 | 2009-07-21 20:35:13 | <p>Or just all the commits that occurred between two dates? In SVN, you could do something like </p>
<pre><code>svn diff -r{date}:{date}
</code></pre>
<p>to do it! I can't seem to find a Git equivalent to this.</p>
<p>Specifically I'm looking at writing a script to send out daily emails with all the code committed t... | 96,630 | 142,318 | 2024-12-30 15:33:32 | 1,161,629 | 192 | 2009-07-21 20:40:53 | 8,590 | 2024-12-30 15:33:32 | https://stackoverflow.com/q/1161609 | https://stackoverflow.com/a/1161629 | <p>You could use <code>git whatchanged --since="1 day ago" -p</code></p>
<p>It also takes a <code>--until</code> argument.</p>
<p><a href="https://git-scm.com/docs/git-whatchanged/2.0.5" rel="nofollow noreferrer">Docs</a></p>
| <p>You could use <code>git whatchanged --since="1 day ago" -p</code></p> <p>It also takes a <code>--until</code> argument.</p> <p><a href="https://git-scm.com/docs/git-whatchanged/2.0.5" rel="nofollow noreferrer">Docs</a></p> | 119, 606, 9033, 47913 | diff, git, git-diff, git-log | <h1>How can I get the diff between all the commits that occurred between two dates with Git?</h1>
<p>Or just all the commits that occurred between two dates? In SVN, you could do something like </p>
<pre><code>svn diff -r{date}:{date}
</code></pre>
<p>to do it! I can't seem to find a Git equivalent to this.</p>
<p>S... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,133 | git | # How can I get the diff between all the commits that occurred between two dates with Git?
Or just all the commits that occurred between two dates? In SVN, you could do something like
```
svn diff -r{date}:{date}
```
to do it! I can't seem to find a Git equivalent to this.
Specifically I'm looking at writing a scri... | You could use `git whatchanged --since="1 day ago" -p`
It also takes a `--until` argument.
[Docs](https://git-scm.com/docs/git-whatchanged/2.0.5) |
5277467 | How can I clean my .git folder? Cleaned up my project directory, but .git is still massive | 130 | 2011-03-11 19:33:45 | <p>The <em><strong>.git/objects</strong></em> in my rails project directory is still massive, after deleting hundreds of Megabytes of accidentally generated garbage. </p>
<p>I have tried <code>git add -A</code>, as well as other commands to update the index and remove nonexistent files. I gather, perhaps incorrect... | 100,977 | 650,775 | 2023-10-27 10:52:50 | 5,277,575 | 192 | 2011-03-11 19:44:38 | 19,750 | 2011-09-22 20:38:24 | https://stackoverflow.com/q/5277467 | https://stackoverflow.com/a/5277575 | <ul>
<li><p>If you added the files and then removed them, the blobs still exist but are dangling. <code>git fsck</code> will list unreachable blobs, and <code>git prune</code> will delete them.</p></li>
<li><p>If you added the files, committed them, and then rolled back with <code>git reset --hard HEAD^</code>, they’re... | <ul> <li><p>If you added the files and then removed them, the blobs still exist but are dangling. <code>git fsck</code> will list unreachable blobs, and <code>git prune</code> will delete them.</p></li> <li><p>If you added the files, committed them, and then rolled back with <code>git reset --hard HEAD^</code>, they’re... | 119 | git | <h1>How can I clean my .git folder? Cleaned up my project directory, but .git is still massive</h1>
<p>The <em><strong>.git/objects</strong></em> in my rails project directory is still massive, after deleting hundreds of Megabytes of accidentally generated garbage. </p>
<p>I have tried <code>git add -A</code>, as w... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,134 | git | # How can I clean my .git folder? Cleaned up my project directory, but .git is still massive
The ***.git/objects*** in my rails project directory is still massive, after deleting hundreds of Megabytes of accidentally generated garbage.
I have tried `git add -A`, as well as other commands to update the index and remov... | - If you added the files and then removed them, the blobs still exist but are dangling. `git fsck` will list unreachable blobs, and `git prune` will delete them.
- If you added the files, committed them, and then rolled back with `git reset --hard HEAD^`, they’re stuck a little deeper. `git fsck` will not list any dang... |
8136178 | Git log between tags | 112 | 2011-11-15 12:15:31 | <p>I'm trying to output the log between two tagged commits.</p>
<pre><code>mbell@cheetah [12:07:22] [/var/www/html/brone] [dev]
-> % git tag
6.x-0.1
6.x-1.0-beta1
6.x-1.0-beta2
6.x-1.0-beta3
6.x-1.0-beta4
6.x-1.0-beta5
6.x-1.0-beta6
6.x-1.0-beta7
6.x-1.0-beta8
6.x-1.0-beta9
</code></pre>
<p>If I then do:</p>
<p>... | 98,254 | 137,300 | 2022-11-29 11:20:04 | 8,136,213 | 192 | 2011-11-15 12:18:16 | 229,602 | 2020-07-16 05:32:32 | https://stackoverflow.com/q/8136178 | https://stackoverflow.com/a/8136213 | <p>You need an ellipsis to indicate a range. Try <code>git log tag1..tag2</code>.</p>
| <p>You need an ellipsis to indicate a range. Try <code>git log tag1..tag2</code>.</p> | 119, 20151, 47913 | git, git-log, multiple-versions | <h1>Git log between tags</h1>
<p>I'm trying to output the log between two tagged commits.</p>
<pre><code>mbell@cheetah [12:07:22] [/var/www/html/brone] [dev]
-> % git tag
6.x-0.1
6.x-1.0-beta1
6.x-1.0-beta2
6.x-1.0-beta3
6.x-1.0-beta4
6.x-1.0-beta5
6.x-1.0-beta6
6.x-1.0-beta7
6.x-1.0-beta8
6.x-1.0-beta9
</code></p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,135 | git | # Git log between tags
I'm trying to output the log between two tagged commits.
```
mbell@cheetah [12:07:22] [/var/www/html/brone] [dev]
-> % git tag
6.x-0.1
6.x-1.0-beta1
6.x-1.0-beta2
6.x-1.0-beta3
6.x-1.0-beta4
6.x-1.0-beta5
6.x-1.0-beta6
6.x-1.0-beta7
6.x-1.0-beta8
6.x-1.0-beta9
```
If I then do:
`git log 6.x-... | You need an ellipsis to indicate a range. Try `git log tag1..tag2`. |
3001888 | How do .gitignore exclusion rules actually work? | 184 | 2010-06-08 22:46:52 | <p>I'm trying to solve a gitignore problem on a large directory structure, but to simplify my question I have reduced it to the following.</p>
<p>I have the following directory structure of two files (foo, bar) in a brand new git repository (no commits so far):</p>
<pre><code>a/b/c/foo
a/b/c/bar
</code></pre>
<p>Obviou... | 101,412 | 143,397 | 2022-12-13 22:18:55 | 3,001,967 | 191 | 2010-06-08 23:00:44 | 258,120 | 2010-06-08 23:00:44 | https://stackoverflow.com/q/3001888 | https://stackoverflow.com/a/3001967 | <pre>/a/b/c/*
!foo</pre>
<p>Seems to work for me (git 1.7.0.4 on Linux). The <code>*</code> is important as otherwise you're ignoring the directory itself (so git won't look inside) instead of the files within the directory (which allows for the exclusion).</p>
<p>Think of the exclusions as saying "but not this one" ... | <pre>/a/b/c/* !foo</pre> <p>Seems to work for me (git 1.7.0.4 on Linux). The <code>*</code> is important as otherwise you're ignoring the directory itself (so git won't look inside) instead of the files within the directory (which allows for the exclusion).</p> <p>Think of the exclusions as saying "but not this one" ... | 119, 25056 | git, gitignore | <h1>How do .gitignore exclusion rules actually work?</h1>
<p>I'm trying to solve a gitignore problem on a large directory structure, but to simplify my question I have reduced it to the following.</p>
<p>I have the following directory structure of two files (foo, bar) in a brand new git repository (no commits so far):<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,137 | git | # How do .gitignore exclusion rules actually work?
I'm trying to solve a gitignore problem on a large directory structure, but to simplify my question I have reduced it to the following.
I have the following directory structure of two files (foo, bar) in a brand new git repository (no commits so far):
```
a/b/c/foo
... | ```
/a/b/c/*
!foo
```
Seems to work for me (git 1.7.0.4 on Linux). The `*` is important as otherwise you're ignoring the directory itself (so git won't look inside) instead of the files within the directory (which allows for the exclusion).
Think of the exclusions as saying "but not this one" rather than "but include... |
1955985 | What does the caret (^) character mean in Git? | 170 | 2009-12-23 23:53:09 | <p>I saw an <a href="https://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo/1113140#1113140">answer to a question</a> here that helps restore a deleted file in git.</p>
<p>The solution was</p>
<pre><code>git checkout <deleting_commit>^ -- <deleted_file_path>
</code></pre>
<p>What... | 62,300 | 11,708 | 2024-04-15 18:33:58 | 1,956,054 | 191 | 2009-12-24 00:14:09 | 123,109 | 2024-04-15 18:33:58 | https://stackoverflow.com/q/1955985 | https://stackoverflow.com/a/1956054 | <p><code>HEAD^</code> means the first parent of the tip of the current branch.</p>
<p>Remember that git commits can have more than one <em>immediate</em> parent. <code>HEAD^</code> is short for <code>HEAD^1</code>, and you can also address <code>HEAD^2</code> and so on as appropriate. Any commit with multiple parents i... | <p><code>HEAD^</code> means the first parent of the tip of the current branch.</p> <p>Remember that git commits can have more than one <em>immediate</em> parent. <code>HEAD^</code> is short for <code>HEAD^1</code>, and you can also address <code>HEAD^2</code> and so on as appropriate. Any commit with multiple parents i... | 119 | git | <h1>What does the caret (^) character mean in Git?</h1>
<p>I saw an <a href="https://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo/1113140#1113140">answer to a question</a> here that helps restore a deleted file in git.</p>
<p>The solution was</p>
<pre><code>git checkout <deleting_commit&... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,138 | git | # What does the caret (^) character mean in Git?
I saw an [answer to a question](https://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo/1113140#1113140) here that helps restore a deleted file in git.
The solution was
```
git checkout <deleting_commit>^ -- <deleted_file_path>
```
What does t... | `HEAD^` means the first parent of the tip of the current branch.
Remember that git commits can have more than one *immediate* parent. `HEAD^` is short for `HEAD^1`, and you can also address `HEAD^2` and so on as appropriate. Any commit with multiple parents is the product of a merge or a merge commit.
You can get to ... |
4040717 | git remote prune – didn't show as many pruned branches as I expected | 115 | 2010-10-28 07:32:05 | <p>From the man page:</p>
<blockquote>
<pre><code>Deletes all stale tracking branches under <name>.
These stale branches have already been removed from the remote repository
referenced by <name>, but are still locally available in "remotes/<name>".
</code></pre>
</blockquote>
<p>So I removed a bunch... | 125,368 | 96,531 | 2019-10-30 01:18:31 | 4,041,027 | 191 | 2010-10-28 08:27:42 | 356,716 | 2019-10-30 01:18:31 | https://stackoverflow.com/q/4040717 | https://stackoverflow.com/a/4041027 | <p>When you use <code>git push origin :staleStuff</code>, it automatically removes <code>origin/staleStuff</code>, so when you ran <code>git remote prune origin</code>, you have pruned some branch that was removed by someone else. It's more likely that your co-workers now need to run <code>git prune</code> to get rid o... | <p>When you use <code>git push origin :staleStuff</code>, it automatically removes <code>origin/staleStuff</code>, so when you ran <code>git remote prune origin</code>, you have pruned some branch that was removed by someone else. It's more likely that your co-workers now need to run <code>git prune</code> to get rid o... | 119, 456, 1879, 41346, 76220 | branch, git, git-branch, git-remote, version-control | <h1>git remote prune – didn't show as many pruned branches as I expected</h1>
<p>From the man page:</p>
<blockquote>
<pre><code>Deletes all stale tracking branches under <name>.
These stale branches have already been removed from the remote repository
referenced by <name>, but are still locally available i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,141 | git | # git remote prune – didn't show as many pruned branches as I expected
From the man page:
> ```
> Deletes all stale tracking branches under <name>.
> These stale branches have already been removed from the remote repository
> referenced by <name>, but are still locally available in "remotes/<name>".
> ```
So I remov... | When you use `git push origin :staleStuff`, it automatically removes `origin/staleStuff`, so when you ran `git remote prune origin`, you have pruned some branch that was removed by someone else. It's more likely that your co-workers now need to run `git prune` to get rid of branches you have removed.
---
So what exac... |
2411031 | How do I clone into a non-empty directory? | 735 | 2010-03-09 17:23:48 | <p>I have directory A with files matching directory B. Directory A may have other needed files. Directory B is a git repo.</p>
<p>I want to clone directory B to directory A but git-clone won't allow me to since the directory is non-empty.</p>
<p>I was hoping it would just clone .git and since all the files match I co... | 502,665 | 285,546 | 2025-11-11 11:11:05 | 2,484,349 | 190 | 2010-03-20 19:10:16 | 285,546 | 2014-03-06 10:21:41 | https://stackoverflow.com/q/2411031 | https://stackoverflow.com/a/2484349 | <p>In the following shell commands <code>existing-dir</code> is a directory whose contents match the tracked files in the <code>repo-to-clone</code> git repository.</p>
<pre class="lang-bash prettyprint-override"><code># Clone just the repository's .git folder (excluding files as they are already in
# `existing-dir`) ... | <p>In the following shell commands <code>existing-dir</code> is a directory whose contents match the tracked files in the <code>repo-to-clone</code> git repository.</p> <pre class="lang-bash prettyprint-override"><code># Clone just the repository's .git folder (excluding files as they are already in # `existing-dir`) ... | 119 | git | <h1>How do I clone into a non-empty directory?</h1>
<p>I have directory A with files matching directory B. Directory A may have other needed files. Directory B is a git repo.</p>
<p>I want to clone directory B to directory A but git-clone won't allow me to since the directory is non-empty.</p>
<p>I was hoping it woul... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,142 | git | # How do I clone into a non-empty directory?
I have directory A with files matching directory B. Directory A may have other needed files. Directory B is a git repo.
I want to clone directory B to directory A but git-clone won't allow me to since the directory is non-empty.
I was hoping it would just clone .git and s... | In the following shell commands `existing-dir` is a directory whose contents match the tracked files in the `repo-to-clone` git repository.
```
# Clone just the repository's .git folder (excluding files as they are already in
# `existing-dir`) into an empty temporary directory
git clone --no-checkout repo-to-clone exi... |
1884474 | Change old commit message using `git rebase` | 242 | 2009-12-10 22:16:13 | <p>I was trying to edit an old commit message as explained <a href="http://schacon.github.io/history.html" rel="noreferrer">here</a>.</p>
<p>The thing is that now, when I try to run <code>rebase -i HEAD~5</code> it says <code>interactive rebase already started</code>.</p>
<p>So then I try: <code>git rebase --continue</... | 269,954 | 7,595 | 2025-12-23 14:27:37 | 1,884,582 | 190 | 2009-12-10 22:37:52 | 6,309 | 2013-03-08 20:53:06 | https://stackoverflow.com/q/1884474 | https://stackoverflow.com/a/1884582 | <p>It says:</p>
<blockquote>
<p>When you save and exit the editor, it will rewind you back to that last commit in that list and drop you on the command line with the following message:</p>
</blockquote>
<pre><code>$ git rebase -i HEAD~3
Stopped at 7482e0d... updated the gemspec to hopefully work better
You can amend th... | <p>It says:</p> <blockquote> <p>When you save and exit the editor, it will rewind you back to that last commit in that list and drop you on the command line with the following message:</p> </blockquote> <pre><code>$ git rebase -i HEAD~3 Stopped at 7482e0d... updated the gemspec to hopefully work better You can amend th... | 119, 7330, 8974, 29934 | git, git-rebase, rebase, repository | <h1>Change old commit message using `git rebase`</h1>
<p>I was trying to edit an old commit message as explained <a href="http://schacon.github.io/history.html" rel="noreferrer">here</a>.</p>
<p>The thing is that now, when I try to run <code>rebase -i HEAD~5</code> it says <code>interactive rebase already started</code... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,143 | git | # Change old commit message using `git rebase`
I was trying to edit an old commit message as explained [here](http://schacon.github.io/history.html).
The thing is that now, when I try to run `rebase -i HEAD~5` it says `interactive rebase already started`.
So then I try: `git rebase --continue` but got this error:
`... | It says:
> When you save and exit the editor, it will rewind you back to that last commit in that list and drop you on the command line with the following message:
```
$ git rebase -i HEAD~3
Stopped at 7482e0d... updated the gemspec to hopefully work better
You can amend the commit now, with
```
It does not mean:
>... |
2092810 | Browse orphaned commits in Git | 146 | 2010-01-19 10:39:17 | <p>My git repository has somehow gone wonky - I loaded up msysgit this morning and instead of the branch name being shown after the current directory, it says "((ref: re...))", 'git status' reports everything as a new file, 'git log' and 'git reflog' tell me "fatal: bad default revision 'HEAD'", and so on.</p>
<p>Doin... | 76,171 | 40,834 | 2025-03-27 06:30:40 | 2,326,238 | 189 | 2010-02-24 13:21:08 | 40,834 | 2024-07-19 18:47:07 | https://stackoverflow.com/q/2092810 | https://stackoverflow.com/a/2326238 | <p>Using <code>git reflog --all</code> is a good way to browse orphaned commits - and using the SHA1 hashes from that you can reconstruct history.</p>
<p>In my case though, the repository was corrupted so this didn't help; <code>git fsck</code> can help you find and sometimes fix errors in the repository itself.</p>
| <p>Using <code>git reflog --all</code> is a good way to browse orphaned commits - and using the SHA1 hashes from that you can reconstruct history.</p> <p>In my case though, the repository was corrupted so this didn't help; <code>git fsck</code> can help you find and sometimes fix errors in the repository itself.</p> | 119 | git | <h1>Browse orphaned commits in Git</h1>
<p>My git repository has somehow gone wonky - I loaded up msysgit this morning and instead of the branch name being shown after the current directory, it says "((ref: re...))", 'git status' reports everything as a new file, 'git log' and 'git reflog' tell me "fatal: bad default r... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,148 | git | # Browse orphaned commits in Git
My git repository has somehow gone wonky - I loaded up msysgit this morning and instead of the branch name being shown after the current directory, it says "((ref: re...))", 'git status' reports everything as a new file, 'git log' and 'git reflog' tell me "fatal: bad default revision '... | Using `git reflog --all` is a good way to browse orphaned commits - and using the SHA1 hashes from that you can reconstruct history.
In my case though, the repository was corrupted so this didn't help; `git fsck` can help you find and sometimes fix errors in the repository itself. |
6711670 | Git: show more context when using git add -i or git add -e? | 145 | 2011-07-15 18:35:25 | <p>I'm selectively committing parts of a large file and I'd like to see more context around each hunk. Is this possible?</p>
| 40,098 | 251,561 | 2022-10-26 15:15:04 | 6,712,949 | 189 | 2011-07-15 20:45:20 | 98,117 | 2011-07-15 20:45:20 | https://stackoverflow.com/q/6711670 | https://stackoverflow.com/a/6712949 | <p>Short answer: no.</p>
<p><code>git diff</code> has the <code>-U<n></code> option which allows you to customize the number of lines to show around a change. For example, <code>git diff -U5 ...</code> will show 5 lines of context. As far as I can tell, there is no such option available for the diff display in t... | <p>Short answer: no.</p> <p><code>git diff</code> has the <code>-U<n></code> option which allows you to customize the number of lines to show around a change. For example, <code>git diff -U5 ...</code> will show 5 lines of context. As far as I can tell, there is no such option available for the diff display in t... | 119 | git | <h1>Git: show more context when using git add -i or git add -e?</h1>
<p>I'm selectively committing parts of a large file and I'd like to see more context around each hunk. Is this possible?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,149 | git | # Git: show more context when using git add -i or git add -e?
I'm selectively committing parts of a large file and I'd like to see more context around each hunk. Is this possible? | Short answer: no.
`git diff` has the `-U<n>` option which allows you to customize the number of lines to show around a change. For example, `git diff -U5 ...` will show 5 lines of context. As far as I can tell, there is no such option available for the diff display in the interactive mode. |
39928132 | git rebase using sourcetree | 132 | 2016-10-08 02:35:53 | <p>I think I am confused on how to use SourceTree GUI to do git rebase. I have two branches "master" and "dev". As seen, the two branch diverged. I want to do a rebase on "dev" branch, using command line, this would be:</p>
<pre><code>git checkout dev
git rebase master
</code></pre>
<p><a href="https://i.sstatic.net/... | 149,982 | 2,366,592 | 2023-05-01 22:46:56 | 39,929,429 | 189 | 2016-10-08 06:30:22 | 6,309 | 2018-10-09 07:18:26 | https://stackoverflow.com/q/39928132 | https://stackoverflow.com/a/39929429 | <blockquote>
<p>But picking this option seems have no effect whatsoever. </p>
</blockquote>
<p>Yes, because current changes are the one of the current branches, which is <code>dev</code>.</p>
<p>Rebasing <code>dev</code> on top of <code>dev</code> means an no-op.</p>
<pre><code>git checkout dev
git rebase master
<... | <blockquote> <p>But picking this option seems have no effect whatsoever. </p> </blockquote> <p>Yes, because current changes are the one of the current branches, which is <code>dev</code>.</p> <p>Rebasing <code>dev</code> on top of <code>dev</code> means an no-op.</p> <pre><code>git checkout dev git rebase master <... | 119, 90056 | atlassian-sourcetree, git | <h1>git rebase using sourcetree</h1>
<p>I think I am confused on how to use SourceTree GUI to do git rebase. I have two branches "master" and "dev". As seen, the two branch diverged. I want to do a rebase on "dev" branch, using command line, this would be:</p>
<pre><code>git checkout dev
git rebase master
</code></pre... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,150 | git | # git rebase using sourcetree
I think I am confused on how to use SourceTree GUI to do git rebase. I have two branches "master" and "dev". As seen, the two branch diverged. I want to do a rebase on "dev" branch, using command line, this would be:
```
git checkout dev
git rebase master
```
[ to view the history/log of a file.
How can I do this with Git?
I am just looking for the history record for a particular file, and then the ability to compare the different versions. | Use [`git log`](http://git-scm.com/docs/git-log) to view the commit history. Each commit has an associated revision specifier that is a hash key (e.g. `14b8d0982044b0c49f7a855e396206ee65c0e787` and `b410ad4619d296f9d37f0db3d0ff5b9066838b39`). To view the difference between two different commits, use [`git diff`](http:/... |
3696938 | How do you commit code as a different user? | 158 | 2010-09-12 22:35:04 | <p>I want to be able to do this for a script. I'm essentially re-creating the entire version history of some code in Git - it currently uses a different version control system. I need the script to be able to add in the commits to Git while preserving the commit's original author (and date).</p>
<p>Assuming I know the... | 96,725 | 13,760 | 2022-03-18 15:12:34 | 3,696,994 | 188 | 2010-09-12 22:59:24 | 63,147 | 2022-03-18 15:12:34 | https://stackoverflow.com/q/3696938 | https://stackoverflow.com/a/3696994 | <p>Check out the <code>--author</code> option for <code>git commit</code>:</p>
<p>From the <a href="https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---authorltauthorgt" rel="noreferrer">man page</a>:</p>
<blockquote>
<p><code>--author=<author></code></p>
<p>Override the commit author. Specify an e... | <p>Check out the <code>--author</code> option for <code>git commit</code>:</p> <p>From the <a href="https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---authorltauthorgt" rel="noreferrer">man page</a>:</p> <blockquote> <p><code>--author=<author></code></p> <p>Override the commit author. Specify an e... | 119, 1231, 5597 | command-line, commit, git | <h1>How do you commit code as a different user?</h1>
<p>I want to be able to do this for a script. I'm essentially re-creating the entire version history of some code in Git - it currently uses a different version control system. I need the script to be able to add in the commits to Git while preserving the commit's or... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,156 | git | # How do you commit code as a different user?
I want to be able to do this for a script. I'm essentially re-creating the entire version history of some code in Git - it currently uses a different version control system. I need the script to be able to add in the commits to Git while preserving the commit's original au... | Check out the `--author` option for `git commit`:
From the [man page](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---authorltauthorgt):
> `--author=<author>`
>
> Override the commit author. Specify an explicit author
> using the standard `A U Thor <author@example.com>` format. Otherwise
> `<author... |
9162919 | Whitelisting and subdirectories in Git | 117 | 2012-02-06 15:54:12 | <p>I have created a white-list for text files only.</p>
<pre><code>*
!*.txt
</code></pre>
<p>Now, I have an untracked text file in a sub-directory - <code>sub/dir/file.txt</code>, and this is NOT shown (it is ignored). Text files in the root directory are shown, however.</p>
<p>Why is that, and how do I fix it?</p>
| 51,316 | 1,192,631 | 2023-03-06 06:38:27 | 9,227,991 | 188 | 2012-02-10 12:45:17 | 1,084,945 | 2013-10-03 14:12:26 | https://stackoverflow.com/q/9162919 | https://stackoverflow.com/a/9227991 | <p>If you try it that way, it'll fail, because you'll end up blacklisting the directories in your structure. </p>
<p>To solve, you want to blacklist everything that is not a directory, and is not one of the file-types you want to commit, <strong>while not blacklisting directories</strong>. </p>
<p>The <code>.gitignor... | <p>If you try it that way, it'll fail, because you'll end up blacklisting the directories in your structure. </p> <p>To solve, you want to blacklist everything that is not a directory, and is not one of the file-types you want to commit, <strong>while not blacklisting directories</strong>. </p> <p>The <code>.gitignor... | 119, 25056 | git, gitignore | <h1>Whitelisting and subdirectories in Git</h1>
<p>I have created a white-list for text files only.</p>
<pre><code>*
!*.txt
</code></pre>
<p>Now, I have an untracked text file in a sub-directory - <code>sub/dir/file.txt</code>, and this is NOT shown (it is ignored). Text files in the root directory are shown, however... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,158 | git | # Whitelisting and subdirectories in Git
I have created a white-list for text files only.
```
*
!*.txt
```
Now, I have an untracked text file in a sub-directory - `sub/dir/file.txt`, and this is NOT shown (it is ignored). Text files in the root directory are shown, however.
Why is that, and how do I fix it? | If you try it that way, it'll fail, because you'll end up blacklisting the directories in your structure.
To solve, you want to blacklist everything that is not a directory, and is not one of the file-types you want to commit, **while not blacklisting directories**.
The `.gitignore` file that will do this:
```
# Fir... |
21051850 | force git to accept cherry-pick's changes | 103 | 2014-01-10 18:35:29 | <p>I did cherry-pick from a gerrit review in my branch.
In gerrit code review, I have two patch sets and I cherry-picked patch one before, so now I want to do the second patch set, but there are conflicts, how can I force git to accept all changes?
Thanks!</p>
| 77,770 | 2,195,816 | 2021-04-28 11:09:34 | 32,468,531 | 188 | 2015-09-08 23:00:45 | 2,044,940 | 2021-04-28 11:09:34 | https://stackoverflow.com/q/21051850 | https://stackoverflow.com/a/32468531 | <p>You can tell it to always prefer the changes of the commit you are cherry-picking:</p>
<pre><code>git cherry-pick commitish --strategy-option theirs
</code></pre>
<p><code>commitish</code> can be a SHA-1 hash of a commit, or a <code>branch-name</code> for the lastest commit of that branch, <code>branch-name~1</code>... | <p>You can tell it to always prefer the changes of the commit you are cherry-picking:</p> <pre><code>git cherry-pick commitish --strategy-option theirs </code></pre> <p><code>commitish</code> can be a SHA-1 hash of a commit, or a <code>branch-name</code> for the lastest commit of that branch, <code>branch-name~1</code>... | 119, 78810 | git, git-cherry-pick | <h1>force git to accept cherry-pick's changes</h1>
<p>I did cherry-pick from a gerrit review in my branch.
In gerrit code review, I have two patch sets and I cherry-picked patch one before, so now I want to do the second patch set, but there are conflicts, how can I force git to accept all changes?
Thanks!</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,159 | git | # force git to accept cherry-pick's changes
I did cherry-pick from a gerrit review in my branch.
In gerrit code review, I have two patch sets and I cherry-picked patch one before, so now I want to do the second patch set, but there are conflicts, how can I force git to accept all changes?
Thanks! | You can tell it to always prefer the changes of the commit you are cherry-picking:
```
git cherry-pick commitish --strategy-option theirs
```
`commitish` can be a SHA-1 hash of a commit, or a `branch-name` for the lastest commit of that branch, `branch-name~1` for the commit before that etc.
If you want to do the re... |
8475448 | Find merge commit which includes a specific commit | 256 | 2011-12-12 14:00:44 | <p>Imagine the following history:</p>
<pre><code> c---e---g--- feature
/ \
-a---b---d---f---h--- master
</code></pre>
<p>How can I find when commit "c" has been merged into master (ie, find merge commit "h") ?</p>
| 94,215 | 1,016,526 | 2023-07-20 19:35:58 | 8,492,711 | 187 | 2011-12-13 16:36:02 | 108,802 | 2011-12-13 16:41:44 | https://stackoverflow.com/q/8475448 | https://stackoverflow.com/a/8492711 | <p>Your example shows that the branch <code>feature</code> is still available.</p>
<p>In that case <code>h</code> is the last result of:</p>
<pre><code>git log master ^feature --ancestry-path
</code></pre>
<hr>
<p>If the branch <code>feature</code> is not available anymore, you can show the merge commits in the his... | <p>Your example shows that the branch <code>feature</code> is still available.</p> <p>In that case <code>h</code> is the last result of:</p> <pre><code>git log master ^feature --ancestry-path </code></pre> <hr> <p>If the branch <code>feature</code> is not available anymore, you can show the merge commits in the his... | 119 | git | <h1>Find merge commit which includes a specific commit</h1>
<p>Imagine the following history:</p>
<pre><code> c---e---g--- feature
/ \
-a---b---d---f---h--- master
</code></pre>
<p>How can I find when commit "c" has been merged into master (ie, find merge commit "h") ?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,161 | git | # Find merge commit which includes a specific commit
Imagine the following history:
```
c---e---g--- feature
/ \
-a---b---d---f---h--- master
```
How can I find when commit "c" has been merged into master (ie, find merge commit "h") ? | Your example shows that the branch `feature` is still available.
In that case `h` is the last result of:
```
git log master ^feature --ancestry-path
```
---
If the branch `feature` is not available anymore, you can show the merge commits in the history line between `c` and `master`:
```
git log <SHA-1_for_c>..mast... |
16550688 | How to .gitignore files recursively | 169 | 2013-05-14 18:54:34 | <p>I'm trying to avoid the following pattern in my <code>.gitignore</code> file.</p>
<pre><code>MyPrject/WebApp/Scripts/special/*.js
MyPrject/WebApp/Scripts/special/*/*.js
MyPrject/WebApp/Scripts/special/*/*/*.js
MyPrject/WebApp/Scripts/special/*/*/*/*.js
MyPrject/WebApp/Scripts/special/*/*/*/*/*.js
MyPrject/WebApp/Sc... | 148,667 | 450,913 | 2020-01-22 05:44:04 | 27,741,990 | 187 | 2015-01-02 12:09:12 | 2,227,106 | 2017-06-15 23:55:36 | https://stackoverflow.com/q/16550688 | https://stackoverflow.com/a/27741990 | <p>As of git 1.8.2, this:</p>
<pre><code>MyPrject/WebApp/Scripts/special/**/*.js
</code></pre>
<p>Should work according to <a href="https://stackoverflow.com/questions/17812717/correctly-ignore-all-files-recursively-under-a-specific-folder-except-for-a-spec">this answer</a>. It also works for me in Windows 7 using So... | <p>As of git 1.8.2, this:</p> <pre><code>MyPrject/WebApp/Scripts/special/**/*.js </code></pre> <p>Should work according to <a href="https://stackoverflow.com/questions/17812717/correctly-ignore-all-files-recursively-under-a-specific-folder-except-for-a-spec">this answer</a>. It also works for me in Windows 7 using So... | 119, 25056 | git, gitignore | <h1>How to .gitignore files recursively</h1>
<p>I'm trying to avoid the following pattern in my <code>.gitignore</code> file.</p>
<pre><code>MyPrject/WebApp/Scripts/special/*.js
MyPrject/WebApp/Scripts/special/*/*.js
MyPrject/WebApp/Scripts/special/*/*/*.js
MyPrject/WebApp/Scripts/special/*/*/*/*.js
MyPrject/WebApp/Sc... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,163 | git | # How to .gitignore files recursively
I'm trying to avoid the following pattern in my `.gitignore` file.
```
MyPrject/WebApp/Scripts/special/*.js
MyPrject/WebApp/Scripts/special/*/*.js
MyPrject/WebApp/Scripts/special/*/*/*.js
MyPrject/WebApp/Scripts/special/*/*/*/*.js
MyPrject/WebApp/Scripts/special/*/*/*/*/*.js
MyPr... | As of git 1.8.2, this:
```
MyPrject/WebApp/Scripts/special/**/*.js
```
Should work according to [this answer](https://stackoverflow.com/questions/17812717/correctly-ignore-all-files-recursively-under-a-specific-folder-except-for-a-spec). It also works for me in Windows 7 using Sourcetree 1.6.12.0 and the version of g... |
12681529 | In git, is there a way to show untracked stashed files without applying the stash? | 163 | 2012-10-01 21:40:25 | <p>If I run <code>git stash -u</code>, I can stash untracked files. However, said untracked files don't show up at all with <code>git stash show stash@{0}</code>. Is there any way to show untracked stashed files without applying the stash?</p>
| 26,228 | 699,700 | 2023-07-10 05:38:02 | 12,681,856 | 187 | 2012-10-01 22:12:33 | 1,664,755 | 2021-10-19 14:04:54 | https://stackoverflow.com/q/12681529 | https://stackoverflow.com/a/12681856 | <p>Untracked files are stored in the third parent of a stash commit. (This isn't actually documented, but is pretty obvious from <a href="https://github.com/git/git/commit/787513027a7d0af3c2cd2f04b85bc7136d580586" rel="noreferrer">The commit which introduced the -u feature, 787513...</a>, and the way the <a href="http:... | <p>Untracked files are stored in the third parent of a stash commit. (This isn't actually documented, but is pretty obvious from <a href="https://github.com/git/git/commit/787513027a7d0af3c2cd2f04b85bc7136d580586" rel="noreferrer">The commit which introduced the -u feature, 787513...</a>, and the way the <a href="http:... | 119, 13091 | git, git-stash | <h1>In git, is there a way to show untracked stashed files without applying the stash?</h1>
<p>If I run <code>git stash -u</code>, I can stash untracked files. However, said untracked files don't show up at all with <code>git stash show stash@{0}</code>. Is there any way to show untracked stashed files without apply... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,164 | git | # In git, is there a way to show untracked stashed files without applying the stash?
If I run `git stash -u`, I can stash untracked files. However, said untracked files don't show up at all with `git stash show stash@{0}`. Is there any way to show untracked stashed files without applying the stash? | Untracked files are stored in the third parent of a stash commit. (This isn't actually documented, but is pretty obvious from [The commit which introduced the -u feature, 787513...](https://github.com/git/git/commit/787513027a7d0af3c2cd2f04b85bc7136d580586), and the way the [rest of the documentation for `git-stash`](h... |
21756614 | difference between git merge origin/master and git pull | 146 | 2014-02-13 14:12:14 | <p>I'm working on a local branch "BDD-local" and would like to get the changes from other developers.
The other developers are using their own branch and once they are happy with the unit tests, they push the changes to remote repo (origin/master).</p>
<p>I was going through several posts here and getting conflicting... | 225,422 | 2,917,758 | 2014-05-30 13:34:09 | 21,758,295 | 187 | 2014-02-13 15:21:20 | 300,238 | 2014-02-13 18:28:00 | https://stackoverflow.com/q/21756614 | https://stackoverflow.com/a/21758295 | <p><strong>fetch, merge, and pull</strong></p>
<p><code>git fetch</code> and <code>git merge origin/master</code> will fetch & integrate remote changes. Let me explain a common scenario. origin/master is at C. Someone pushed D. You worked on E & F. Note that you will not see D in your local repository un... | <p><strong>fetch, merge, and pull</strong></p> <p><code>git fetch</code> and <code>git merge origin/master</code> will fetch & integrate remote changes. Let me explain a common scenario. origin/master is at C. Someone pushed D. You worked on E & F. Note that you will not see D in your local repository un... | 119, 456, 717 | git, merge, version-control | <h1>difference between git merge origin/master and git pull</h1>
<p>I'm working on a local branch "BDD-local" and would like to get the changes from other developers.
The other developers are using their own branch and once they are happy with the unit tests, they push the changes to remote repo (origin/master).</p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,165 | git | # difference between git merge origin/master and git pull
I'm working on a local branch "BDD-local" and would like to get the changes from other developers.
The other developers are using their own branch and once they are happy with the unit tests, they push the changes to remote repo (origin/master).
I was going th... | **fetch, merge, and pull**
`git fetch` and `git merge origin/master` will fetch & integrate remote changes. Let me explain a common scenario. origin/master is at C. Someone pushed D. You worked on E & F. Note that you will not see D in your local repository until you run `git fetch`.
```
origin/master
v
A-B-C-... |
1910783 | Git: 1.List all files in a branch, 2.compare files from different branch | 122 | 2009-12-15 22:12:04 | <ol>
<li>Looking for a command like <code>ls -R</code> or <code>dir/s</code> that can list all files in a commit/branch. </li>
<li>Is there any command that can compare two files from different branches?</li>
</ol>
| 153,928 | 207,419 | 2020-02-26 05:43:58 | 1,910,822 | 187 | 2009-12-15 22:19:01 | 46,058 | 2009-12-15 23:31:19 | https://stackoverflow.com/q/1910783 | https://stackoverflow.com/a/1910822 | <ol>
<li><code>git ls-tree -r --name-only <commit></code> (where instead of <code><commit></code> there can be <code><branch></code>).<br /> You might want to use also <code>-t</code> option which lists subdirectories before descending into them</li>
<li><code>git diff <branchA>:<fileA> &... | <ol> <li><code>git ls-tree -r --name-only <commit></code> (where instead of <code><commit></code> there can be <code><branch></code>).<br /> You might want to use also <code>-t</code> option which lists subdirectories before descending into them</li> <li><code>git diff <branchA>:<fileA> &... | 119 | git | <h1>Git: 1.List all files in a branch, 2.compare files from different branch</h1>
<ol>
<li>Looking for a command like <code>ls -R</code> or <code>dir/s</code> that can list all files in a commit/branch. </li>
<li>Is there any command that can compare two files from different branches?</li>
</ol>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,166 | git | # Git: 1.List all files in a branch, 2.compare files from different branch
1. Looking for a command like `ls -R` or `dir/s` that can list all files in a commit/branch.
2. Is there any command that can compare two files from different branches? | 1. `git ls-tree -r --name-only <commit>` (where instead of `<commit>` there can be `<branch>`).
You might want to use also `-t` option which lists subdirectories before descending into them
2. `git diff <branchA>:<fileA> <branchB>:<fileB>`,
or if you want to compare the same file `git diff <branchA> <branch... |
15472107 | When listing git-ls-remote why there's "^{}" after the tag name? | 121 | 2013-03-18 08:02:56 | <p>When I run <code>git ls-remote</code> in the work tree, the command outputs a list of revisions in the origin repo. For some reason I get 2 revisions with every tag and for the second revision of the same tag, the tag name includes <code>^{}</code></p>
<pre><code>git ls-remote
From git@github.com:andris9/zzzzzz.git... | 27,773 | 217,076 | 2021-08-11 05:02:48 | 15,472,310 | 187 | 2013-03-18 08:19:36 | 380,757 | 2021-08-11 05:02:48 | https://stackoverflow.com/q/15472107 | https://stackoverflow.com/a/15472310 | <p>There are 2 types of tags:</p>
<ul>
<li><strong>lightweight</strong> - merely refs that point to some object (like a commit).</li>
<li><strong>annotated</strong> - a separate git object by themselves, and store a lot more information like author, committer, a commit message, etc.</li>
</ul>
<p>When you used <code>gi... | <p>There are 2 types of tags:</p> <ul> <li><strong>lightweight</strong> - merely refs that point to some object (like a commit).</li> <li><strong>annotated</strong> - a separate git object by themselves, and store a lot more information like author, committer, a commit message, etc.</li> </ul> <p>When you used <code>gi... | 119 | git | <h1>When listing git-ls-remote why there's "^{}" after the tag name?</h1>
<p>When I run <code>git ls-remote</code> in the work tree, the command outputs a list of revisions in the origin repo. For some reason I get 2 revisions with every tag and for the second revision of the same tag, the tag name includes <code>^{}</... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,167 | git | # When listing git-ls-remote why there's "^{}" after the tag name?
When I run `git ls-remote` in the work tree, the command outputs a list of revisions in the origin repo. For some reason I get 2 revisions with every tag and for the second revision of the same tag, the tag name includes `^{}`
```
git ls-remote
From g... | There are 2 types of tags:
- **lightweight** - merely refs that point to some object (like a commit).
- **annotated** - a separate git object by themselves, and store a lot more information like author, committer, a commit message, etc.
When you used `git tag -a` to create a tag, git would have created an annotated t... |
9477702 | Undo delete in GIT | 68 | 2012-02-28 06:59:00 | <p>I made something very stupid.
I made a commit using git commit (file edits + new files) (C).
Then I made amend last commit.
Then I deleted all files recursively (!) using <code>git rm -r</code>
Then I made another git commit (C).</p>
<pre>
A-B-C
↑
master
</pre>
<p>Is there any way to undelete the files but k... | 92,725 | 1,234,921 | 2015-11-10 20:50:56 | 9,478,062 | 187 | 2012-02-28 07:36:09 | 526,535 | 2015-11-10 20:50:56 | https://stackoverflow.com/q/9477702 | https://stackoverflow.com/a/9478062 | <p>Do yourself a favour and do not do <code>git checkout <hash></code> like the other answer suggests and go into more problems.</p>
<p>IF you have deleted file from your working directory and not committed the changes yet, do:</p>
<pre><code>git checkout -f
</code></pre>
<p><strong>CAUTION: commit uncommitted... | <p>Do yourself a favour and do not do <code>git checkout <hash></code> like the other answer suggests and go into more problems.</p> <p>IF you have deleted file from your working directory and not committed the changes yet, do:</p> <pre><code>git checkout -f </code></pre> <p><strong>CAUTION: commit uncommitted... | 119, 5597, 5766, 37510, 50016 | commit, delete-file, git, undelete, undo | <h1>Undo delete in GIT</h1>
<p>I made something very stupid.
I made a commit using git commit (file edits + new files) (C).
Then I made amend last commit.
Then I deleted all files recursively (!) using <code>git rm -r</code>
Then I made another git commit (C).</p>
<pre>
A-B-C
↑
master
</pre>
<p>Is there any way... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,168 | git | # Undo delete in GIT
I made something very stupid.
I made a commit using git commit (file edits + new files) (C).
Then I made amend last commit.
Then I deleted all files recursively (!) using `git rm -r`
Then I made another git commit (C).
```
A-B-C
↑
master
```
Is there any way to undelete the files but keep ... | Do yourself a favour and do not do `git checkout <hash>` like the other answer suggests and go into more problems.
IF you have deleted file from your working directory and not committed the changes yet, do:
```
git checkout -f
```
**CAUTION: commit uncommitted files before executing this command, otherwise you're go... |
25984310 | How to see remote tags? | 272 | 2014-09-22 22:56:30 | <p>In Atlassian SourceTree, how to know which tags are only local and which are also in remote?</p>
<p>When creating a tag you get the option "Push tag to: ...", but how to know if a tag has been pushed or not after it is created? I can see all my tags locally, but I need to be sure that they are present in remote so ... | 213,385 | 423,171 | 2024-08-18 02:41:29 | 25,987,962 | 186 | 2014-09-23 06:06:00 | 6,309 | 2024-08-18 02:41:29 | https://stackoverflow.com/q/25984310 | https://stackoverflow.com/a/25987962 | <p>Even without cloning or fetching, you can check the list of tags on the upstream repo with <a href="http://git-scm.com/docs/git-ls-remote" rel="noreferrer"><code>git ls-remote</code></a>:</p>
<pre><code>git ls-remote --tags /url/to/upstream/repo
</code></pre>
<p>(as illustrated in "<a href="https://stackoverflo... | <p>Even without cloning or fetching, you can check the list of tags on the upstream repo with <a href="http://git-scm.com/docs/git-ls-remote" rel="noreferrer"><code>git ls-remote</code></a>:</p> <pre><code>git ls-remote --tags /url/to/upstream/repo </code></pre> <p>(as illustrated in "<a href="https://stackoverflo... | 119, 90056 | atlassian-sourcetree, git | <h1>How to see remote tags?</h1>
<p>In Atlassian SourceTree, how to know which tags are only local and which are also in remote?</p>
<p>When creating a tag you get the option "Push tag to: ...", but how to know if a tag has been pushed or not after it is created? I can see all my tags locally, but I need to be sure th... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,169 | git | # How to see remote tags?
In Atlassian SourceTree, how to know which tags are only local and which are also in remote?
When creating a tag you get the option "Push tag to: ...", but how to know if a tag has been pushed or not after it is created? I can see all my tags locally, but I need to be sure that they are pres... | Even without cloning or fetching, you can check the list of tags on the upstream repo with [`git ls-remote`](http://git-scm.com/docs/git-ls-remote):
```
git ls-remote --tags /url/to/upstream/repo
```
(as illustrated in "[When listing git-ls-remote why there's “`^{}`” after the tag name?](https://stackoverflow.com/q/1... |
5814319 | Git submodule push | 174 | 2011-04-28 06:05:47 | <p>If I modify a submodule, can I push the commit back to the submodule origin, or would that require a clone?
If clone, can I store a clone inside another repository?</p>
| 196,579 | 194,515 | 2024-11-21 07:54:41 | 5,814,351 | 186 | 2011-04-28 06:08:28 | 526,535 | 2011-04-28 06:16:20 | https://stackoverflow.com/q/5814319 | https://stackoverflow.com/a/5814351 | <p>A submodule is nothing but a clone of a git repo within another repo with some extra meta data (gitlink tree entry, .gitmodules file )</p>
<pre><code>$ cd your_submodule
$ git checkout master
<hack,edit>
$ git commit -a -m "commit in submodule"
$ git push
$ cd ..
$ git add your_submodule
$ git commit -m "Upda... | <p>A submodule is nothing but a clone of a git repo within another repo with some extra meta data (gitlink tree entry, .gitmodules file )</p> <pre><code>$ cd your_submodule $ git checkout master <hack,edit> $ git commit -a -m "commit in submodule" $ git push $ cd .. $ git add your_submodule $ git commit -m "Upda... | 119, 41612 | git, git-submodules | <h1>Git submodule push</h1>
<p>If I modify a submodule, can I push the commit back to the submodule origin, or would that require a clone?
If clone, can I store a clone inside another repository?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,170 | git | # Git submodule push
If I modify a submodule, can I push the commit back to the submodule origin, or would that require a clone?
If clone, can I store a clone inside another repository? | A submodule is nothing but a clone of a git repo within another repo with some extra meta data (gitlink tree entry, .gitmodules file )
```
$ cd your_submodule
$ git checkout master
<hack,edit>
$ git commit -a -m "commit in submodule"
$ git push
$ cd ..
$ git add your_submodule
$ git commit -m "Updated submodule"
``` |
7275508 | Is there a way to squash a number of commits non-interactively? | 154 | 2011-09-01 19:31:51 | <p>I'm trying to squash a range of commits - HEAD to HEAD~3. Is there a quick way to do this, or do I need to use rebase --interactive?</p>
| 56,537 | 864,358 | 2021-12-29 18:54:40 | 7,275,658 | 186 | 2011-09-01 19:46:25 | 456 | 2019-11-13 21:24:47 | https://stackoverflow.com/q/7275508 | https://stackoverflow.com/a/7275658 | <p>Make sure your working tree is clean, then</p>
<pre><code>git reset --soft HEAD~3
git commit -m 'new commit message'
</code></pre>
| <p>Make sure your working tree is clean, then</p> <pre><code>git reset --soft HEAD~3 git commit -m 'new commit message' </code></pre> | 119, 4063, 8974, 42532 | git, interactive, rebase, squash | <h1>Is there a way to squash a number of commits non-interactively?</h1>
<p>I'm trying to squash a range of commits - HEAD to HEAD~3. Is there a quick way to do this, or do I need to use rebase --interactive?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,171 | git | # Is there a way to squash a number of commits non-interactively?
I'm trying to squash a range of commits - HEAD to HEAD~3. Is there a quick way to do this, or do I need to use rebase --interactive? | Make sure your working tree is clean, then
```
git reset --soft HEAD~3
git commit -m 'new commit message'
``` |
17324645 | git create commit from diff between two branches | 134 | 2013-06-26 15:44:35 | <p>I have two branches which have very little similar history, but are related to each other.</p>
<p>I want the changes between those two in <strong>one</strong> git commit.</p>
<p>files have been deleted and created between those patches and I want the patch to reflect that</p>
<p>i.e.: the following stuff will not... | 45,803 | 887,836 | 2023-01-05 19:36:51 | 17,324,759 | 186 | 2013-06-26 15:49:48 | 2,422,194 | 2021-09-21 18:47:02 | https://stackoverflow.com/q/17324645 | https://stackoverflow.com/a/17324759 | <p>A simple way to make "the diff from branch_b..branch_a" into a commit is:</p>
<ol>
<li>create and checkout branch tmp at branch_a (<code>git branch tmp branch_a && git checkout tmp</code>) (or <code>git reset --hard branch_a</code> on an existing branch)</li>
<li><code>git reset --soft branch_b</co... | <p>A simple way to make "the diff from branch_b..branch_a" into a commit is:</p> <ol> <li>create and checkout branch tmp at branch_a (<code>git branch tmp branch_a && git checkout tmp</code>) (or <code>git reset --hard branch_a</code> on an existing branch)</li> <li><code>git reset --soft branch_b</co... | 119 | git | <h1>git create commit from diff between two branches</h1>
<p>I have two branches which have very little similar history, but are related to each other.</p>
<p>I want the changes between those two in <strong>one</strong> git commit.</p>
<p>files have been deleted and created between those patches and I want the patch ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,172 | git | # git create commit from diff between two branches
I have two branches which have very little similar history, but are related to each other.
I want the changes between those two in **one** git commit.
files have been deleted and created between those patches and I want the patch to reflect that
i.e.: the following... | A simple way to make "the diff from branch_b..branch_a" into a commit is:
1. create and checkout branch tmp at branch_a (`git branch tmp branch_a && git checkout tmp`) (or `git reset --hard branch_a` on an existing branch)
2. `git reset --soft branch_b`
3. `git commit`
that commit will include all the diff between br... |
18345115 | How do you revert to a specific tag in Git? | 133 | 2013-08-20 21:17:28 | <p>I know how to revert to older commits in a Git branch, but how do I revert back to a branch's state dictated by a tag? I envision something like this:</p>
<pre><code>git revert -bytag "Version 1.0 Revision 1.5"
</code></pre>
<p>Is this possible?</p>
| 205,960 | 1,176,806 | 2023-05-10 14:26:08 | 18,354,193 | 186 | 2013-08-21 09:49:46 | 2,527,338 | 2014-03-20 16:39:46 | https://stackoverflow.com/q/18345115 | https://stackoverflow.com/a/18354193 | <p>Git tags are just pointers to the commit. So you use them the same way as you do HEAD, branch names or commit sha hashes. You can use tags with any git command that accepts commit/revision arguments. You can try it with <code>git rev-parse tagname</code> to display the commit it points to.</p>
<p>In your case you h... | <p>Git tags are just pointers to the commit. So you use them the same way as you do HEAD, branch names or commit sha hashes. You can use tags with any git command that accepts commit/revision arguments. You can try it with <code>git rev-parse tagname</code> to display the commit it points to.</p> <p>In your case you h... | 115, 119, 1097, 12309 | git, revert, tagging, tags | <h1>How do you revert to a specific tag in Git?</h1>
<p>I know how to revert to older commits in a Git branch, but how do I revert back to a branch's state dictated by a tag? I envision something like this:</p>
<pre><code>git revert -bytag "Version 1.0 Revision 1.5"
</code></pre>
<p>Is this possible?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,173 | git | # How do you revert to a specific tag in Git?
I know how to revert to older commits in a Git branch, but how do I revert back to a branch's state dictated by a tag? I envision something like this:
```
git revert -bytag "Version 1.0 Revision 1.5"
```
Is this possible? | Git tags are just pointers to the commit. So you use them the same way as you do HEAD, branch names or commit sha hashes. You can use tags with any git command that accepts commit/revision arguments. You can try it with `git rev-parse tagname` to display the commit it points to.
In your case you have at least these tw... |
22058041 | Commit Without Setting User Name and Email | 121 | 2014-02-27 02:49:22 | <p>I try to <code>commit</code> like this:</p>
<pre class="lang-shell prettyprint-override"><code>git commit --author='Paul Draper <my@email.org>' -m 'My commit message'
</code></pre>
<p>but I get:</p>
<pre class="lang-shell prettyprint-override"><code>*** Please tell me who you are.
Run
git config --global use... | 57,833 | 1,212,596 | 2022-02-11 13:16:57 | 22,058,263 | 186 | 2014-02-27 03:10:32 | 1,256,452 | 2019-05-15 14:06:37 | https://stackoverflow.com/q/22058041 | https://stackoverflow.com/a/22058263 | <p>(This occurred to me after suggesting the long version with the environment variables—git commit wants to set both an author and a committer, and <code>--author</code> only overrides the former.)</p>
<p>All git commands take <code>-c</code> arguments <strong>before</strong> the action verb to set temporary configur... | <p>(This occurred to me after suggesting the long version with the environment variables—git commit wants to set both an author and a committer, and <code>--author</code> only overrides the former.)</p> <p>All git commands take <code>-c</code> arguments <strong>before</strong> the action verb to set temporary configur... | 119 | git | <h1>Commit Without Setting User Name and Email</h1>
<p>I try to <code>commit</code> like this:</p>
<pre class="lang-shell prettyprint-override"><code>git commit --author='Paul Draper <my@email.org>' -m 'My commit message'
</code></pre>
<p>but I get:</p>
<pre class="lang-shell prettyprint-override"><code>*** Pleas... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,174 | git | # Commit Without Setting User Name and Email
I try to `commit` like this:
```
git commit --author='Paul Draper <my@email.org>' -m 'My commit message'
```
but I get:
```
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your accou... | (This occurred to me after suggesting the long version with the environment variables—git commit wants to set both an author and a committer, and `--author` only overrides the former.)
All git commands take `-c` arguments **before** the action verb to set temporary configuration data, so that's the perfect place for t... |
40975751 | Copy changes from one branch to another | 166 | 2016-12-05 13:47:39 | <p>I have a branch named <code>BranchA</code> from <code>master</code>. I have some changes in <code>BranchA</code> (I am not going to merge changes from <code>BranchA</code> to <code>master</code>).</p>
<p>Now I have created another branch from <code>master</code> named <code>BranchB</code>.</p>
<p>How can I copy the ... | 442,368 | 4,717,427 | 2023-12-19 15:53:07 | 40,975,961 | 185 | 2016-12-05 13:57:51 | 813,040 | 2021-11-04 08:52:04 | https://stackoverflow.com/q/40975751 | https://stackoverflow.com/a/40975961 | <pre><code>git checkout BranchB
git merge BranchA
</code></pre>
<p>This is all if you intend to not merge your changes back to master. Generally it is a good practice to merge all your changes back to master, and create new branches off of that.</p>
<p>Also, after the merge command, you will have some conflicts, which ... | <pre><code>git checkout BranchB git merge BranchA </code></pre> <p>This is all if you intend to not merge your changes back to master. Generally it is a good practice to merge all your changes back to master, and create new branches off of that.</p> <p>Also, after the merge command, you will have some conflicts, which ... | 119, 53847, 76220 | branching-and-merging, git, git-branch | <h1>Copy changes from one branch to another</h1>
<p>I have a branch named <code>BranchA</code> from <code>master</code>. I have some changes in <code>BranchA</code> (I am not going to merge changes from <code>BranchA</code> to <code>master</code>).</p>
<p>Now I have created another branch from <code>master</code> named... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,175 | git | # Copy changes from one branch to another
I have a branch named `BranchA` from `master`. I have some changes in `BranchA` (I am not going to merge changes from `BranchA` to `master`).
Now I have created another branch from `master` named `BranchB`.
How can I copy the changes from `BranchA` to `BranchB`? | ```
git checkout BranchB
git merge BranchA
```
This is all if you intend to not merge your changes back to master. Generally it is a good practice to merge all your changes back to master, and create new branches off of that.
Also, after the merge command, you will have some conflicts, which you will have to edit man... |
3719574 | is it possible to ignore .gitignore rules in subdirectory? | 124 | 2010-09-15 16:07:15 | <p>I want to ignore all of .gitignore rules in subdirectory except .gitignore rules in root.</p>
<p>for example:
I already have <code>.gitignore</code> file in a directory structure <code>/a</code>.</p>
<p>And also have <code>.gitignore</code> file in <code>/a/b</code>. Assume <code>/a</code> has <code>a.txt</code> and... | 108,367 | 205,589 | 2022-09-17 19:32:25 | 3,721,910 | 185 | 2010-09-15 21:22:47 | 417,080 | 2010-09-15 21:22:47 | https://stackoverflow.com/q/3719574 | https://stackoverflow.com/a/3721910 | <p>Your question isn't too clear, but if there are some subdirectories where you want different gitignore rules, you can just create a new .gitignore in that directory.</p>
<p>Say you have:</p>
<pre>
project/.gitignore
project/stuff/.gitignore
</pre>
<p>The .gitignore in stuff/ will override the .gitignore in the ro... | <p>Your question isn't too clear, but if there are some subdirectories where you want different gitignore rules, you can just create a new .gitignore in that directory.</p> <p>Say you have:</p> <pre> project/.gitignore project/stuff/.gitignore </pre> <p>The .gitignore in stuff/ will override the .gitignore in the ro... | 119 | git | <h1>is it possible to ignore .gitignore rules in subdirectory?</h1>
<p>I want to ignore all of .gitignore rules in subdirectory except .gitignore rules in root.</p>
<p>for example:
I already have <code>.gitignore</code> file in a directory structure <code>/a</code>.</p>
<p>And also have <code>.gitignore</code> file in ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,176 | git | # is it possible to ignore .gitignore rules in subdirectory?
I want to ignore all of .gitignore rules in subdirectory except .gitignore rules in root.
for example:
I already have `.gitignore` file in a directory structure `/a`.
And also have `.gitignore` file in `/a/b`. Assume `/a` has `a.txt` and `b.txt` files.
`/... | Your question isn't too clear, but if there are some subdirectories where you want different gitignore rules, you can just create a new .gitignore in that directory.
Say you have:
```
project/.gitignore
project/stuff/.gitignore
```
The .gitignore in stuff/ will override the .gitignore in the root directory.
`git he... |
5689960 | How do I create a commit without a parent in Git? | 110 | 2011-04-16 22:11:25 | <p>I have a small project I was working on without any kind of version control software, and I ended up with three different versions of the same script, where each one does something slightly different from the others. I initialized a git repo with one of the versions, and I'd really like to commit each of the other t... | 40,488 | 648,855 | 2020-01-25 02:49:57 | 5,690,048 | 185 | 2011-04-16 22:26:01 | 526,535 | 2012-05-14 08:21:38 | https://stackoverflow.com/q/5689960 | https://stackoverflow.com/a/5690048 | <p>From my comment:</p>
<blockquote>
<p>Why don't you create two branches and add the two other versions to them and then work on the branches?</p>
</blockquote>
<p>Which I think would agree with ctcherry's answer as well.</p>
<hr>
<p>But if you really do want to create a completely different "branch" that is unr... | <p>From my comment:</p> <blockquote> <p>Why don't you create two branches and add the two other versions to them and then work on the branches?</p> </blockquote> <p>Which I think would agree with ctcherry's answer as well.</p> <hr> <p>But if you really do want to create a completely different "branch" that is unr... | 119 | git | <h1>How do I create a commit without a parent in Git?</h1>
<p>I have a small project I was working on without any kind of version control software, and I ended up with three different versions of the same script, where each one does something slightly different from the others. I initialized a git repo with one of the ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,178 | git | # How do I create a commit without a parent in Git?
I have a small project I was working on without any kind of version control software, and I ended up with three different versions of the same script, where each one does something slightly different from the others. I initialized a git repo with one of the versions,... | From my comment:
> Why don't you create two branches and add the two other versions to them and then work on the branches?
Which I think would agree with ctcherry's answer as well.
---
But if you really do want to create a completely different "branch" that is unrelated to master, then you can do it with `git check... |
4592838 | Symbolic link to a hook in git | 107 | 2011-01-04 10:58:03 | <p>I wrote my own custom post-merge hook, now I added a "hooks" directory to my main project folder (since git doesn't track changes in .git/hooks), somewhere I read that I can make a symbolic link from hooks to .git/hooks so I don't have to copy the file from one folder to the other every time someone changes it so I ... | 35,967 | 217,019 | 2018-11-21 17:51:53 | 4,594,681 | 185 | 2011-01-04 14:30:27 | 225,718 | 2011-01-04 14:30:27 | https://stackoverflow.com/q/4592838 | https://stackoverflow.com/a/4594681 | <p>you just used wrong path, it should be:</p>
<pre><code>ln -s -f ../../hooks/post-merge .git/hooks/post-merge
</code></pre>
| <p>you just used wrong path, it should be:</p> <pre><code>ln -s -f ../../hooks/post-merge .git/hooks/post-merge </code></pre> | 58, 119, 43087 | git, githooks, linux | <h1>Symbolic link to a hook in git</h1>
<p>I wrote my own custom post-merge hook, now I added a "hooks" directory to my main project folder (since git doesn't track changes in .git/hooks), somewhere I read that I can make a symbolic link from hooks to .git/hooks so I don't have to copy the file from one folder to the o... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,179 | git | # Symbolic link to a hook in git
I wrote my own custom post-merge hook, now I added a "hooks" directory to my main project folder (since git doesn't track changes in .git/hooks), somewhere I read that I can make a symbolic link from hooks to .git/hooks so I don't have to copy the file from one folder to the other ever... | you just used wrong path, it should be:
```
ln -s -f ../../hooks/post-merge .git/hooks/post-merge
``` |
2519933 | GIT clone repo across local file system in windows | 209 | 2010-03-25 22:34:47 | <p>I am a complete Noob when it comes to GIT. I have been just taking my first steps over the last few days. I setup a repo on my laptop, pulled down the Trunk from an SVN project (had some issues with branches, not got them working), but all seems ok there.</p>
<p>I now want to be able to pull or push from the lapt... | 218,105 | 6,486 | 2019-11-22 12:54:01 | 2,520,121 | 184 | 2010-03-25 23:16:55 | 216,074 | 2014-11-15 22:20:27 | https://stackoverflow.com/q/2519933 | https://stackoverflow.com/a/2520121 | <p>You can specify the remote’s URL by applying the <a href="http://msdn.microsoft.com/en-us/library/gg465305.aspx" rel="noreferrer" title="Universal Naming Convention">UNC</a> path to the file protocol. This requires you to use four slashes:</p>
<pre><code>git clone file:////<host>/<share>/<path>
</... | <p>You can specify the remote’s URL by applying the <a href="http://msdn.microsoft.com/en-us/library/gg465305.aspx" rel="noreferrer" title="Universal Naming Convention">UNC</a> path to the file protocol. This requires you to use four slashes:</p> <pre><code>git clone file:////<host>/<share>/<path> </... | 64, 119, 34099 | git, git-clone, windows | <h1>GIT clone repo across local file system in windows</h1>
<p>I am a complete Noob when it comes to GIT. I have been just taking my first steps over the last few days. I setup a repo on my laptop, pulled down the Trunk from an SVN project (had some issues with branches, not got them working), but all seems ok there.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,180 | git | # GIT clone repo across local file system in windows
I am a complete Noob when it comes to GIT. I have been just taking my first steps over the last few days. I setup a repo on my laptop, pulled down the Trunk from an SVN project (had some issues with branches, not got them working), but all seems ok there.
I now wan... | You can specify the remote’s URL by applying the [UNC](http://msdn.microsoft.com/en-us/library/gg465305.aspx "Universal Naming Convention") path to the file protocol. This requires you to use four slashes:
```
git clone file:////<host>/<share>/<path>
```
For example, if your main machine has the IP *192.168.10.51* an... |
984707 | What are the file limits in Git (number and size)? | 203 | 2009-06-12 02:10:22 | <p>Does anyone know what are the Git limits for number of files and size of files?</p>
| 149,262 | 121,095 | 2023-10-04 20:01:43 | 984,973 | 184 | 2009-06-12 04:21:14 | 6,309 | 2019-06-27 15:12:32 | https://stackoverflow.com/q/984707 | https://stackoverflow.com/a/984973 | <p>This message from <a href="https://marc.info/?l=git&m=124121401124923&w=2" rel="noreferrer">Linus himself</a> can help you with some other limits</p>
<blockquote>
<p>[...] CVS, ie it really ends up being pretty much oriented to a "one file
at a time" model.</p>
<p>Which is nice in that you can have... | <p>This message from <a href="https://marc.info/?l=git&m=124121401124923&w=2" rel="noreferrer">Linus himself</a> can help you with some other limits</p> <blockquote> <p>[...] CVS, ie it really ends up being pretty much oriented to a "one file at a time" model.</p> <p>Which is nice in that you can have... | 119 | git | <h1>What are the file limits in Git (number and size)?</h1>
<p>Does anyone know what are the Git limits for number of files and size of files?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,181 | git | # What are the file limits in Git (number and size)?
Does anyone know what are the Git limits for number of files and size of files? | This message from [Linus himself](https://marc.info/?l=git&m=124121401124923&w=2) can help you with some other limits
> [...] CVS, ie it really ends up being pretty much oriented to a "one file
> at a time" model.
>
> Which is nice in that you can have a million files, and then only check
> out a few of them - you'll ... |
1395445 | Viewing a Deleted File in Git | 136 | 2009-09-08 18:11:36 | <p>I've deleted a file with Git and then committed, so the file is no longer in my working copy. I want to look at the contents of that file, but not actually restore it. How can I do this?</p>
| 35,625 | 125,680 | 2023-05-04 22:16:02 | 1,395,463 | 184 | 2009-09-08 18:15:52 | 19,563 | 2009-09-08 18:15:52 | https://stackoverflow.com/q/1395445 | https://stackoverflow.com/a/1395463 | <pre><code>git show HEAD^:path/to/file
</code></pre>
<p>You can use an explicit commit identifier or <code>HEAD~n</code> to see older versions or if there has been more than one commit since you deleted it.</p>
| <pre><code>git show HEAD^:path/to/file </code></pre> <p>You can use an explicit commit identifier or <code>HEAD~n</code> to see older versions or if there has been more than one commit since you deleted it.</p> | 119 | git | <h1>Viewing a Deleted File in Git</h1>
<p>I've deleted a file with Git and then committed, so the file is no longer in my working copy. I want to look at the contents of that file, but not actually restore it. How can I do this?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,182 | git | # Viewing a Deleted File in Git
I've deleted a file with Git and then committed, so the file is no longer in my working copy. I want to look at the contents of that file, but not actually restore it. How can I do this? | ```
git show HEAD^:path/to/file
```
You can use an explicit commit identifier or `HEAD~n` to see older versions or if there has been more than one commit since you deleted it. |
5383609 | Using Git with an existing Xcode project | 120 | 2011-03-21 20:56:31 | <p>I am trying to figure out how to use git in my project workflow, and I have an existing Xcode project that I want to put into the repository. I think I have the repository set up correctly under organizer, but the Source Control menu is grayed out.<br>
Apparently, it's easy to do if you start a new project, but how ... | 115,054 | 356,438 | 2022-04-25 19:10:05 | 5,383,712 | 184 | 2011-03-21 21:04:21 | 460,450 | 2015-10-03 10:56:48 | https://stackoverflow.com/q/5383609 | https://stackoverflow.com/a/5383712 | <p>GitHub has some very good git tutorials at <a href="http://help.github.com">help.github.com</a>.</p>
<p>to do the initial setup of a repository, open up a terminal window, and CD to the project directory. once there, type </p>
<pre><code>git init
git add .
git commit -m "Initial commit"
</code></pre>
<p>Restart X... | <p>GitHub has some very good git tutorials at <a href="http://help.github.com">help.github.com</a>.</p> <p>to do the initial setup of a repository, open up a terminal window, and CD to the project directory. once there, type </p> <pre><code>git init git add . git commit -m "Initial commit" </code></pre> <p>Restart X... | 119, 908 | git, xcode | <h1>Using Git with an existing Xcode project</h1>
<p>I am trying to figure out how to use git in my project workflow, and I have an existing Xcode project that I want to put into the repository. I think I have the repository set up correctly under organizer, but the Source Control menu is grayed out.<br>
Apparently, it... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,183 | git | # Using Git with an existing Xcode project
I am trying to figure out how to use git in my project workflow, and I have an existing Xcode project that I want to put into the repository. I think I have the repository set up correctly under organizer, but the Source Control menu is grayed out.
Apparently, it's easy to ... | GitHub has some very good git tutorials at [help.github.com](http://help.github.com).
to do the initial setup of a repository, open up a terminal window, and CD to the project directory. once there, type
```
git init
git add .
git commit -m "Initial commit"
```
Restart Xcode.
The repository should now be set up, and... |
16408300 | What are the differences between local branch, local tracking branch, remote branch and remote tracking branch? | 219 | 2013-05-06 22:24:39 | <p>I just started using Git and I got really confused between different branches. Can anyone help me to figure out what the following branch types are?</p>
<ul>
<li>local branches</li>
<li>local tracking branches</li>
<li>remote branches </li>
<li>remote tracking branches </li>
</ul>
<p>What is the difference between... | 155,508 | 1,361,407 | 2023-07-16 08:16:17 | 16,408,515 | 183 | 2013-05-06 22:46:28 | 1,311,354 | 2021-01-02 08:50:19 | https://stackoverflow.com/q/16408300 | https://stackoverflow.com/a/16408515 | <p>A <strong>local branch</strong> is a branch that only you (the local user) can see. It exists only on your local machine.</p>
<pre><code>git branch myNewBranch # Create local branch named "myNewBranch"
</code></pre>
<p>A <strong>remote branch</strong> is a branch on a remote location (in most cases ... | <p>A <strong>local branch</strong> is a branch that only you (the local user) can see. It exists only on your local machine.</p> <pre><code>git branch myNewBranch # Create local branch named "myNewBranch" </code></pre> <p>A <strong>remote branch</strong> is a branch on a remote location (in most cases ... | 119, 456, 41346, 76220 | git, git-branch, git-remote, version-control | <h1>What are the differences between local branch, local tracking branch, remote branch and remote tracking branch?</h1>
<p>I just started using Git and I got really confused between different branches. Can anyone help me to figure out what the following branch types are?</p>
<ul>
<li>local branches</li>
<li>local tra... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,184 | git | # What are the differences between local branch, local tracking branch, remote branch and remote tracking branch?
I just started using Git and I got really confused between different branches. Can anyone help me to figure out what the following branch types are?
- local branches
- local tracking branches
- remote bra... | A **local branch** is a branch that only you (the local user) can see. It exists only on your local machine.
```
git branch myNewBranch # Create local branch named "myNewBranch"
```
A **remote branch** is a branch on a remote location (in most cases `origin`). You can push the newly created local branch `myNew... |
35122376 | How can I remove a file from Git within IntelliJ VCS? | 144 | 2016-02-01 02:55:11 | <p>VCS has an <code>Add</code> option (Git Add) but seems to lack Git Remove.</p>
<p>What's the idiomatic way to Git Remove with VCS?</p>
| 122,656 | 1,938,929 | 2023-10-27 09:11:22 | 48,191,707 | 183 | 2018-01-10 16:15:08 | 3,464,979 | 2018-01-10 16:15:08 | https://stackoverflow.com/q/35122376 | https://stackoverflow.com/a/48191707 | <p>In the terminal, use <code>git rm --cached -r .idea/</code>.
This will remove the files from the GIT index, but leave the files locally.</p>
| <p>In the terminal, use <code>git rm --cached -r .idea/</code>. This will remove the files from the GIT index, but leave the files locally.</p> | 119, 456, 8945 | git, intellij-idea, version-control | <h1>How can I remove a file from Git within IntelliJ VCS?</h1>
<p>VCS has an <code>Add</code> option (Git Add) but seems to lack Git Remove.</p>
<p>What's the idiomatic way to Git Remove with VCS?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,185 | git | # How can I remove a file from Git within IntelliJ VCS?
VCS has an `Add` option (Git Add) but seems to lack Git Remove.
What's the idiomatic way to Git Remove with VCS? | In the terminal, use `git rm --cached -r .idea/`.
This will remove the files from the GIT index, but leave the files locally. |
5188274 | How do I interactively unstage a particular hunk in git? | 133 | 2011-03-04 00:20:50 | <p>In git, if I have a couple of hunks from the same file staged in my index, how can I interactively unstage one of them?</p>
<p>Is there any alternative to unstaging the entire file, and then re-staging the hunks I want to keep, or manually undoing the changes to the working copy, and then interactively adding those... | 17,950 | 38,765 | 2018-05-01 22:36:12 | 5,188,372 | 183 | 2011-03-04 00:34:51 | 626,853 | 2014-07-31 12:50:45 | https://stackoverflow.com/q/5188274 | https://stackoverflow.com/a/5188372 | <p>Try <code>git reset --patch filename</code>; this should do the opposite of <code>git add --patch</code>, according to the <a href="http://git-scm.com/docs/git-reset">documentation</a>. The short form <code>-p</code> also works for both commands.</p>
| <p>Try <code>git reset --patch filename</code>; this should do the opposite of <code>git add --patch</code>, according to the <a href="http://git-scm.com/docs/git-reset">documentation</a>. The short form <code>-p</code> also works for both commands.</p> | 119, 20002 | git, staging | <h1>How do I interactively unstage a particular hunk in git?</h1>
<p>In git, if I have a couple of hunks from the same file staged in my index, how can I interactively unstage one of them?</p>
<p>Is there any alternative to unstaging the entire file, and then re-staging the hunks I want to keep, or manually undoing th... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,188 | git | # How do I interactively unstage a particular hunk in git?
In git, if I have a couple of hunks from the same file staged in my index, how can I interactively unstage one of them?
Is there any alternative to unstaging the entire file, and then re-staging the hunks I want to keep, or manually undoing the changes to the... | Try `git reset --patch filename`; this should do the opposite of `git add --patch`, according to the [documentation](http://git-scm.com/docs/git-reset). The short form `-p` also works for both commands. |
1499157 | Git checkout/pull doesn't remove directories? | 103 | 2009-09-30 16:11:28 | <p>I've got my repo @ github. I did some work at home and pushed it to github. It involved some deleting of files and directories. Now I'm on my work box, which had a copy of the code before deleting the files and directories.</p>
<p>I issued the following:</p>
<pre><code>git remote update
git checkout HEAD
git pull ... | 53,922 | 181,489 | 2023-06-13 11:56:05 | 1,499,824 | 183 | 2009-09-30 18:19:24 | 28,804 | 2009-09-30 18:19:24 | https://stackoverflow.com/q/1499157 | https://stackoverflow.com/a/1499824 | <p>Git doesn't track directories, so it won't remove ones that become empty as a result of a merge or other change. However, you can use <code>git clean -fd</code> to remove untracked directories (the <code>-fd</code> flag means <em>f</em>orce removal of untracked files and <em>d</em>irectories).</p>
| <p>Git doesn't track directories, so it won't remove ones that become empty as a result of a merge or other change. However, you can use <code>git clean -fd</code> to remove untracked directories (the <code>-fd</code> flag means <em>f</em>orce removal of untracked files and <em>d</em>irectories).</p> | 119, 68596 | git, git-clean | <h1>Git checkout/pull doesn't remove directories?</h1>
<p>I've got my repo @ github. I did some work at home and pushed it to github. It involved some deleting of files and directories. Now I'm on my work box, which had a copy of the code before deleting the files and directories.</p>
<p>I issued the following:</p>
<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,191 | git | # Git checkout/pull doesn't remove directories?
I've got my repo @ github. I did some work at home and pushed it to github. It involved some deleting of files and directories. Now I'm on my work box, which had a copy of the code before deleting the files and directories.
I issued the following:
```
git remote update... | Git doesn't track directories, so it won't remove ones that become empty as a result of a merge or other change. However, you can use `git clean -fd` to remove untracked directories (the `-fd` flag means *f*orce removal of untracked files and *d*irectories). |
13698978 | Git - undoing git rm | 97 | 2012-12-04 08:46:21 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/2125710/how-to-revert-a-git-rm-r">How to revert a “git rm -r .”?</a> </p>
</blockquote>
<p>Git SOS here. I worked 10 hours on a project without committing (I know, I know) and then I git added too many files, s... | 81,663 | 1,436,111 | 2019-10-15 09:00:16 | 13,699,072 | 183 | 2012-12-04 08:52:04 | 1,017,941 | 2019-10-15 09:00:16 | https://stackoverflow.com/q/13698978 | https://stackoverflow.com/a/13699072 | <p>If you already commited changes, then:</p>
<pre><code>git reset (--hard) HEAD~1
</code></pre>
<p>If not then:</p>
<pre><code>git reset
git ls-files -d -z | xargs -0 git checkout --
</code></pre>
| <p>If you already commited changes, then:</p> <pre><code>git reset (--hard) HEAD~1 </code></pre> <p>If not then:</p> <pre><code>git reset git ls-files -d -z | xargs -0 git checkout -- </code></pre> | 119, 112901 | git, git-rm | <h1>Git - undoing git rm</h1>
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/2125710/how-to-revert-a-git-rm-r">How to revert a “git rm -r .”?</a> </p>
</blockquote>
<p>Git SOS here. I worked 10 hours on a project without committing (I know, I know) and then... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,192 | git | # Git - undoing git rm
> **Possible Duplicate:**
> [How to revert a “git rm -r .”?](https://stackoverflow.com/questions/2125710/how-to-revert-a-git-rm-r)
Git SOS here. I worked 10 hours on a project without committing (I know, I know) and then I git added too many files, so I tried using git rm and accidentally del... | If you already commited changes, then:
```
git reset (--hard) HEAD~1
```
If not then:
```
git reset
git ls-files -d -z | xargs -0 git checkout --
``` |
17570446 | How do I add Git version control (Bitbucket) to an existing source code folder? | 86 | 2013-07-10 11:03:15 | <p>How can I add the contents of an existing folder to Git version control?</p>
<p>The tutorial <a href="https://confluence.atlassian.com/display/BITBUCKET/Create+an+Account+and+a+Git+Repo" rel="noreferrer">here</a> covers the case of making a directory and then adding source contents to it. I have some source code in... | 160,294 | 1,406,716 | 2017-11-29 23:00:46 | 36,550,960 | 183 | 2016-04-11 14:02:04 | 3,595,288 | 2017-02-22 11:59:46 | https://stackoverflow.com/q/17570446 | https://stackoverflow.com/a/36550960 | <p><strong>Final working solution</strong>
using @Arrigo response and @Samitha Chathuranga comment, I'll put all together to build a full response for this question:</p>
<ol>
<li>Suppose you have your project folder on PC;</li>
<li><p>Create a new repository on bitbucket:
<a href="https://i.sstatic.net/yOLBC.jpg" rel=... | <p><strong>Final working solution</strong> using @Arrigo response and @Samitha Chathuranga comment, I'll put all together to build a full response for this question:</p> <ol> <li>Suppose you have your project folder on PC;</li> <li><p>Create a new repository on bitbucket: <a href="https://i.sstatic.net/yOLBC.jpg" rel=... | 119, 8337 | bitbucket, git | <h1>How do I add Git version control (Bitbucket) to an existing source code folder?</h1>
<p>How can I add the contents of an existing folder to Git version control?</p>
<p>The tutorial <a href="https://confluence.atlassian.com/display/BITBUCKET/Create+an+Account+and+a+Git+Repo" rel="noreferrer">here</a> covers the cas... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,193 | git | # How do I add Git version control (Bitbucket) to an existing source code folder?
How can I add the contents of an existing folder to Git version control?
The tutorial [here](https://confluence.atlassian.com/display/BITBUCKET/Create+an+Account+and+a+Git+Repo) covers the case of making a directory and then adding sour... | **Final working solution**
using @Arrigo response and @Samitha Chathuranga comment, I'll put all together to build a full response for this question:
1. Suppose you have your project folder on PC;
2. Create a new repository on bitbucket:
[](https://i.s... |
5709687 | What are the "loose objects" that the Git GUI refers to? | 266 | 2011-04-18 22:38:14 | <p>When I open the <strong>Git GUI</strong>, I get a popup message that refers to <code>loose objects</code>. I did <code>git gc</code> and that removed the message.</p>
<p>What are <code>loose objects</code> and how could I prevent this from occurring again?</p>
| 96,496 | 342,259 | 2024-09-21 20:38:25 | 5,710,039 | 182 | 2011-04-18 23:37:48 | 526,535 | 2022-02-19 17:24:24 | https://stackoverflow.com/q/5709687 | https://stackoverflow.com/a/5710039 | <p>An object (blobs, trees, and commits) with SHA say - <code>810cae53e0f622d6804f063c04a83dbc3a11b7ca</code> will be stored at</p>
<pre><code>.git/objects/81/0cae53e0f622d6804f063c04a83dbc3a11b7ca
</code></pre>
<p>( the split in first two characters to improve performance of the File system as now not all the objects... | <p>An object (blobs, trees, and commits) with SHA say - <code>810cae53e0f622d6804f063c04a83dbc3a11b7ca</code> will be stored at</p> <pre><code>.git/objects/81/0cae53e0f622d6804f063c04a83dbc3a11b7ca </code></pre> <p>( the split in first two characters to improve performance of the File system as now not all the objects... | 119, 33729 | git, git-gui | <h1>What are the "loose objects" that the Git GUI refers to?</h1>
<p>When I open the <strong>Git GUI</strong>, I get a popup message that refers to <code>loose objects</code>. I did <code>git gc</code> and that removed the message.</p>
<p>What are <code>loose objects</code> and how could I prevent this from occurring ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,194 | git | # What are the "loose objects" that the Git GUI refers to?
When I open the **Git GUI**, I get a popup message that refers to `loose objects`. I did `git gc` and that removed the message.
What are `loose objects` and how could I prevent this from occurring again? | An object (blobs, trees, and commits) with SHA say - `810cae53e0f622d6804f063c04a83dbc3a11b7ca` will be stored at
```
.git/objects/81/0cae53e0f622d6804f063c04a83dbc3a11b7ca
```
( the split in first two characters to improve performance of the File system as now not all the objects are stored in the same directory)
O... |
16068186 | How to cherry pick only changes for only one file, not the whole commit | 145 | 2013-04-17 19:09:19 | <p>I need to apply changes introduced in one branch to another branch.
I can use cherry pick to do that. However, in my case I want to apply changes which are relevant only for one file, I don't need to cherry pick whole commit.
How to do that?</p>
| 91,666 | 1,082,727 | 2024-04-30 19:32:12 | 16,068,510 | 182 | 2013-04-17 19:25:31 | 216,074 | 2013-04-17 19:25:31 | https://stackoverflow.com/q/16068186 | https://stackoverflow.com/a/16068510 | <p>You have different options based on what you want to achieve:</p>
<p>If you want the contents of the file to be the same as on the target branch, you can use <code>git checkout <branch> -- <filename></code>. This will however not “cherry-pick” the changes that happened in a single commit, but just take ... | <p>You have different options based on what you want to achieve:</p> <p>If you want the contents of the file to be the same as on the target branch, you can use <code>git checkout <branch> -- <filename></code>. This will however not “cherry-pick” the changes that happened in a single commit, but just take ... | 119 | git | <h1>How to cherry pick only changes for only one file, not the whole commit</h1>
<p>I need to apply changes introduced in one branch to another branch.
I can use cherry pick to do that. However, in my case I want to apply changes which are relevant only for one file, I don't need to cherry pick whole commit.
How to do ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,196 | git | # How to cherry pick only changes for only one file, not the whole commit
I need to apply changes introduced in one branch to another branch.
I can use cherry pick to do that. However, in my case I want to apply changes which are relevant only for one file, I don't need to cherry pick whole commit.
How to do that? | You have different options based on what you want to achieve:
If you want the contents of the file to be the same as on the target branch, you can use `git checkout <branch> -- <filename>`. This will however not “cherry-pick” the changes that happened in a single commit, but just take the resulting state of said file.... |
26021040 | Remove .pyc files from Git remote repository | 84 | 2014-09-24 15:38:30 | <p>Accidentally, I have pushed the .pyc files to the master repository. Now I want to delete them but I can´t do it. Is there any way to remove them directly from the Bitbucket site?</p>
| 80,655 | 2,190,906 | 2020-03-11 08:49:19 | 26,097,537 | 182 | 2014-09-29 10:17:59 | 2,266,320 | 2016-08-22 01:20:24 | https://stackoverflow.com/q/26021040 | https://stackoverflow.com/a/26097537 | <ol>
<li><strong>Remove</strong> <code>.pyc</code> files using <code>git rm *.pyc</code>. If this not work use <code>git rm -f *.pyc</code></li>
<li><strong>Commit</strong> <code>git commit -a -m 'all pyc files removed'</code></li>
<li><strong>Push</strong> <code>git push</code></li>
<li>In future commits you can ignor... | <ol> <li><strong>Remove</strong> <code>.pyc</code> files using <code>git rm *.pyc</code>. If this not work use <code>git rm -f *.pyc</code></li> <li><strong>Commit</strong> <code>git commit -a -m 'all pyc files removed'</code></li> <li><strong>Push</strong> <code>git push</code></li> <li>In future commits you can ignor... | 119, 41628 | git, pyc | <h1>Remove .pyc files from Git remote repository</h1>
<p>Accidentally, I have pushed the .pyc files to the master repository. Now I want to delete them but I can´t do it. Is there any way to remove them directly from the Bitbucket site?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,199 | git | # Remove .pyc files from Git remote repository
Accidentally, I have pushed the .pyc files to the master repository. Now I want to delete them but I can´t do it. Is there any way to remove them directly from the Bitbucket site? | 1. **Remove** `.pyc` files using `git rm *.pyc`. If this not work use `git rm -f *.pyc`
2. **Commit** `git commit -a -m 'all pyc files removed'`
3. **Push** `git push`
4. In future commits you can ignore `.pyc` files by creating a `.gitignore` file |
7484199 | How to test a merge without actually merging first | 238 | 2011-09-20 11:12:46 | <p>Is there any way of simulating a <code>git merge</code> between two branches, the current working branch and the master, but without making any changes?</p>
<p>I often have conflicts when I have to make a <code>git merge</code>. Is there any way of simulating the merge first?</p>
| 143,888 | 86,112 | 2023-11-29 13:35:24 | 7,484,246 | 181 | 2011-09-20 11:16:44 | 223,092 | 2013-12-08 09:24:10 | https://stackoverflow.com/q/7484199 | https://stackoverflow.com/a/7484246 | <p>I don't think there is a way of simulating what will happen until you try the merge. However, if you make sure that the output of <code>git status</code> is empty before you do the merge, it is quite safe to just go ahead and try it. If you get conflicts, you can immediately get back to the state you were at befor... | <p>I don't think there is a way of simulating what will happen until you try the merge. However, if you make sure that the output of <code>git status</code> is empty before you do the merge, it is quite safe to just go ahead and try it. If you get conflicts, you can immediately get back to the state you were at befor... | 119, 717 | git, merge | <h1>How to test a merge without actually merging first</h1>
<p>Is there any way of simulating a <code>git merge</code> between two branches, the current working branch and the master, but without making any changes?</p>
<p>I often have conflicts when I have to make a <code>git merge</code>. Is there any way of simulat... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,200 | git | # How to test a merge without actually merging first
Is there any way of simulating a `git merge` between two branches, the current working branch and the master, but without making any changes?
I often have conflicts when I have to make a `git merge`. Is there any way of simulating the merge first? | I don't think there is a way of simulating what will happen until you try the merge. However, if you make sure that the output of `git status` is empty before you do the merge, it is quite safe to just go ahead and try it. If you get conflicts, you can immediately get back to the state you were at before with:
```
git... |
5721566 | Combining Multiple Commits Into One Prior To Push | 188 | 2011-04-19 19:26:06 | <p>This question pertains not only to how to accomplish this task, but to whether doing so is good or bad practice with Git.</p>
<p>Consider that locally I do most work on the <code>main</code> branch, but I have created a topical branch I will call <code>feature_branch</code>. In the process of working on <code>featur... | 225,232 | 666,752 | 2025-01-15 05:36:28 | 5,721,879 | 181 | 2011-04-19 19:52:37 | 69,755 | 2024-01-15 04:48:14 | https://stackoverflow.com/q/5721566 | https://stackoverflow.com/a/5721879 | <p>For your first question, no, there's nothing wrong with pushing multiple commits at once. Many times, you may want to break your work down into a few small, logical commits, but only push them up once you feel like the whole series is ready. Or you might be making several commits locally while disconnected, and you ... | <p>For your first question, no, there's nothing wrong with pushing multiple commits at once. Many times, you may want to break your work down into a few small, logical commits, but only push them up once you feel like the whole series is ready. Or you might be making several commits locally while disconnected, and you ... | 119, 5597, 53850 | commit, git, git-commit | <h1>Combining Multiple Commits Into One Prior To Push</h1>
<p>This question pertains not only to how to accomplish this task, but to whether doing so is good or bad practice with Git.</p>
<p>Consider that locally I do most work on the <code>main</code> branch, but I have created a topical branch I will call <code>featu... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,201 | git | # Combining Multiple Commits Into One Prior To Push
This question pertains not only to how to accomplish this task, but to whether doing so is good or bad practice with Git.
Consider that locally I do most work on the `main` branch, but I have created a topical branch I will call `feature_branch`. In the process of w... | For your first question, no, there's nothing wrong with pushing multiple commits at once. Many times, you may want to break your work down into a few small, logical commits, but only push them up once you feel like the whole series is ready. Or you might be making several commits locally while disconnected, and you pus... |
9823692 | Resolving a 'both added' merge conflict in git? | 174 | 2012-03-22 13:54:47 | <p>I'm rebasing in git, and one conflict I get is 'both added' - that is, exactly the same filename has been added independently in my branch, and in the branch I'm rebasing on. <code>git status</code> tells me:</p>
<pre><code># Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
# (use &... | 112,379 | 178,757 | 2024-12-31 00:29:58 | 9,824,158 | 181 | 2012-03-22 14:19:53 | 19,563 | 2016-09-05 10:45:54 | https://stackoverflow.com/q/9823692 | https://stackoverflow.com/a/9824158 | <p>If you use <code>git rm</code> git will remove all versions of that path from the index so your resolve action will leave you without either version.</p>
<p>You can use <code>git checkout --ours src/MyFile.cs</code> to choose the version from the branch onto which you are rebasing or <code>git checkout --theirs src... | <p>If you use <code>git rm</code> git will remove all versions of that path from the index so your resolve action will leave you without either version.</p> <p>You can use <code>git checkout --ours src/MyFile.cs</code> to choose the version from the branch onto which you are rebasing or <code>git checkout --theirs src... | 119, 717, 8974 | git, merge, rebase | <h1>Resolving a 'both added' merge conflict in git?</h1>
<p>I'm rebasing in git, and one conflict I get is 'both added' - that is, exactly the same filename has been added independently in my branch, and in the branch I'm rebasing on. <code>git status</code> tells me:</p>
<pre><code># Unmerged paths:
# (use "gi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,202 | git | # Resolving a 'both added' merge conflict in git?
I'm rebasing in git, and one conflict I get is 'both added' - that is, exactly the same filename has been added independently in my branch, and in the branch I'm rebasing on. `git status` tells me:
```
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
... | If you use `git rm` git will remove all versions of that path from the index so your resolve action will leave you without either version.
You can use `git checkout --ours src/MyFile.cs` to choose the version from the branch onto which you are rebasing or `git checkout --theirs src/MyFile.cs` to choose the version fro... |
8476376 | Typical .gitignore file for an Android app | 119 | 2011-12-12 15:08:02 | <p>Just put an Android project under git (<em>beanstalk</em>) version control via the command line (<em>mac terminal</em>). Next step is to set up exclusions.</p>
<p>To those of you who have already been down this path:</p>
<p><strong>What should a typical .gitignore file look like for an android project?</strong></p... | 54,218 | 1,082,041 | 2019-01-09 20:05:31 | 8,476,621 | 181 | 2011-12-12 15:25:46 | 397,911 | 2011-12-12 15:25:46 | https://stackoverflow.com/q/8476376 | https://stackoverflow.com/a/8476621 | <p>You can mix <a href="https://github.com/github/gitignore/blob/master/Android.gitignore" rel="noreferrer">Android.gitignore</a>:</p>
<pre><code># built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
loca... | <p>You can mix <a href="https://github.com/github/gitignore/blob/master/Android.gitignore" rel="noreferrer">Android.gitignore</a>:</p> <pre><code># built application files *.apk *.ap_ # files for the dex VM *.dex # Java class files *.class # generated files bin/ gen/ # Local configuration file (sdk path, etc) loca... | 17, 53, 119, 1386, 25056 | android, eclipse, git, gitignore, java | <h1>Typical .gitignore file for an Android app</h1>
<p>Just put an Android project under git (<em>beanstalk</em>) version control via the command line (<em>mac terminal</em>). Next step is to set up exclusions.</p>
<p>To those of you who have already been down this path:</p>
<p><strong>What should a typical .gitignor... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,204 | git | # Typical .gitignore file for an Android app
Just put an Android project under git (*beanstalk*) version control via the command line (*mac terminal*). Next step is to set up exclusions.
To those of you who have already been down this path:
**What should a typical .gitignore file look like for an android project?**
... | You can mix [Android.gitignore](https://github.com/github/gitignore/blob/master/Android.gitignore):
```
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
```
with [Eclipse.gitignore]... |
1108853 | Recovering added/staged file after doing git reset --hard HEAD^? | 93 | 2009-07-10 10:39:42 | <p>I added a new file <code>F1</code> and made changes to another file F2 but then did a <code>git reset --hard HEAD^</code> and I have lost all the changes to the files.</p>
<p>Is there <em>some</em> way, I can get them back?</p>
<p>I did look at a related question here: <a href="https://stackoverflow.com/questions/54... | 74,745 | 49,847 | 2024-10-06 21:13:43 | 1,109,433 | 181 | 2009-07-10 13:10:34 | 46,058 | 2020-08-28 07:43:33 | https://stackoverflow.com/q/1108853 | https://stackoverflow.com/a/1109433 | <p>You can (with some work) recover state of file at the last "git add <em><file></em>". You can use</p>
<pre><code>$ git fsck --cache --no-reflogs --lost-found --dangling HEAD
</code></pre>
<p>and then examine files in '.git/lost-found/other' directory.</p>
<p>Please read <a href="http://www.kernel.org... | <p>You can (with some work) recover state of file at the last "git add <em><file></em>". You can use</p> <pre><code>$ git fsck --cache --no-reflogs --lost-found --dangling HEAD </code></pre> <p>and then examine files in '.git/lost-found/other' directory.</p> <p>Please read <a href="http://www.kernel.org... | 119, 456, 2200 | git, recovery, version-control | <h1>Recovering added/staged file after doing git reset --hard HEAD^?</h1>
<p>I added a new file <code>F1</code> and made changes to another file F2 but then did a <code>git reset --hard HEAD^</code> and I have lost all the changes to the files.</p>
<p>Is there <em>some</em> way, I can get them back?</p>
<p>I did look a... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,205 | git | # Recovering added/staged file after doing git reset --hard HEAD^?
I added a new file `F1` and made changes to another file F2 but then did a `git reset --hard HEAD^` and I have lost all the changes to the files.
Is there *some* way, I can get them back?
I did look at a related question here: [How can I undo git res... | You can (with some work) recover state of file at the last "git add *<file>*". You can use
```
$ git fsck --cache --no-reflogs --lost-found --dangling HEAD
```
and then examine files in '.git/lost-found/other' directory.
Please read [git fsck](http://www.kernel.org/pub/software/scm/git/docs/git-fsck.html) manpage. |
3491270 | git merge: apply changes to code that moved to a different file | 189 | 2010-08-16 07:19:27 | <p>I am attempting a pretty beefy git merge maneuver right now. One problem that I am coming across is that I made some changes to some code in my branch, but my colleague moved that code to a new file in his branch. So when I did <code>git merge my_branch his_branch</code>, git did not notice that the code in the ne... | 78,114 | 161,801 | 2024-12-03 10:43:13 | 15,137,607 | 180 | 2013-02-28 14:11:34 | 124,319 | 2021-06-07 14:44:30 | https://stackoverflow.com/q/3491270 | https://stackoverflow.com/a/15137607 | <p>I had a similar issue, and I resolved it by rebasing my work to match the target file organization. This works because git keep tracks of files <em>content</em>, so by rebasing on top of a rename, the changes are applied as necessary.</p>
<p>More precisely, let's say that you modified <code>original.txt</code> on yo... | <p>I had a similar issue, and I resolved it by rebasing my work to match the target file organization. This works because git keep tracks of files <em>content</em>, so by rebasing on top of a rename, the changes are applied as necessary.</p> <p>More precisely, let's say that you modified <code>original.txt</code> on yo... | 119, 28897 | git, git-merge | <h1>git merge: apply changes to code that moved to a different file</h1>
<p>I am attempting a pretty beefy git merge maneuver right now. One problem that I am coming across is that I made some changes to some code in my branch, but my colleague moved that code to a new file in his branch. So when I did <code>git merg... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,206 | git | # git merge: apply changes to code that moved to a different file
I am attempting a pretty beefy git merge maneuver right now. One problem that I am coming across is that I made some changes to some code in my branch, but my colleague moved that code to a new file in his branch. So when I did `git merge my_branch his_... | I had a similar issue, and I resolved it by rebasing my work to match the target file organization. This works because git keep tracks of files *content*, so by rebasing on top of a rename, the changes are applied as necessary.
More precisely, let's say that you modified `original.txt` on your branch (the `local` bran... |
42019529 | How to clone/pull a git repository, ignoring LFS? | 138 | 2017-02-03 08:07:25 | <p>Is there a way to explicitly ignore all git-lfs files on <code>clone</code> and <code>pull</code>?<br>(besides uninstalling <code>git-lfs</code> which I ended up doing).</p>
<hr>
<p>In this case git-lfs just contains pre-compiled libs for a platform I don't use... so there is absolutely no use in getting them.</p>... | 126,322 | 432,509 | 2024-07-17 15:07:17 | 42,021,818 | 180 | 2017-02-03 10:14:37 | 4,653,675 | 2021-02-15 21:44:30 | https://stackoverflow.com/q/42019529 | https://stackoverflow.com/a/42021818 | <p>Two alternatives:</p>
<p>(1) Using the GIT_LFS_SKIP_SMUDGE variable:</p>
<pre><code>GIT_LFS_SKIP_SMUDGE=1 git clone SERVER-REPOSITORY
</code></pre>
<p>Obs: for "Windows", use the following two commands:</p>
<pre><code>set GIT_LFS_SKIP_SMUDGE=1
git clone SERVER-REPOSITORY
</code></pre>
<p>(2) Configuring ... | <p>Two alternatives:</p> <p>(1) Using the GIT_LFS_SKIP_SMUDGE variable:</p> <pre><code>GIT_LFS_SKIP_SMUDGE=1 git clone SERVER-REPOSITORY </code></pre> <p>Obs: for "Windows", use the following two commands:</p> <pre><code>set GIT_LFS_SKIP_SMUDGE=1 git clone SERVER-REPOSITORY </code></pre> <p>(2) Configuring ... | 119, 115244 | git, git-lfs | <h1>How to clone/pull a git repository, ignoring LFS?</h1>
<p>Is there a way to explicitly ignore all git-lfs files on <code>clone</code> and <code>pull</code>?<br>(besides uninstalling <code>git-lfs</code> which I ended up doing).</p>
<hr>
<p>In this case git-lfs just contains pre-compiled libs for a platform I don'... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,207 | git | # How to clone/pull a git repository, ignoring LFS?
Is there a way to explicitly ignore all git-lfs files on `clone` and `pull`?
(besides uninstalling `git-lfs` which I ended up doing).
---
In this case git-lfs just contains pre-compiled libs for a platform I don't use... so there is absolutely no use in getting t... | Two alternatives:
(1) Using the GIT_LFS_SKIP_SMUDGE variable:
```
GIT_LFS_SKIP_SMUDGE=1 git clone SERVER-REPOSITORY
```
Obs: for "Windows", use the following two commands:
```
set GIT_LFS_SKIP_SMUDGE=1
git clone SERVER-REPOSITORY
```
(2) Configuring the git-lfs smudge:
```
git config --global filter.lfs.smudge ... |
15458237 | Git pretty format colors | 108 | 2013-03-17 06:41:00 | <p>I'm trying to set up pretty format colors for Git. From what I can tell version 1.6.0 only recognizes red, green and blue.</p>
<pre><code>$ git log --pretty=format:"%Credred%Creset %Cgreengreen%Creset %Cyellowyellow%Creset %Cblueblue%Creset %Cmagentamagenta%Creset %Ccyancyan%Creset %Cwhitewhite%Creset"
red green %... | 49,807 | 58,061 | 2024-07-02 19:24:02 | 15,458,378 | 180 | 2013-03-17 07:03:33 | 380,757 | 2023-10-02 13:53:13 | https://stackoverflow.com/q/15458237 | https://stackoverflow.com/a/15458378 | <p>I do not have an old version of <code>git</code> to verify that the colors other than <code>red</code>, <code>blue</code> and <code>green</code> are supported.</p>
<p>Although, one thing I noticed even with the recent versions of <code>git</code> (like 1.7.10 I used) is that colors other than <code>red</code>, <code... | <p>I do not have an old version of <code>git</code> to verify that the colors other than <code>red</code>, <code>blue</code> and <code>green</code> are supported.</p> <p>Although, one thing I noticed even with the recent versions of <code>git</code> (like 1.7.10 I used) is that colors other than <code>red</code>, <code... | 119 | git | <h1>Git pretty format colors</h1>
<p>I'm trying to set up pretty format colors for Git. From what I can tell version 1.6.0 only recognizes red, green and blue.</p>
<pre><code>$ git log --pretty=format:"%Credred%Creset %Cgreengreen%Creset %Cyellowyellow%Creset %Cblueblue%Creset %Cmagentamagenta%Creset %Ccyancyan%Crese... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,210 | git | # Git pretty format colors
I'm trying to set up pretty format colors for Git. From what I can tell version 1.6.0 only recognizes red, green and blue.
```
$ git log --pretty=format:"%Credred%Creset %Cgreengreen%Creset %Cyellowyellow%Creset %Cblueblue%Creset %Cmagentamagenta%Creset %Ccyancyan%Creset %Cwhitewhite%Creset... | I do not have an old version of `git` to verify that the colors other than `red`, `blue` and `green` are supported.
Although, one thing I noticed even with the recent versions of `git` (like 1.7.10 I used) is that colors other than `red`, `green` and `blue` need to be within parentheses `()`. For `red`, `green` and `b... |
9804211 | Can not push changes after using git reset --hard | 106 | 2012-03-21 11:59:48 | <p>I had a mistake and commit some changes to git which I should not have committed.
After I made the commit, I pushed my changes.
I then used the following commands to try and reset my changes.</p>
<pre><code> git reset --hard head
</code></pre>
<p>Now I want to push this 'reset' to the remote repository with this ... | 137,066 | 654,019 | 2022-07-08 07:45:09 | 9,804,398 | 180 | 2012-03-21 12:13:39 | 6,309 | 2022-07-08 07:45:09 | https://stackoverflow.com/q/9804211 | https://stackoverflow.com/a/9804398 | <pre><code>git push -f origin myBranch
</code></pre>
<p>should work (provided you are aware this can be dangerous if MyBranch was already fetched by others in their own repo)</p>
<p>Since 2012, you also have:</p>
<ul>
<li><a href="https://stackoverflow.com/a/52937476/6309"><code>git push --force-with-lease</code></a> ... | <pre><code>git push -f origin myBranch </code></pre> <p>should work (provided you are aware this can be dangerous if MyBranch was already fetched by others in their own repo)</p> <p>Since 2012, you also have:</p> <ul> <li><a href="https://stackoverflow.com/a/52937476/6309"><code>git push --force-with-lease</code></a> ... | 119, 34403 | git, git-revert | <h1>Can not push changes after using git reset --hard</h1>
<p>I had a mistake and commit some changes to git which I should not have committed.
After I made the commit, I pushed my changes.
I then used the following commands to try and reset my changes.</p>
<pre><code> git reset --hard head
</code></pre>
<p>Now I wa... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,211 | git | # Can not push changes after using git reset --hard
I had a mistake and commit some changes to git which I should not have committed.
After I made the commit, I pushed my changes.
I then used the following commands to try and reset my changes.
```
git reset --hard head
```
Now I want to push this 'reset' to the rem... | ```
git push -f origin myBranch
```
should work (provided you are aware this can be dangerous if MyBranch was already fetched by others in their own repo)
Since 2012, you also have:
- [`git push --force-with-lease`](https://stackoverflow.com/a/52937476/6309) (Git 1.8.5+ Q3 2013) which is safer, and
- [`git push --fo... |
540535 | Managing large binary files with Git | 556 | 2009-02-12 08:52:52 | <p>I am looking for opinions of how to handle large binary files on which my source code (web application) is dependent. We are currently discussing several alternatives:</p>
<ol>
<li>Copy the binary files by hand.
<ul>
<li>Pro: Not sure.</li>
<li>Contra: I am strongly against this, as it increases the likelihood of ... | 215,649 | 15,274 | 2022-06-10 04:14:12 | 541,490 | 179 | 2009-02-12 14:29:01 | 825 | 2014-01-09 10:13:09 | https://stackoverflow.com/q/540535 | https://stackoverflow.com/a/541490 | <p>If the program won't work without the files it seems like splitting them into a separate repo is a bad idea. We have large test suites that we break into a separate repo but those are truly "auxiliary" files.</p>
<p>However, you may be able to manage the files in a separate repo and then use <a href="http://git-sc... | <p>If the program won't work without the files it seems like splitting them into a separate repo is a bad idea. We have large test suites that we break into a separate repo but those are truly "auxiliary" files.</p> <p>However, you may be able to manage the files in a separate repo and then use <a href="http://git-sc... | 119, 456, 5004, 25181 | binaryfiles, git, large-files, version-control | <h1>Managing large binary files with Git</h1>
<p>I am looking for opinions of how to handle large binary files on which my source code (web application) is dependent. We are currently discussing several alternatives:</p>
<ol>
<li>Copy the binary files by hand.
<ul>
<li>Pro: Not sure.</li>
<li>Contra: I am strongly ag... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,212 | git | # Managing large binary files with Git
I am looking for opinions of how to handle large binary files on which my source code (web application) is dependent. We are currently discussing several alternatives:
1. Copy the binary files by hand.
- Pro: Not sure.
- Contra: I am strongly against this, as it increases ... | If the program won't work without the files it seems like splitting them into a separate repo is a bad idea. We have large test suites that we break into a separate repo but those are truly "auxiliary" files.
However, you may be able to manage the files in a separate repo and then use [`git-submodule`](http://git-scm.... |
7744049 | Git: How to rebase to a specific commit? | 308 | 2011-10-12 17:27:20 | <p>I'd like to rebase to a specific commit, not to a HEAD of the other branch:</p>
<pre><code>A --- B --- C master
\
\-- D topic
</code></pre>
<p>to</p>
<pre><code>A --- B --- C master
\
\-- D topic
</code></pre>
<p>instead of </p>
<pre><code>A --- B --- ... | 555,233 | 145,989 | 2025-07-02 09:28:08 | 7,744,237 | 179 | 2011-10-12 17:44:26 | 1,864,976 | 2020-01-19 06:17:07 | https://stackoverflow.com/q/7744049 | https://stackoverflow.com/a/7744237 | <p>You can avoid using the --onto parameter by making a temp branch on the commit you like and then use rebase in its simple form:</p>
<pre><code>git branch temp master^
git checkout topic
git rebase temp
git branch -d temp
</code></pre>
| <p>You can avoid using the --onto parameter by making a temp branch on the commit you like and then use rebase in its simple form:</p> <pre><code>git branch temp master^ git checkout topic git rebase temp git branch -d temp </code></pre> | 119, 456, 8974, 29934 | git, git-rebase, rebase, version-control | <h1>Git: How to rebase to a specific commit?</h1>
<p>I'd like to rebase to a specific commit, not to a HEAD of the other branch:</p>
<pre><code>A --- B --- C master
\
\-- D topic
</code></pre>
<p>to</p>
<pre><code>A --- B --- C master
\
\-- D topic
</code><... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,213 | git | # Git: How to rebase to a specific commit?
I'd like to rebase to a specific commit, not to a HEAD of the other branch:
```
A --- B --- C master
\
\-- D topic
```
to
```
A --- B --- C master
\
\-- D topic
```
instead of
```
A --- B --- C master
... | You can avoid using the --onto parameter by making a temp branch on the commit you like and then use rebase in its simple form:
```
git branch temp master^
git checkout topic
git rebase temp
git branch -d temp
``` |
35575400 | What is the advantage of git lfs? | 103 | 2016-02-23 10:48:00 | <p>Github has a <a href="https://help.github.com/articles/conditions-for-large-files/">limit</a> on push large file. So if you want to push a large file to your repo, you have to use <a href="https://git-lfs.github.com/">Git LFS</a>. </p>
<p>I know it's a bad idea to add binary file in git repo. But if I am using <a h... | 35,552 | 2,002,510 | 2020-08-10 01:31:28 | 35,578,715 | 179 | 2016-02-23 13:21:28 | 4,830,165 | 2020-08-10 01:31:28 | https://stackoverflow.com/q/35575400 | https://stackoverflow.com/a/35578715 | <p>One specificity of Git (and other distributed systems) compared to centralized systems is that each repository contains the whole history of the project. Suppose you create a 100 MB file, modify it 100 times in a way that doesn't compress well. You'll end up with a 10 GB repository. This means that each clone will d... | <p>One specificity of Git (and other distributed systems) compared to centralized systems is that each repository contains the whole history of the project. Suppose you create a 100 MB file, modify it 100 times in a way that doesn't compress well. You'll end up with a 10 GB repository. This means that each clone will d... | 119, 115244 | git, git-lfs | <h1>What is the advantage of git lfs?</h1>
<p>Github has a <a href="https://help.github.com/articles/conditions-for-large-files/">limit</a> on push large file. So if you want to push a large file to your repo, you have to use <a href="https://git-lfs.github.com/">Git LFS</a>. </p>
<p>I know it's a bad idea to add bina... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,214 | git | # What is the advantage of git lfs?
Github has a [limit](https://help.github.com/articles/conditions-for-large-files/) on push large file. So if you want to push a large file to your repo, you have to use [Git LFS](https://git-lfs.github.com/).
I know it's a bad idea to add binary file in git repo. But if I am using ... | One specificity of Git (and other distributed systems) compared to centralized systems is that each repository contains the whole history of the project. Suppose you create a 100 MB file, modify it 100 times in a way that doesn't compress well. You'll end up with a 10 GB repository. This means that each clone will down... |
22724921 | Do I need to do 'git init' before doing 'git clone' on a project | 88 | 2014-03-28 23:28:01 | <p>I'm doing a <code>git clone</code> on a project following the instructions. But, do I need to do an <code>init</code> in the directory beforehand?</p>
| 68,082 | 697,795 | 2024-05-20 19:57:18 | 22,724,997 | 179 | 2014-03-28 23:35:35 | 1,870,481 | 2014-03-28 23:35:35 | https://stackoverflow.com/q/22724921 | https://stackoverflow.com/a/22724997 | <p><code>git clone</code> is basically a combination of:</p>
<ul>
<li><code>git init</code> (create the local repository)</li>
<li><code>git remote add</code> (add the URL to that repository)</li>
<li><code>git fetch</code> (fetch all branches from that URL to your local repository)</li>
<li><code>git checkout</code> ... | <p><code>git clone</code> is basically a combination of:</p> <ul> <li><code>git init</code> (create the local repository)</li> <li><code>git remote add</code> (add the URL to that repository)</li> <li><code>git fetch</code> (fetch all branches from that URL to your local repository)</li> <li><code>git checkout</code> ... | 119 | git | <h1>Do I need to do 'git init' before doing 'git clone' on a project</h1>
<p>I'm doing a <code>git clone</code> on a project following the instructions. But, do I need to do an <code>init</code> in the directory beforehand?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,215 | git | # Do I need to do 'git init' before doing 'git clone' on a project
I'm doing a `git clone` on a project following the instructions. But, do I need to do an `init` in the directory beforehand? | `git clone` is basically a combination of:
- `git init` (create the local repository)
- `git remote add` (add the URL to that repository)
- `git fetch` (fetch all branches from that URL to your local repository)
- `git checkout` (create all the files of the main branch in your working tree)
Therefore, no, you don't h... |
58031165 | How to get rid of "would clobber existing tag" | 664 | 2019-09-20 15:20:32 | <p>I'm using git in VSCodium and each time I try to pull git is complaining.</p>
<p>Looking into the log I see</p>
<pre><code>> git pull --tags origin master
From https://github.com/MY/REPO
* branch master -> FETCH_HEAD
! [rejected] latest -> latest (would clobber existing tag)
... | 302,092 | 6,237,339 | 2025-02-24 09:20:08 | 58,031,333 | 177 | 2019-09-20 15:31:31 | 3,980,115 | 2021-10-25 11:35:19 | https://stackoverflow.com/q/58031165 | https://stackoverflow.com/a/58031333 | <p>Since you say it's unclear what's going wrong, I assume you're not using that tag for anything and you just want to do your own work.</p>
<p>Turn off this setting:</p>
<p><a href="https://i.sstatic.net/taEKs.png" rel="noreferrer"><img src="https://i.sstatic.net/taEKs.png" alt="enter image description here" /></a></p... | <p>Since you say it's unclear what's going wrong, I assume you're not using that tag for anything and you just want to do your own work.</p> <p>Turn off this setting:</p> <p><a href="https://i.sstatic.net/taEKs.png" rel="noreferrer"><img src="https://i.sstatic.net/taEKs.png" alt="enter image description here" /></a></p... | 119 | git | <h1>How to get rid of "would clobber existing tag"</h1>
<p>I'm using git in VSCodium and each time I try to pull git is complaining.</p>
<p>Looking into the log I see</p>
<pre><code>> git pull --tags origin master
From https://github.com/MY/REPO
* branch master -> FETCH_HEAD
! [rejected] ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,216 | git | # How to get rid of "would clobber existing tag"
I'm using git in VSCodium and each time I try to pull git is complaining.
Looking into the log I see
```
> git pull --tags origin master
From https://github.com/MY/REPO
* branch master -> FETCH_HEAD
! [rejected] latest -> latest (would clo... | Since you say it's unclear what's going wrong, I assume you're not using that tag for anything and you just want to do your own work.
Turn off this setting:
[](https://i.sstatic.net/taEKs.png)
*Or add this `"git.pullTags": false` in the settings.json fi... |
19097259 | How to move a git repository into another directory and make that directory a git repository? | 190 | 2013-09-30 14:49:23 | <p>I have a directory <strong>gitrepo1</strong>. This directory is a git repository.</p>
<ul>
<li><p>I would like to move this <strong>gitrepo1</strong> into another directory <strong>newrepo</strong>.</p></li>
<li><p>Directory <strong>newrepo</strong> should be the new git repository with no loss of git history and s... | 324,926 | 1,819,254 | 2023-08-11 18:34:28 | 19,097,284 | 177 | 2013-09-30 14:50:37 | 912,144 | 2015-11-03 22:11:36 | https://stackoverflow.com/q/19097259 | https://stackoverflow.com/a/19097284 | <p>It's very simple. Git doesn't care about what's the name of its directory. It only cares what's inside. So you can simply do:</p>
<pre><code># copy the directory into newrepo dir that exists already (else create it)
$ cp -r gitrepo1 newrepo
# remove .git from old repo to delete all history and anything git from it... | <p>It's very simple. Git doesn't care about what's the name of its directory. It only cares what's inside. So you can simply do:</p> <pre><code># copy the directory into newrepo dir that exists already (else create it) $ cp -r gitrepo1 newrepo # remove .git from old repo to delete all history and anything git from it... | 119 | git | <h1>How to move a git repository into another directory and make that directory a git repository?</h1>
<p>I have a directory <strong>gitrepo1</strong>. This directory is a git repository.</p>
<ul>
<li><p>I would like to move this <strong>gitrepo1</strong> into another directory <strong>newrepo</strong>.</p></li>
<li><... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,217 | git | # How to move a git repository into another directory and make that directory a git repository?
I have a directory **gitrepo1**. This directory is a git repository.
- I would like to move this **gitrepo1** into another directory **newrepo**.
- Directory **newrepo** should be the new git repository with no loss of git... | It's very simple. Git doesn't care about what's the name of its directory. It only cares what's inside. So you can simply do:
```
# copy the directory into newrepo dir that exists already (else create it)
$ cp -r gitrepo1 newrepo
# remove .git from old repo to delete all history and anything git from it
$ rm -rf gitr... |
543346 | List all the files that ever existed in a Git repository | 144 | 2009-02-12 21:23:43 | <p>Do you have a clean way to list all the files that ever existed in specified branch?</p>
| 31,867 | 1,277,510 | 2024-05-03 22:54:30 | 543,426 | 177 | 2009-02-12 21:39:18 | 39,975 | 2024-05-03 22:54:30 | https://stackoverflow.com/q/543346 | https://stackoverflow.com/a/543426 | <p>This is a simplified variation of Strager's <a href="https://stackoverflow.com/a/543383/313192">solution</a>:</p>
<pre><code>git log --pretty=format: --name-status | cut -f2- | sort -u
</code></pre>
<p><strong>Edit:</strong> Thanks to <a href="https://stackoverflow.com/questions/543346/list-all-the-files-that-ever-e... | <p>This is a simplified variation of Strager's <a href="https://stackoverflow.com/a/543383/313192">solution</a>:</p> <pre><code>git log --pretty=format: --name-status | cut -f2- | sort -u </code></pre> <p><strong>Edit:</strong> Thanks to <a href="https://stackoverflow.com/questions/543346/list-all-the-files-that-ever-e... | 119 | git | <h1>List all the files that ever existed in a Git repository</h1>
<p>Do you have a clean way to list all the files that ever existed in specified branch?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,219 | git | # List all the files that ever existed in a Git repository
Do you have a clean way to list all the files that ever existed in specified branch? | This is a simplified variation of Strager's [solution](https://stackoverflow.com/a/543383/313192):
```
git log --pretty=format: --name-status | cut -f2- | sort -u
```
**Edit:** Thanks to [Jakub](https://stackoverflow.com/questions/543346/list-all-the-files-that-ever-existed-in-a-git-repository#comment357659_543426) f... |
190431 | Is git-svn dcommit after merging in git dangerous? | 135 | 2008-10-10 07:38:52 | <p>My motivation for trying out git-svn is the effortless merging and branching. Then I noticed that man git-svn(1) says: </p>
<blockquote>
<p>Running git-merge or git-pull is NOT recommended on a branch you plan
to dcommit from. Subversion does not represent merges in any
reasonable or useful fashion; so users ... | 37,332 | 5,179 | 2016-05-04 23:07:31 | 4,238,528 | 177 | 2010-11-21 15:05:31 | 492,649 | 2011-01-31 12:35:37 | https://stackoverflow.com/q/190431 | https://stackoverflow.com/a/4238528 | <p>Actually, I found an even better way with the <code>--no-ff</code> option on git merge.
All this squash technic I used before is no longer required. </p>
<p>My new workflow is now as follows: </p>
<ul>
<li><p>I have a "master" branch that is the only branch that I dcommit from and that clone the SVN repository (<c... | <p>Actually, I found an even better way with the <code>--no-ff</code> option on git merge. All this squash technic I used before is no longer required. </p> <p>My new workflow is now as follows: </p> <ul> <li><p>I have a "master" branch that is the only branch that I dcommit from and that clone the SVN repository (<c... | 63, 119, 717, 1879, 6452 | branch, git, git-svn, merge, svn | <h1>Is git-svn dcommit after merging in git dangerous?</h1>
<p>My motivation for trying out git-svn is the effortless merging and branching. Then I noticed that man git-svn(1) says: </p>
<blockquote>
<p>Running git-merge or git-pull is NOT recommended on a branch you plan
to dcommit from. Subversion does not repre... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,220 | git | # Is git-svn dcommit after merging in git dangerous?
My motivation for trying out git-svn is the effortless merging and branching. Then I noticed that man git-svn(1) says:
> Running git-merge or git-pull is NOT recommended on a branch you plan
> to dcommit from. Subversion does not represent merges in any
> reasonabl... | Actually, I found an even better way with the `--no-ff` option on git merge.
All this squash technic I used before is no longer required.
My new workflow is now as follows:
- I have a "master" branch that is the only branch that I dcommit from and that clone the SVN repository (`-s` assume you have a standard SVN lay... |
4750148 | git: Show index diff in commit message as comment | 134 | 2011-01-20 17:00:43 | <p>When <code>git commit</code> open the message editor is shows a brief status, something like this:</p>
<pre><code># Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Your branch is ahead of 'origin/master' by 26 ... | 20,303 | 11,208 | 2017-09-11 16:56:41 | 4,750,245 | 177 | 2011-01-20 17:09:23 | 66,353 | 2016-09-14 09:15:56 | https://stackoverflow.com/q/4750148 | https://stackoverflow.com/a/4750245 | <p>The <code>--verbose</code> (or <code>-v</code>) flag for <a href="http://www.kernel.org/pub/software/scm/git/docs/git-commit.html" rel="noreferrer"><code>git commit</code></a> will display the diff of what would be committed:</p>
<p><code>git commit --verbose</code></p>
| <p>The <code>--verbose</code> (or <code>-v</code>) flag for <a href="http://www.kernel.org/pub/software/scm/git/docs/git-commit.html" rel="noreferrer"><code>git commit</code></a> will display the diff of what would be committed:</p> <p><code>git commit --verbose</code></p> | 119 | git | <h1>git: Show index diff in commit message as comment</h1>
<p>When <code>git commit</code> open the message editor is shows a brief status, something like this:</p>
<pre><code># Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On bra... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,221 | git | # git: Show index diff in commit message as comment
When `git commit` open the message editor is shows a brief status, something like this:
```
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Your branch is ahe... | The `--verbose` (or `-v`) flag for [`git commit`](http://www.kernel.org/pub/software/scm/git/docs/git-commit.html) will display the diff of what would be committed:
`git commit --verbose` |
29270058 | How to fetch all git history after I clone the repo with `--depth 1`? | 117 | 2015-03-26 02:26:26 | <p>There is a big repo with thousands of commits. When I clone it, I just want to see the latest code, and don't wait for too long, so I run:</p>
<pre><code>git clone git://..../... --depth 1
</code></pre>
<p>But later, I want to see all the history commits, but I don't know how to fetch all the histories.</p>
| 44,758 | 342,235 | 2024-05-15 21:29:12 | 29,270,131 | 177 | 2015-03-26 02:35:10 | 781,754 | 2015-03-26 02:35:10 | https://stackoverflow.com/q/29270058 | https://stackoverflow.com/a/29270131 | <p>Use <code>git pull --unshallow</code> and it will download the entire commit history.</p>
| <p>Use <code>git pull --unshallow</code> and it will download the entire commit history.</p> | 119 | git | <h1>How to fetch all git history after I clone the repo with `--depth 1`?</h1>
<p>There is a big repo with thousands of commits. When I clone it, I just want to see the latest code, and don't wait for too long, so I run:</p>
<pre><code>git clone git://..../... --depth 1
</code></pre>
<p>But later, I want to see all t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,223 | git | # How to fetch all git history after I clone the repo with `--depth 1`?
There is a big repo with thousands of commits. When I clone it, I just want to see the latest code, and don't wait for too long, so I run:
```
git clone git://..../... --depth 1
```
But later, I want to see all the history commits, but I don't k... | Use `git pull --unshallow` and it will download the entire commit history. |
21523481 | Symfony2 - creating own vendor bundle - project and git strategy | 80 | 2014-02-03 09:19:54 | <p>We're considering creating our own <code>common</code> bundle for entity mapping and services for use within few separate apps. A bundle should be easy to modify, run, include and test. I know about <a href="http://symfony.com/doc/current/cookbook/bundles/best_practices.html" rel="noreferrer">Best Practices for Stru... | 34,631 | 1,407,357 | 2018-08-16 08:22:32 | 21,526,873 | 177 | 2014-02-03 12:00:15 | 2,575,993 | 2016-11-06 02:45:48 | https://stackoverflow.com/q/21523481 | https://stackoverflow.com/a/21526873 | <h1>Create a new empty symfony project</h1>
<pre><code>php composer.phar create-project symfony/framework-standard-edition demo/ 2.4.1
cd demo
</code></pre>
<h1>Generate a new bundle</h1>
<p>(for example <code>src/Company/DemoBundle</code>)</p>
<pre><code>php app/console generate:bundle
cd src/Company/DemoBundle/
<... | <h1>Create a new empty symfony project</h1> <pre><code>php composer.phar create-project symfony/framework-standard-edition demo/ 2.4.1 cd demo </code></pre> <h1>Generate a new bundle</h1> <p>(for example <code>src/Company/DemoBundle</code>)</p> <pre><code>php app/console generate:bundle cd src/Company/DemoBundle/ <... | 5, 119, 2669, 57799 | bundle, git, php, symfony | <h1>Symfony2 - creating own vendor bundle - project and git strategy</h1>
<p>We're considering creating our own <code>common</code> bundle for entity mapping and services for use within few separate apps. A bundle should be easy to modify, run, include and test. I know about <a href="http://symfony.com/doc/current/cook... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,225 | git | # Symfony2 - creating own vendor bundle - project and git strategy
We're considering creating our own `common` bundle for entity mapping and services for use within few separate apps. A bundle should be easy to modify, run, include and test. I know about [Best Practices for Structuring Bundles](http://symfony.com/doc/... | # Create a new empty symfony project
```
php composer.phar create-project symfony/framework-standard-edition demo/ 2.4.1
cd demo
```
# Generate a new bundle
(for example `src/Company/DemoBundle`)
```
php app/console generate:bundle
cd src/Company/DemoBundle/
```
# Init your github repository in `src/Company/DemoBu... |
29929534 | Docker error: Unable to locate package git | 72 | 2015-04-28 20:43:34 | <p>I'm using an image <code>nginx</code> which is based on <code>dockerfile/ubuntu</code>. On attaching to the docker container's shell</p>
<pre><code>docker exec -it <container_id> /bin/bash
</code></pre>
<p>I want to do a <code>git pull</code> so I tried installing <code>git</code> but <code>apt</code> is una... | 91,946 | 741,099 | 2019-09-23 14:38:03 | 29,929,714 | 177 | 2015-04-28 20:53:30 | 1,524,766 | 2015-09-28 17:16:40 | https://stackoverflow.com/q/29929534 | https://stackoverflow.com/a/29929714 | <p>This is happening because the apt repository is not yet updated, it is common practice to clean your apt repositories and tmp files after creating an image, which your base image is probably doing.</p>
<p>To fix this, you are going to want to run <code>apt-get update</code> prior to installing git, it is good pract... | <p>This is happening because the apt repository is not yet updated, it is common practice to clean your apt repositories and tmp files after creating an image, which your base image is probably doing.</p> <p>To fix this, you are going to want to run <code>apt-get update</code> prior to installing git, it is good pract... | 119, 549, 2080, 90304 | apt, docker, git, ubuntu | <h1>Docker error: Unable to locate package git</h1>
<p>I'm using an image <code>nginx</code> which is based on <code>dockerfile/ubuntu</code>. On attaching to the docker container's shell</p>
<pre><code>docker exec -it <container_id> /bin/bash
</code></pre>
<p>I want to do a <code>git pull</code> so I tried ins... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,226 | git | # Docker error: Unable to locate package git
I'm using an image `nginx` which is based on `dockerfile/ubuntu`. On attaching to the docker container's shell
```
docker exec -it <container_id> /bin/bash
```
I want to do a `git pull` so I tried installing `git` but `apt` is unable to find the package:
```
root@a71e45d... | This is happening because the apt repository is not yet updated, it is common practice to clean your apt repositories and tmp files after creating an image, which your base image is probably doing.
To fix this, you are going to want to run `apt-get update` prior to installing git, it is good practice to combine the up... |
51275777 | Why does git stash pop say that it could not restore untracked files from stash entry? | 219 | 2018-07-11 00:54:16 | <p>I had a bunch of staged and unstaged changes and I wanted to quickly switch to another branch and then switch back.</p>
<p>So I staged my changes using:</p>
<pre><code>$ git stash push -a
</code></pre>
<p>(In hindsight I probably could have used <code>--include-untracked</code> instead of <code>--all</code>)</p>
... | 121,959 | 367,796 | 2024-03-29 10:54:09 | 51,276,389 | 176 | 2018-07-11 02:29:25 | 1,256,452 | 2018-07-13 13:51:56 | https://stackoverflow.com/q/51275777 | https://stackoverflow.com/a/51276389 | <p>As a bit of additional explanation, note that <code>git stash</code> makes either two commits, or three commits. The default is two; you get three if you use any spelling of the <code>--all</code> or <code>--include-untracked</code> options.</p>
<p>These two, or three, commits are special in one important way: the... | <p>As a bit of additional explanation, note that <code>git stash</code> makes either two commits, or three commits. The default is two; you get three if you use any spelling of the <code>--all</code> or <code>--include-untracked</code> options.</p> <p>These two, or three, commits are special in one important way: the... | 119, 13091 | git, git-stash | <h1>Why does git stash pop say that it could not restore untracked files from stash entry?</h1>
<p>I had a bunch of staged and unstaged changes and I wanted to quickly switch to another branch and then switch back.</p>
<p>So I staged my changes using:</p>
<pre><code>$ git stash push -a
</code></pre>
<p>(In hindsight... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,227 | git | # Why does git stash pop say that it could not restore untracked files from stash entry?
I had a bunch of staged and unstaged changes and I wanted to quickly switch to another branch and then switch back.
So I staged my changes using:
```
$ git stash push -a
```
(In hindsight I probably could have used `--include-u... | As a bit of additional explanation, note that `git stash` makes either two commits, or three commits. The default is two; you get three if you use any spelling of the `--all` or `--include-untracked` options.
These two, or three, commits are special in one important way: they are on *no* branch. Git locates them throu... |
1822849 | What are these ^M's that keep showing up in my files in emacs? | 210 | 2009-11-30 22:26:30 | <p>I think it may have to do with TextMate, but we work in a small team and are having some issues with full-file conflicts of nearly identical files in git – in one branch the files have a ^M appended to each line.</p>
<p>What is this mysterious <code>^M</code> character supposed to do, and where could it be coming fr... | 149,305 | 118,910 | 2022-10-12 17:41:28 | 1,822,882 | 176 | 2009-11-30 22:32:08 | 19,750 | 2018-10-30 13:33:42 | https://stackoverflow.com/q/1822849 | https://stackoverflow.com/a/1822882 | <p>In <a href="http://git-scm.com/docs/git-config" rel="noreferrer">git-config</a>, set <code>core.autocrlf</code> to <code>true</code> to make git automatically convert line endings correctly for your platform, e.g. run this command for a global setting:</p>
<pre><code>git config --global core.autocrlf true
</code></... | <p>In <a href="http://git-scm.com/docs/git-config" rel="noreferrer">git-config</a>, set <code>core.autocrlf</code> to <code>true</code> to make git automatically convert line endings correctly for your platform, e.g. run this command for a global setting:</p> <pre><code>git config --global core.autocrlf true </code></... | 119, 371, 3705, 8329, 14899 | carriage-return, emacs, git, line-endings, newline | <h1>What are these ^M's that keep showing up in my files in emacs?</h1>
<p>I think it may have to do with TextMate, but we work in a small team and are having some issues with full-file conflicts of nearly identical files in git – in one branch the files have a ^M appended to each line.</p>
<p>What is this mysterious <... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,228 | git | # What are these ^M's that keep showing up in my files in emacs?
I think it may have to do with TextMate, but we work in a small team and are having some issues with full-file conflicts of nearly identical files in git – in one branch the files have a ^M appended to each line.
What is this mysterious `^M` character s... | In [git-config](http://git-scm.com/docs/git-config), set `core.autocrlf` to `true` to make git automatically convert line endings correctly for your platform, e.g. run this command for a global setting:
```
git config --global core.autocrlf true
``` |
4722423 | How to merge two branches with different directory hierarchies in git? | 82 | 2011-01-18 09:25:33 | <p>I started using Maven with a web application project so the directory hierarchy changed. I created a new branch for the Maven integration. Now I have two branches one with the old directory hierarchy and one with the maven directory hierarchy. Both branches have new commits (bugfixes and new features).</p>
<p>I woul... | 43,613 | 556,938 | 2022-09-27 19:44:09 | 4,722,641 | 176 | 2011-01-18 09:53:40 | 478,206 | 2011-01-18 09:53:40 | https://stackoverflow.com/q/4722423 | https://stackoverflow.com/a/4722641 | <p>Try setting <code>merge.renameLimit</code> to something high for this merge. git tries to detect renames, but only if the number of files is below this limit, since it requires O(n^2) processing time:</p>
<pre><code>git config merge.renameLimit 999999
</code></pre>
<p>then when done:</p>
<pre><code>git config --u... | <p>Try setting <code>merge.renameLimit</code> to something high for this merge. git tries to detect renames, but only if the number of files is below this limit, since it requires O(n^2) processing time:</p> <pre><code>git config merge.renameLimit 999999 </code></pre> <p>then when done:</p> <pre><code>git config --u... | 119, 717, 28897 | git, git-merge, merge | <h1>How to merge two branches with different directory hierarchies in git?</h1>
<p>I started using Maven with a web application project so the directory hierarchy changed. I created a new branch for the Maven integration. Now I have two branches one with the old directory hierarchy and one with the maven directory hier... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,234 | git | # How to merge two branches with different directory hierarchies in git?
I started using Maven with a web application project so the directory hierarchy changed. I created a new branch for the Maven integration. Now I have two branches one with the old directory hierarchy and one with the maven directory hierarchy. Bo... | Try setting `merge.renameLimit` to something high for this merge. git tries to detect renames, but only if the number of files is below this limit, since it requires O(n^2) processing time:
```
git config merge.renameLimit 999999
```
then when done:
```
git config --unset merge.renameLimit
``` |
5358336 | How to list all tags along with the full message in git? | 519 | 2011-03-18 22:11:03 | <p>I want git to list all tags along with the full annotation or commit message. Something like this is close:</p>
<pre><code>git tag -n5
</code></pre>
<p>This does exactly what I want except that it will only show up to the first 5 lines of the tag message.</p>
<p>I guess I can just use a very large number. What is... | 238,150 | 172,274 | 2024-05-02 20:58:39 | 26,366,791 | 175 | 2014-10-14 17:33:14 | 172,274 | 2020-02-27 04:05:22 | https://stackoverflow.com/q/5358336 | https://stackoverflow.com/a/26366791 | <pre><code>git tag -n99
</code></pre>
<p>Short and sweet. This will list up to 99 lines from each tag annotation/commit message. <a href="https://git-scm.com/docs/git-tag" rel="noreferrer">Here is a link to the official documentation for git tag</a>.</p>
<p>I now think the limitation of only showing up to 99 lines pe... | <pre><code>git tag -n99 </code></pre> <p>Short and sweet. This will list up to 99 lines from each tag annotation/commit message. <a href="https://git-scm.com/docs/git-tag" rel="noreferrer">Here is a link to the official documentation for git tag</a>.</p> <p>I now think the limitation of only showing up to 99 lines pe... | 115, 119, 60718 | git, git-tag, tags | <h1>How to list all tags along with the full message in git?</h1>
<p>I want git to list all tags along with the full annotation or commit message. Something like this is close:</p>
<pre><code>git tag -n5
</code></pre>
<p>This does exactly what I want except that it will only show up to the first 5 lines of the tag me... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,235 | git | # How to list all tags along with the full message in git?
I want git to list all tags along with the full annotation or commit message. Something like this is close:
```
git tag -n5
```
This does exactly what I want except that it will only show up to the first 5 lines of the tag message.
I guess I can just use a ... | ```
git tag -n99
```
Short and sweet. This will list up to 99 lines from each tag annotation/commit message. [Here is a link to the official documentation for git tag](https://git-scm.com/docs/git-tag).
I now think the limitation of only showing up to 99 lines per tag is actually a good thing as most of the time, if ... |
225291 | git-upload-pack: command not found, when cloning remote Git repo | 176 | 2008-10-22 11:14:13 | <p>I have been using git to keep two copies of my project in sync, one is my local box, the other the test server.
This is an issue which occurs when I log onto our remote development server using ssh;</p>
<pre><code>git clone me@me.mydevbox.com:/home/chris/myproject
Initialized empty Git repository in /tmp/myproject/... | 145,541 | 24,508 | 2023-08-15 06:51:10 | 225,315 | 175 | 2008-10-22 11:20:42 | 17,221 | 2012-07-26 01:04:50 | https://stackoverflow.com/q/225291 | https://stackoverflow.com/a/225315 | <p>Make sure <code>git-upload-pack</code> is on the path from a non-login shell. (On my machine it's in <code>/usr/bin</code>).</p>
<p>To see what your path looks like on the remote machine from a non-login shell, try this:</p>
<pre><code>ssh you@remotemachine echo \$PATH
</code></pre>
<p>(That works in Bash, Zsh, a... | <p>Make sure <code>git-upload-pack</code> is on the path from a non-login shell. (On my machine it's in <code>/usr/bin</code>).</p> <p>To see what your path looks like on the remote machine from a non-login shell, try this:</p> <pre><code>ssh you@remotemachine echo \$PATH </code></pre> <p>(That works in Bash, Zsh, a... | 34, 119, 386, 456 | git, ssh, unix, version-control | <h1>git-upload-pack: command not found, when cloning remote Git repo</h1>
<p>I have been using git to keep two copies of my project in sync, one is my local box, the other the test server.
This is an issue which occurs when I log onto our remote development server using ssh;</p>
<pre><code>git clone me@me.mydevbox.com... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,236 | git | # git-upload-pack: command not found, when cloning remote Git repo
I have been using git to keep two copies of my project in sync, one is my local box, the other the test server.
This is an issue which occurs when I log onto our remote development server using ssh;
```
git clone me@me.mydevbox.com:/home/chris/myproje... | Make sure `git-upload-pack` is on the path from a non-login shell. (On my machine it's in `/usr/bin`).
To see what your path looks like on the remote machine from a non-login shell, try this:
```
ssh you@remotemachine echo \$PATH
```
(That works in Bash, Zsh, and tcsh, and probably other shells too.)
If the path it... |
10459374 | Making git diff --stat show full file path | 174 | 2012-05-05 06:11:58 | <p>On doing <code>git diff --stat</code> some files are listed with full path from repository base but some files are listed as:</p>
<pre><code>.../short/path/to/filename.
</code></pre>
<p>That is the path starts with <code>...</code> and only short path is shown.</p>
<p>I would like <code>git diff</code> to list ... | 59,514 | 1,403,211 | 2021-05-04 11:22:01 | 10,460,154 | 175 | 2012-05-05 08:26:02 | 1,256,452 | 2021-05-04 11:22:01 | https://stackoverflow.com/q/10459374 | https://stackoverflow.com/a/10460154 | <p>By default <code>git diff</code> truncates its output to fit into a 80-column terminal.</p>
<p>You can override this by specifying values using the <a href="https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---statltwidthgtltname-widthgtltcountgt" rel="noreferrer"><code>--stat</code> option</a>:</p>
<pre><... | <p>By default <code>git diff</code> truncates its output to fit into a 80-column terminal.</p> <p>You can override this by specifying values using the <a href="https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---statltwidthgtltname-widthgtltcountgt" rel="noreferrer"><code>--stat</code> option</a>:</p> <pre><... | 119, 9033 | git, git-diff | <h1>Making git diff --stat show full file path</h1>
<p>On doing <code>git diff --stat</code> some files are listed with full path from repository base but some files are listed as:</p>
<pre><code>.../short/path/to/filename.
</code></pre>
<p>That is the path starts with <code>...</code> and only short path is shown.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,237 | git | # Making git diff --stat show full file path
On doing `git diff --stat` some files are listed with full path from repository base but some files are listed as:
```
.../short/path/to/filename.
```
That is the path starts with `...` and only short path is shown.
I would like `git diff` to list full file path for all ... | By default `git diff` truncates its output to fit into a 80-column terminal.
You can override this by specifying values using the [`--stat` option](https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---statltwidthgtltname-widthgtltcountgt):
```
--stat[=<width>[,<name-width>[,<count>]]]
Generate a diff... |
8965781 | Update an outdated branch against master in a Git repo | 145 | 2012-01-22 23:42:17 | <p>I have a Git repository that has branch (local and remote) that has become outdated. I would like to bring this branch up to date with the master branch, but I don't know how to do this. There will also probably be many merge conflicts. </p>
<p>How can I bring or update this out-of-date branch to the same state as ... | 131,905 | 48,523 | 2017-12-05 09:27:17 | 8,965,803 | 175 | 2012-01-22 23:45:59 | 1,024,637 | 2012-03-02 05:04:42 | https://stackoverflow.com/q/8965781 | https://stackoverflow.com/a/8965803 | <p>Update the master branch, which you need to do regardless.</p>
<p>Then, one of:</p>
<ol>
<li><p>Rebase the old branch against the master branch. Solve the merge conflicts during rebase, and the result will be an up-to-date branch that merges cleanly against master.</p></li>
<li><p>Merge your branch into master, a... | <p>Update the master branch, which you need to do regardless.</p> <p>Then, one of:</p> <ol> <li><p>Rebase the old branch against the master branch. Solve the merge conflicts during rebase, and the result will be an up-to-date branch that merges cleanly against master.</p></li> <li><p>Merge your branch into master, a... | 119, 76220 | git, git-branch | <h1>Update an outdated branch against master in a Git repo</h1>
<p>I have a Git repository that has branch (local and remote) that has become outdated. I would like to bring this branch up to date with the master branch, but I don't know how to do this. There will also probably be many merge conflicts. </p>
<p>How can... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,238 | git | # Update an outdated branch against master in a Git repo
I have a Git repository that has branch (local and remote) that has become outdated. I would like to bring this branch up to date with the master branch, but I don't know how to do this. There will also probably be many merge conflicts.
How can I bring or updat... | Update the master branch, which you need to do regardless.
Then, one of:
1. Rebase the old branch against the master branch. Solve the merge conflicts during rebase, and the result will be an up-to-date branch that merges cleanly against master.
2. Merge your branch into master, and resolve the merge conflicts.
3. Me... |
12794568 | How to configure Git post commit hook | 138 | 2012-10-09 07:06:03 | <p>How to trigger a build remotely from Jenkins?<br>
How to configure Git post commit hook?</p>
<p>My requirement is whenever changes are made in the Git repository for a particular project it will automatically start Jenkins build for that project. </p>
<p>In Jenkins trigger build section I selected trigger build r... | 219,155 | 1,722,045 | 2018-01-04 09:59:11 | 12,794,930 | 175 | 2012-10-09 07:29:00 | 6,309 | 2018-01-04 09:59:11 | https://stackoverflow.com/q/12794568 | https://stackoverflow.com/a/12794930 | <p>As mentioned in "<a href="http://kohsuke.org/2011/12/01/polling-must-die-triggering-jenkins-builds-from-a-git-hook/" rel="noreferrer">Polling must die: triggering Jenkins builds from a git hook</a>", you can notify Jenkins of a new commit:</p>
<blockquote>
<p>With the latest <a href="https://wiki.jenkins-ci.org/d... | <p>As mentioned in "<a href="http://kohsuke.org/2011/12/01/polling-must-die-triggering-jenkins-builds-from-a-git-hook/" rel="noreferrer">Polling must die: triggering Jenkins builds from a git hook</a>", you can notify Jenkins of a new commit:</p> <blockquote> <p>With the latest <a href="https://wiki.jenkins-ci.org/d... | 119, 853, 5597, 64999 | commit, git, hook, jenkins | <h1>How to configure Git post commit hook</h1>
<p>How to trigger a build remotely from Jenkins?<br>
How to configure Git post commit hook?</p>
<p>My requirement is whenever changes are made in the Git repository for a particular project it will automatically start Jenkins build for that project. </p>
<p>In Jenkins t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,239 | git | # How to configure Git post commit hook
How to trigger a build remotely from Jenkins?
How to configure Git post commit hook?
My requirement is whenever changes are made in the Git repository for a particular project it will automatically start Jenkins build for that project.
In Jenkins trigger build section I sele... | As mentioned in "[Polling must die: triggering Jenkins builds from a git hook](http://kohsuke.org/2011/12/01/polling-must-die-triggering-jenkins-builds-from-a-git-hook/)", you can notify Jenkins of a new commit:
> With the latest [Git plugin 1.1.14](https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin) (that I just ... |
41502146 | git - gpg onto mac osx: error: gpg failed to sign the data | 119 | 2017-01-06 09:00:45 | <p>I installed GPG from brew.</p>
<pre><code>brew install gpg
</code></pre>
<p>It is gnupg2-2.0.30_2.</p>
<p>When I commit, I do get a error message:</p>
<pre><code>You need a passphrase to unlock the secret key for
user: "Max Mustermann (mycomment) <mm@test.de>"
2048-bit RSA key, ID 1111AAAA, created 2017-01... | 75,476 | 5,883,086 | 2025-07-25 21:48:28 | 41,506,446 | 175 | 2017-01-06 13:08:28 | 441,757 | 2022-04-12 21:14:13 | https://stackoverflow.com/q/41502146 | https://stackoverflow.com/a/41506446 | <p>If you’re not getting prompted at all for a passphrase, the solution may just be to install a program to facilitate that. The most common is <a href="https://www.gnupg.org/related_software/pinentry/index.en.html" rel="noreferrer">pinentry</a>.</p>
<pre><code>brew install pinentry-mac
</code></pre>
<p>So installing t... | <p>If you’re not getting prompted at all for a passphrase, the solution may just be to install a program to facilitate that. The most common is <a href="https://www.gnupg.org/related_software/pinentry/index.en.html" rel="noreferrer">pinentry</a>.</p> <pre><code>brew install pinentry-mac </code></pre> <p>So installing t... | 119, 369, 6735 | git, gnupg, macos | <h1>git - gpg onto mac osx: error: gpg failed to sign the data</h1>
<p>I installed GPG from brew.</p>
<pre><code>brew install gpg
</code></pre>
<p>It is gnupg2-2.0.30_2.</p>
<p>When I commit, I do get a error message:</p>
<pre><code>You need a passphrase to unlock the secret key for
user: "Max Mustermann (mycomment... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,240 | git | # git - gpg onto mac osx: error: gpg failed to sign the data
I installed GPG from brew.
```
brew install gpg
```
It is gnupg2-2.0.30_2.
When I commit, I do get a error message:
```
You need a passphrase to unlock the secret key for
user: "Max Mustermann (mycomment) <mm@test.de>"
2048-bit RSA key, ID 1111AAAA, crea... | If you’re not getting prompted at all for a passphrase, the solution may just be to install a program to facilitate that. The most common is [pinentry](https://www.gnupg.org/related_software/pinentry/index.en.html).
```
brew install pinentry-mac
```
So installing that and trying again *may* get things working. But if... |
9930637 | Edit a merge commit with git rebase | 105 | 2012-03-29 17:46:59 | <p>In Git when I have commits eg. <code>A - B - C</code> and I want to edit the <code>B</code> commit, I</p>
<ul>
<li>use <code>git rebase -i <A-commit-hash></code>,</li>
<li>in the list I write <code>edit</code> command in front of <code>B</code> commit,</li>
<li>git rebase stops right after <code>B</code> comm... | 76,710 | 834,370 | 2021-01-21 22:37:52 | 9,958,215 | 175 | 2012-03-31 17:48:04 | 712,605 | 2020-11-19 19:54:52 | https://stackoverflow.com/q/9930637 | https://stackoverflow.com/a/9958215 | <h3>Updated answer for 2020:</h3>
<p>You can force <code>git rebase -i</code> to stop at the merge commit via the <code>break</code> command (added in Git 2.20). You can then edit the merge commit as desired via <code>git commit --amend</code>.</p>
<p>Detailed steps:</p>
<ol>
<li>Run <code>git rebase -i --rebase-merges... | <h3>Updated answer for 2020:</h3> <p>You can force <code>git rebase -i</code> to stop at the merge commit via the <code>break</code> command (added in Git 2.20). You can then edit the merge commit as desired via <code>git commit --amend</code>.</p> <p>Detailed steps:</p> <ol> <li>Run <code>git rebase -i --rebase-merges... | 119, 8974 | git, rebase | <h1>Edit a merge commit with git rebase</h1>
<p>In Git when I have commits eg. <code>A - B - C</code> and I want to edit the <code>B</code> commit, I</p>
<ul>
<li>use <code>git rebase -i <A-commit-hash></code>,</li>
<li>in the list I write <code>edit</code> command in front of <code>B</code> commit,</li>
<li>git... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,242 | git | # Edit a merge commit with git rebase
In Git when I have commits eg. `A - B - C` and I want to edit the `B` commit, I
- use `git rebase -i <A-commit-hash>`,
- in the list I write `edit` command in front of `B` commit,
- git rebase stops right after `B` commit so I can fix anything I want using `git commit --amend`,- ... | ### Updated answer for 2020:
You can force `git rebase -i` to stop at the merge commit via the `break` command (added in Git 2.20). You can then edit the merge commit as desired via `git commit --amend`.
Detailed steps:
1. Run `git rebase -i --rebase-merges $ancestor_of_merge_commit`
2. Find the merge commit you wan... |
10622179 | How can I find/identify large commits in Git history? | 705 | 2012-05-16 15:54:14 | <p>I have a 300 MB Git repository. The total size of my currently checked-out files is 2 MB, and the total size of the rest of the Git repository is 298 MB. This is basically a code-only repository that should not be more than a few MB.</p>
<p>I suspect someone accidentally committed some large files (video, images, et... | 255,376 | null | 2025-09-08 23:12:37 | 10,622,293 | 174 | 2012-05-16 16:01:20 | 223,092 | 2024-10-25 22:15:30 | https://stackoverflow.com/q/10622179 | https://stackoverflow.com/a/10622293 | <p>I've found this script very useful in the past for finding large (and non-obvious) objects in a Git repository:</p>
<ul>
<li><em><a href="https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/" rel="nofollow noreferrer">Git script to show largest pack objects and... | <p>I've found this script very useful in the past for finding large (and non-obvious) objects in a Git repository:</p> <ul> <li><em><a href="https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/" rel="nofollow noreferrer">Git script to show largest pack objects and... | 119 | git | <h1>How can I find/identify large commits in Git history?</h1>
<p>I have a 300 MB Git repository. The total size of my currently checked-out files is 2 MB, and the total size of the rest of the Git repository is 298 MB. This is basically a code-only repository that should not be more than a few MB.</p>
<p>I suspect som... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,243 | git | # How can I find/identify large commits in Git history?
I have a 300 MB Git repository. The total size of my currently checked-out files is 2 MB, and the total size of the rest of the Git repository is 298 MB. This is basically a code-only repository that should not be more than a few MB.
I suspect someone accidental... | I've found this script very useful in the past for finding large (and non-obvious) objects in a Git repository:
- *[Git script to show largest pack objects and trim your waist line!](https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/)*
---
```
#!/bin/bash
#se... |
13509293 | git: fatal: Could not read from remote repository | 671 | 2012-11-22 09:18:23 | <p>I am trying to set git up with <a href="http://danielmiessler.com/study/git/#website">http://danielmiessler.com/study/git/#website</a> to manage my site.</p>
<p>I have gotten to the last step in the instructions: git push website +master:refs/heads/master</p>
<p>I am working using the git ming32 command line in w... | 2,434,587 | 1,592,380 | 2025-02-18 09:58:54 | 13,509,396 | 174 | 2012-11-22 09:24:04 | 77,567 | 2015-03-23 14:39:00 | https://stackoverflow.com/q/13509293 | https://stackoverflow.com/a/13509396 | <p>You can specify the username that SSH should send to the remote system as part of your remote's URL. Put the username, followed by an <code>@</code>, before the remote hostname.</p>
<pre><code>git remote set-url website abc@***.com:path/to/repo
</code></pre>
| <p>You can specify the username that SSH should send to the remote system as part of your remote's URL. Put the username, followed by an <code>@</code>, before the remote hostname.</p> <pre><code>git remote set-url website abc@***.com:path/to/repo </code></pre> | 119 | git | <h1>git: fatal: Could not read from remote repository</h1>
<p>I am trying to set git up with <a href="http://danielmiessler.com/study/git/#website">http://danielmiessler.com/study/git/#website</a> to manage my site.</p>
<p>I have gotten to the last step in the instructions: git push website +master:refs/heads/master<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,244 | git | # git: fatal: Could not read from remote repository
I am trying to set git up with <http://danielmiessler.com/study/git/#website> to manage my site.
I have gotten to the last step in the instructions: git push website +master:refs/heads/master
I am working using the git ming32 command line in win7
```
$ git push we... | You can specify the username that SSH should send to the remote system as part of your remote's URL. Put the username, followed by an `@`, before the remote hostname.
```
git remote set-url website abc@***.com:path/to/repo
``` |
7861184 | What is the difference between "git init" and "git init --bare"? | 206 | 2011-10-22 17:08:04 | <p>What is the different between <code>git init</code> and <code>git init --bare</code>? I found that a lot of blog post requires <code>--bare</code> for their Git server?</p>
<p>From <a href="https://www.kernel.org/pub/software/scm/git/docs/git-init.html" rel="noreferrer">the man page</a>, it said:</p>
<blockquote>
... | 109,328 | 514,316 | 2022-12-23 22:54:50 | 7,861,254 | 174 | 2011-10-22 17:16:58 | 1,864,976 | 2022-12-23 22:54:50 | https://stackoverflow.com/q/7861184 | https://stackoverflow.com/a/7861254 | <h2>Non-Bare Git Repo</h2>
<p>This variant creates a repository with a working directory so you can actually work (<code>git clone</code>). After creating it you will see that the directory contains a <code>.git</code> folder where the history and all the git plumbing goes. You work at the level where the <code>.git</c... | <h2>Non-Bare Git Repo</h2> <p>This variant creates a repository with a working directory so you can actually work (<code>git clone</code>). After creating it you will see that the directory contains a <code>.git</code> folder where the history and all the git plumbing goes. You work at the level where the <code>.git</c... | 119, 456 | git, version-control | <h1>What is the difference between "git init" and "git init --bare"?</h1>
<p>What is the different between <code>git init</code> and <code>git init --bare</code>? I found that a lot of blog post requires <code>--bare</code> for their Git server?</p>
<p>From <a href="https://www.kernel.org/pub/software/scm/git/docs/git... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,245 | git | # What is the difference between "git init" and "git init --bare"?
What is the different between `git init` and `git init --bare`? I found that a lot of blog post requires `--bare` for their Git server?
From [the man page](https://www.kernel.org/pub/software/scm/git/docs/git-init.html), it said:
> ```
> --bare
> ```... | ## Non-Bare Git Repo
This variant creates a repository with a working directory so you can actually work (`git clone`). After creating it you will see that the directory contains a `.git` folder where the history and all the git plumbing goes. You work at the level where the `.git` folder is.
## Bare Git Repo
The ot... |
6168736 | How do I tell Git to ignore a specific filename only in the repository's top level? | 103 | 2011-05-29 15:59:41 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/3637660/how-to-exclude-file-only-from-root-folder-in-git">How to exclude file only from root folder in GIT</a> </p>
</blockquote>
<p>For a specific JavaScript project, I am using the <a href="http://www.ritlabs... | 49,846 | 430,775 | 2011-05-29 23:27:53 | 6,168,768 | 174 | 2011-05-29 16:04:50 | 216,074 | 2011-05-29 16:04:50 | https://stackoverflow.com/q/6168736 | https://stackoverflow.com/a/6168768 | <p>Add this to your <code>.gitignore</code> (in the root folder):</p>
<pre><code>/index.html
</code></pre>
<p>The leading <code>/</code> makes git use an absolute path (relative to the current <code>.gitignore</code> location), whereas all other lines are just treated as some kind of wildcard.</p>
| <p>Add this to your <code>.gitignore</code> (in the root folder):</p> <pre><code>/index.html </code></pre> <p>The leading <code>/</code> makes git use an absolute path (relative to the current <code>.gitignore</code> location), whereas all other lines are just treated as some kind of wildcard.</p> | 119, 25056 | git, gitignore | <h1>How do I tell Git to ignore a specific filename only in the repository's top level?</h1>
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/3637660/how-to-exclude-file-only-from-root-folder-in-git">How to exclude file only from root folder in GIT</a> </p>
</bl... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,246 | git | # How do I tell Git to ignore a specific filename only in the repository's top level?
> **Possible Duplicate:**
> [How to exclude file only from root folder in GIT](https://stackoverflow.com/questions/3637660/how-to-exclude-file-only-from-root-folder-in-git)
For a specific JavaScript project, I am using the [TinyWe... | Add this to your `.gitignore` (in the root folder):
```
/index.html
```
The leading `/` makes git use an absolute path (relative to the current `.gitignore` location), whereas all other lines are just treated as some kind of wildcard. |
6412516 | Configuring diff tool with .gitconfig | 234 | 2011-06-20 14:08:56 | <p>How do I configure Git to use a different tool for diffing with the <code>.gitconfig</code> file?</p>
<p>I have this in my .gitconfig:</p>
<pre class="lang-ini prettyprint-override"><code>[diff]
tool = git-chdiff #also tried /bin/git-chdiff
</code></pre>
<p>It does not work; it just opens the regular command lin... | 338,384 | 384,016 | 2024-08-21 13:38:52 | 6,412,645 | 173 | 2011-06-20 14:18:32 | 297,323 | 2024-08-17 19:26:30 | https://stackoverflow.com/q/6412516 | https://stackoverflow.com/a/6412645 | <p>Git offers a range of difftools pre-configured "out-of-the-box" (kdiff3, kompare, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, diffuse, opendiff, p4merge and araxis), and also allows you to specify your own. To use one of the pre-configured difftools (for example, "vimdiff"), you add... | <p>Git offers a range of difftools pre-configured "out-of-the-box" (kdiff3, kompare, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, diffuse, opendiff, p4merge and araxis), and also allows you to specify your own. To use one of the pre-configured difftools (for example, "vimdiff"), you add... | 119 | git | <h1>Configuring diff tool with .gitconfig</h1>
<p>How do I configure Git to use a different tool for diffing with the <code>.gitconfig</code> file?</p>
<p>I have this in my .gitconfig:</p>
<pre class="lang-ini prettyprint-override"><code>[diff]
tool = git-chdiff #also tried /bin/git-chdiff
</code></pre>
<p>It does ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,247 | git | # Configuring diff tool with .gitconfig
How do I configure Git to use a different tool for diffing with the `.gitconfig` file?
I have this in my .gitconfig:
```
[diff]
tool = git-chdiff #also tried /bin/git-chdiff
```
It does not work; it just opens the regular command line diff. When I do:
```
export GIT_EXTE... | Git offers a range of difftools pre-configured "out-of-the-box" (kdiff3, kompare, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, diffuse, opendiff, p4merge and araxis), and also allows you to specify your own. To use one of the pre-configured difftools (for example, "vimdiff"), you add the following lines to... |
12396622 | What does "1 line adds whitespace errors" mean when applying a patch? | 145 | 2012-09-12 21:47:11 | <p>I'm editing some markdown files of a cloned remote repository, and wanted to test creating and applying patches from one branch to another. However, every time I make any change at all, I get the following message during <code>git apply</code>:</p>
<pre><code>0001-b.patch:16: trailing whitespace.
warning: 1 line ad... | 76,623 | 165,673 | 2020-12-08 10:32:58 | 12,396,793 | 173 | 2012-09-12 22:06:05 | 1,600,898 | 2016-02-10 09:21:40 | https://stackoverflow.com/q/12396622 | https://stackoverflow.com/a/12396793 | <p>You don't need to care.</p>
<p>The warning enacts a standard of cleanliness of text files in regard to whitespace, the kind of thing that many programmers tend to care about. As <a href="http://www.kernel.org/pub/software/scm/git/docs/git-apply.html" rel="noreferrer">the manual</a> explains:</p>
<blockquote>
<p>... | <p>You don't need to care.</p> <p>The warning enacts a standard of cleanliness of text files in regard to whitespace, the kind of thing that many programmers tend to care about. As <a href="http://www.kernel.org/pub/software/scm/git/docs/git-apply.html" rel="noreferrer">the manual</a> explains:</p> <blockquote> <p>... | 119, 1084, 2132, 62078 | git, git-patch, patch, whitespace | <h1>What does "1 line adds whitespace errors" mean when applying a patch?</h1>
<p>I'm editing some markdown files of a cloned remote repository, and wanted to test creating and applying patches from one branch to another. However, every time I make any change at all, I get the following message during <code>git apply</... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,249 | git | # What does "1 line adds whitespace errors" mean when applying a patch?
I'm editing some markdown files of a cloned remote repository, and wanted to test creating and applying patches from one branch to another. However, every time I make any change at all, I get the following message during `git apply`:
```
0001-b.p... | You don't need to care.
The warning enacts a standard of cleanliness of text files in regard to whitespace, the kind of thing that many programmers tend to care about. As [the manual](http://www.kernel.org/pub/software/scm/git/docs/git-apply.html) explains:
> What are considered whitespace errors is controlled
> by c... |
8432953 | How to update local tags to match remote? | 137 | 2011-12-08 14:59:37 | <p>I fixed it for my repo by deleting the local tag and then doing a git fetch. This brought the updated tag. </p>
<p>Is there are "right" way to update tags that may have changed on the remote? This is a simple tag, not signed or anything, created with "git tag "</p>
| 122,798 | 145,537 | 2022-02-09 16:47:04 | 8,433,371 | 172 | 2011-12-08 15:29:08 | 6,309 | 2017-11-09 08:33:31 | https://stackoverflow.com/q/8432953 | https://stackoverflow.com/a/8433371 | <p>Make sure you fetch all the tags (through <code>git fetch --tags</code>), to get <em>all</em> the tags and not just ones referencing commits reachable from the branch heads.</p>
<p>Those (fetched) tags are <a href="https://stackoverflow.com/a/5348017/6309">annotated ones (and usually not lightweight)</a>, and if yo... | <p>Make sure you fetch all the tags (through <code>git fetch --tags</code>), to get <em>all</em> the tags and not just ones referencing commits reachable from the branch heads.</p> <p>Those (fetched) tags are <a href="https://stackoverflow.com/a/5348017/6309">annotated ones (and usually not lightweight)</a>, and if yo... | 115, 119 | git, tags | <h1>How to update local tags to match remote?</h1>
<p>I fixed it for my repo by deleting the local tag and then doing a git fetch. This brought the updated tag. </p>
<p>Is there are "right" way to update tags that may have changed on the remote? This is a simple tag, not signed or anything, created with "git tag "</p>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,250 | git | # How to update local tags to match remote?
I fixed it for my repo by deleting the local tag and then doing a git fetch. This brought the updated tag.
Is there are "right" way to update tags that may have changed on the remote? This is a simple tag, not signed or anything, created with "git tag " | Make sure you fetch all the tags (through `git fetch --tags`), to get *all* the tags and not just ones referencing commits reachable from the branch heads.
Those (fetched) tags are [annotated ones (and usually not lightweight)](https://stackoverflow.com/a/5348017/6309), and if you add deleted one on the local repo, th... |
29933349 | How can I make git commit messages divide into multiple lines? | 117 | 2015-04-29 02:36:24 | <p>When I use <code>git log</code> to check out my commit explanatory note I want it to look like this:</p>
<pre><code>1. what I changed
2. blank line
3. why I changed it
</code></pre>
<p>...being in 3 lines not 1 like this: </p>
<pre><code>1. what i changed 2. blank line 3. why i changed
</code></pre>
<p>However,... | 118,904 | 4,790,890 | 2022-09-08 10:14:25 | 29,934,000 | 172 | 2015-04-29 03:50:49 | 2,530,089 | 2015-04-29 03:50:49 | https://stackoverflow.com/q/29933349 | https://stackoverflow.com/a/29934000 | <p>You just use the following command:</p>
<pre><code>$ git commit -m "1. what i changed
> 2. blank line
> 3. why i changed"
</code></pre>
<p>In your terminal, just hit 'enter' for a new line. The commit message won't end until you add the closing quote. The git log will look like:</p>
<pre><code>$ git log
com... | <p>You just use the following command:</p> <pre><code>$ git commit -m "1. what i changed > 2. blank line > 3. why i changed" </code></pre> <p>In your terminal, just hit 'enter' for a new line. The commit message won't end until you add the closing quote. The git log will look like:</p> <pre><code>$ git log com... | 119, 5597 | commit, git | <h1>How can I make git commit messages divide into multiple lines?</h1>
<p>When I use <code>git log</code> to check out my commit explanatory note I want it to look like this:</p>
<pre><code>1. what I changed
2. blank line
3. why I changed it
</code></pre>
<p>...being in 3 lines not 1 like this: </p>
<pre><code>1. w... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,251 | git | # How can I make git commit messages divide into multiple lines?
When I use `git log` to check out my commit explanatory note I want it to look like this:
```
1. what I changed
2. blank line
3. why I changed it
```
...being in 3 lines not 1 like this:
```
1. what i changed 2. blank line 3. why i changed
```
Howev... | You just use the following command:
```
$ git commit -m "1. what i changed
> 2. blank line
> 3. why i changed"
```
In your terminal, just hit 'enter' for a new line. The commit message won't end until you add the closing quote. The git log will look like:
```
$ git log
commit abcde2f660c707br2d20411581c4183170c3p0c2... |
5657451 | How to get a fresh copy of a branch from the remote repository? | 106 | 2011-04-14 01:03:24 | <p>My friend's local <code>master</code> branch is apparently a disaster (through accidental <code>merge</code>s and <code>commit</code>s, I guess). However, his dev branches are fine but contain changes he's not ready to push to remote.</p>
<p>What's the best way of overriding his local <code>master</code> branch wit... | 151,381 | 618,964 | 2020-07-13 09:52:33 | 5,657,500 | 172 | 2011-04-14 01:12:35 | 600,500 | 2016-06-16 18:30:35 | https://stackoverflow.com/q/5657451 | https://stackoverflow.com/a/5657500 | <p>As Jefromi commented, </p>
<pre><code>git checkout master
git reset --hard origin/master
</code></pre>
<p>does the right thing: setting the master to its origin state. (If you are already on the <code>master</code> branch, you can omit the first command.) It also leaves the branch's reflog intact.</p>
<hr>
<p><e... | <p>As Jefromi commented, </p> <pre><code>git checkout master git reset --hard origin/master </code></pre> <p>does the right thing: setting the master to its origin state. (If you are already on the <code>master</code> branch, you can omit the first command.) It also leaves the branch's reflog intact.</p> <hr> <p><e... | 119 | git | <h1>How to get a fresh copy of a branch from the remote repository?</h1>
<p>My friend's local <code>master</code> branch is apparently a disaster (through accidental <code>merge</code>s and <code>commit</code>s, I guess). However, his dev branches are fine but contain changes he's not ready to push to remote.</p>
<p>W... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,252 | git | # How to get a fresh copy of a branch from the remote repository?
My friend's local `master` branch is apparently a disaster (through accidental `merge`s and `commit`s, I guess). However, his dev branches are fine but contain changes he's not ready to push to remote.
What's the best way of overriding his local `maste... | As Jefromi commented,
```
git checkout master
git reset --hard origin/master
```
does the right thing: setting the master to its origin state. (If you are already on the `master` branch, you can omit the first command.) It also leaves the branch's reflog intact.
---
*Old inferior answer:*
```
git checkout dev
git ... |
24294034 | How do I push a local repo to Bitbucket using SourceTree without creating a repo on bitbucket first? | 136 | 2014-06-18 19:58:46 | <p>Is there a way to import my local git repos to SourceTree and push them to my Bitbucket account, having new repos identical to my local repos be created on my account? Or do I have to make a repo online first and push to that? Github has a way to publish your local repos directly from it's client, and it creates it ... | 169,698 | 3,741,030 | 2021-04-21 07:58:43 | 28,123,627 | 171 | 2015-01-24 08:20:51 | 1,852,456 | 2019-04-08 13:01:34 | https://stackoverflow.com/q/24294034 | https://stackoverflow.com/a/28123627 | <p><em>(updated on 3-29-2019 to use the https instead of ssh, so you don't need to use ssh keys)</em></p>
<p>It seems like for BitBucket, you do have to create a repo online first. Using the instructions from <a href="https://confluence.atlassian.com/display/BITBUCKET/Create+a+repository" rel="noreferrer">Atlassian</a... | <p><em>(updated on 3-29-2019 to use the https instead of ssh, so you don't need to use ssh keys)</em></p> <p>It seems like for BitBucket, you do have to create a repo online first. Using the instructions from <a href="https://confluence.atlassian.com/display/BITBUCKET/Create+a+repository" rel="noreferrer">Atlassian</a... | 119, 8337 | bitbucket, git | <h1>How do I push a local repo to Bitbucket using SourceTree without creating a repo on bitbucket first?</h1>
<p>Is there a way to import my local git repos to SourceTree and push them to my Bitbucket account, having new repos identical to my local repos be created on my account? Or do I have to make a repo online firs... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,253 | git | # How do I push a local repo to Bitbucket using SourceTree without creating a repo on bitbucket first?
Is there a way to import my local git repos to SourceTree and push them to my Bitbucket account, having new repos identical to my local repos be created on my account? Or do I have to make a repo online first and pus... | *(updated on 3-29-2019 to use the https instead of ssh, so you don't need to use ssh keys)*
It seems like for BitBucket, you do have to create a repo online first. Using the instructions from [Atlassian](https://confluence.atlassian.com/display/BITBUCKET/Create+a+repository), simply create a new BitBucket repository, ... |
12795790 | How to colorize git-status output? | 122 | 2012-10-09 08:24:03 | <p>I want to colorize git-status output so that: </p>
<pre><code>untracked files = magenta
new files = green
modified files = blue
deleted files = red
</code></pre>
<p>I am instead seeing staged files in green and unstaged files in blue:
<img src="https://i.sstatic.net/bhW0W.png" alt="screenshot of git-status"></p>
... | 60,568 | 758,120 | 2024-11-14 16:38:24 | 12,798,205 | 171 | 2012-10-09 10:37:00 | 6,309 | 2024-10-05 15:48:17 | https://stackoverflow.com/q/12795790 | https://stackoverflow.com/a/12798205 | <p>From <a href="https://git-scm.com/docs/git-config#Documentation/git-config.txt-color" rel="nofollow noreferrer">git config doc</a>:</p>
<pre><code>color.status.<slot>
</code></pre>
<blockquote>
<p>Use customized color for status colorization. <code><slot></code> is one of:</p>
<ul>
<li><code>header</code... | <p>From <a href="https://git-scm.com/docs/git-config#Documentation/git-config.txt-color" rel="nofollow noreferrer">git config doc</a>:</p> <pre><code>color.status.<slot> </code></pre> <blockquote> <p>Use customized color for status colorization. <code><slot></code> is one of:</p> <ul> <li><code>header</code... | 119, 32868, 54839 | git, git-config, git-status | <h1>How to colorize git-status output?</h1>
<p>I want to colorize git-status output so that: </p>
<pre><code>untracked files = magenta
new files = green
modified files = blue
deleted files = red
</code></pre>
<p>I am instead seeing staged files in green and unstaged files in blue:
<img src="https://i.sstatic.net/bhW0... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,254 | git | # How to colorize git-status output?
I want to colorize git-status output so that:
```
untracked files = magenta
new files = green
modified files = blue
deleted files = red
```
I am instead seeing staged files in green and unstaged files in blue:

My .gitc... | From [git config doc](https://git-scm.com/docs/git-config#Documentation/git-config.txt-color):
```
color.status.<slot>
```
> Use customized color for status colorization. `<slot>` is one of:
>
> - `header` (the header text of the status message),
> - `added` or `updated` (files which are added but not committed),
> -... |
32517870 | How to undo git stash clear | 110 | 2015-09-11 07:25:57 | <p>I executed <code>git stash save "ABC"</code>.
<br>Then by mistake I did <code>git stash clear</code> .
How can I retrieve the data that was in stash ABC?</p>
| 33,811 | 3,270,097 | 2025-08-01 14:37:02 | 32,518,069 | 171 | 2015-09-11 07:37:17 | 978,704 | 2025-08-01 14:37:02 | https://stackoverflow.com/q/32517870 | https://stackoverflow.com/a/32518069 | <p>As it may be found in <a href="http://git-scm.com/docs/git-stash" rel="nofollow noreferrer">the documentation of git stash</a>, you may be lucky if this works:</p>
<blockquote>
<p>Recovering stashes that were cleared/dropped erroneously</p>
<p>If you mistakenly drop or clear stashes, they cannot be recovered through... | <p>As it may be found in <a href="http://git-scm.com/docs/git-stash" rel="nofollow noreferrer">the documentation of git stash</a>, you may be lucky if this works:</p> <blockquote> <p>Recovering stashes that were cleared/dropped erroneously</p> <p>If you mistakenly drop or clear stashes, they cannot be recovered through... | 119 | git | <h1>How to undo git stash clear</h1>
<p>I executed <code>git stash save "ABC"</code>.
<br>Then by mistake I did <code>git stash clear</code> .
How can I retrieve the data that was in stash ABC?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,256 | git | # How to undo git stash clear
I executed `git stash save "ABC"`.
Then by mistake I did `git stash clear` .
How can I retrieve the data that was in stash ABC? | As it may be found in [the documentation of git stash](http://git-scm.com/docs/git-stash), you may be lucky if this works:
> Recovering stashes that were cleared/dropped erroneously
>
> If you mistakenly drop or clear stashes, they cannot be recovered through the normal safety mechanisms. However, you can try the foll... |
7925850 | How can I automatically push after committing in Git? | 105 | 2011-10-28 06:25:43 | <p>How do I set Git to automatically push to a remote
repository (including automatically providing my passphrase) after each commit to the local repository?</p>
| 73,926 | 112,757 | 2021-12-05 22:15:00 | 7,925,891 | 171 | 2011-10-28 06:32:17 | 223,092 | 2018-09-12 04:19:02 | https://stackoverflow.com/q/7925850 | https://stackoverflow.com/a/7925891 | <p>First, make sure that you can push manually without providing your password. If you are pushing over HTTP or HTTPS, that will be a case of either <a href="https://stackoverflow.com/questions/6031214/git-how-to-use-netrc-file-on-windows-to-save-user-and-password">creating a <code>.netrc</code> file with the login de... | <p>First, make sure that you can push manually without providing your password. If you are pushing over HTTP or HTTPS, that will be a case of either <a href="https://stackoverflow.com/questions/6031214/git-how-to-use-netrc-file-on-windows-to-save-user-and-password">creating a <code>.netrc</code> file with the login de... | 119, 28898, 43087, 61840 | git, githooks, git-push, post-commit-hook | <h1>How can I automatically push after committing in Git?</h1>
<p>How do I set Git to automatically push to a remote
repository (including automatically providing my passphrase) after each commit to the local repository?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,257 | git | # How can I automatically push after committing in Git?
How do I set Git to automatically push to a remote
repository (including automatically providing my passphrase) after each commit to the local repository? | First, make sure that you can push manually without providing your password. If you are pushing over HTTP or HTTPS, that will be a case of either [creating a `.netrc` file with the login details](https://stackoverflow.com/questions/6031214/git-how-to-use-netrc-file-on-windows-to-save-user-and-password) or [adding your ... |
33942588 | Difference between 'rebase master' and 'rebase --onto master' from a branch derived from a branch of master | 61 | 2015-11-26 15:51:00 | <p>Given the following branch structure:</p>
<pre><code> *------*---*
Master \
*---*--*------*
A \
*-----*-----*
B (HEAD)
</code></pre>
<p>If I want to merge my B changes (and <strong>only</strong> my B changes, no A c... | 37,844 | 467,859 | 2018-09-13 13:44:34 | 33,948,237 | 171 | 2015-11-26 23:10:04 | 1,256,452 | 2018-09-13 13:44:34 | https://stackoverflow.com/q/33942588 | https://stackoverflow.com/a/33948237 | <p>Bear with me for a while before I answer the question as asked. One the earlier answers is right but there are labeling and other relatively minor (but potentially confusing) issues, so I want to start with branch drawings and branch labels. Also, people coming from other systems, or maybe even just new to revisio... | <p>Bear with me for a while before I answer the question as asked. One the earlier answers is right but there are labeling and other relatively minor (but potentially confusing) issues, so I want to start with branch drawings and branch labels. Also, people coming from other systems, or maybe even just new to revisio... | 119, 29934 | git, git-rebase | <h1>Difference between 'rebase master' and 'rebase --onto master' from a branch derived from a branch of master</h1>
<p>Given the following branch structure:</p>
<pre><code> *------*---*
Master \
*---*--*------*
A \
*-----*-----*
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,258 | git | # Difference between 'rebase master' and 'rebase --onto master' from a branch derived from a branch of master
Given the following branch structure:
```
*------*---*
Master \
*---*--*------*
A \
*-----*-----*
B (HEAD)
... | Bear with me for a while before I answer the question as asked. One the earlier answers is right but there are labeling and other relatively minor (but potentially confusing) issues, so I want to start with branch drawings and branch labels. Also, people coming from other systems, or maybe even just new to revision con... |
65605282 | Trying to install Hugo via Homebrew - "Could Not Resolve HEAD to a Revision" | 38 | 2021-01-07 00:57:22 | <p>I'm trying to take a stab at a new site using Hugo, and I am stuck during installation. I've installed Homebrew and when running the version, I get the following:</p>
<pre><code>~ % brew --version
Homebrew 2.7.2
Homebrew/homebrew-core (no git repository)
Homebrew/homebrew-cask (git revision b96680c; last commit 2021... | 34,888 | 10,908,002 | 2022-12-19 11:46:01 | 65,759,743 | 171 | 2021-01-17 10:53:32 | 15,023,420 | 2021-11-29 10:05:19 | https://stackoverflow.com/q/65605282 | https://stackoverflow.com/a/65759743 | <p>Use</p>
<pre class="lang-sh prettyprint-override"><code>git -C $(brew --repository homebrew/core) checkout master
</code></pre>
<p>or</p>
<pre class="lang-sh prettyprint-override"><code>git -C $(brew --repository homebrew/core) reset --hard HEAD
</code></pre>
| <p>Use</p> <pre class="lang-sh prettyprint-override"><code>git -C $(brew --repository homebrew/core) checkout master </code></pre> <p>or</p> <pre class="lang-sh prettyprint-override"><code>git -C $(brew --repository homebrew/core) reset --hard HEAD </code></pre> | 119, 1067, 106634 | git, homebrew, hugo | <h1>Trying to install Hugo via Homebrew - "Could Not Resolve HEAD to a Revision"</h1>
<p>I'm trying to take a stab at a new site using Hugo, and I am stuck during installation. I've installed Homebrew and when running the version, I get the following:</p>
<pre><code>~ % brew --version
Homebrew 2.7.2
Homebrew/homebrew-c... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,259 | git | # Trying to install Hugo via Homebrew - "Could Not Resolve HEAD to a Revision"
I'm trying to take a stab at a new site using Hugo, and I am stuck during installation. I've installed Homebrew and when running the version, I get the following:
```
~ % brew --version
Homebrew 2.7.2
Homebrew/homebrew-core (no git reposit... | Use
```
git -C $(brew --repository homebrew/core) checkout master
```
or
```
git -C $(brew --repository homebrew/core) reset --hard HEAD
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.