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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
11459475 | Should I check in folder "node_modules" to Git when creating a Node.js app on Heroku? | 405 | 2012-07-12 19:45:23 | <p>I followed the basic <em>getting started</em> instructions for Node.js on Heroku here:</p>
<p><a href="https://devcenter.heroku.com/categories/nodejs" rel="noreferrer">https://devcenter.heroku.com/categories/nodejs</a></p>
<p>These instructions don't tell you to create a .gitignore node_modules, and therefore imply ... | 202,647 | 1,072,179 | 2024-03-31 13:09:58 | 19,416,403 | 410 | 2013-10-17 00:46:38 | 1,101,154 | 2021-03-30 22:16:37 | https://stackoverflow.com/q/11459475 | https://stackoverflow.com/a/19416403 | <h2>Second Update</h2>
<p>The FAQ is not available anymore.</p>
<p>From the documentation of <a href="https://docs.npmjs.com/cli/shrinkwrap" rel="noreferrer"><code>shrinkwrap</code></a>:</p>
<blockquote>
<p>If you wish to lock down the specific bytes included in a package, for example to have 100% confidence in being a... | <h2>Second Update</h2> <p>The FAQ is not available anymore.</p> <p>From the documentation of <a href="https://docs.npmjs.com/cli/shrinkwrap" rel="noreferrer"><code>shrinkwrap</code></a>:</p> <blockquote> <p>If you wish to lock down the specific bytes included in a package, for example to have 100% confidence in being a... | 119, 8279, 25056, 46426, 61387 | git, gitignore, heroku, node.js, npm | <h1>Should I check in folder "node_modules" to Git when creating a Node.js app on Heroku?</h1>
<p>I followed the basic <em>getting started</em> instructions for Node.js on Heroku here:</p>
<p><a href="https://devcenter.heroku.com/categories/nodejs" rel="noreferrer">https://devcenter.heroku.com/categories/nodejs</a></p>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,454 | git | # Should I check in folder "node_modules" to Git when creating a Node.js app on Heroku?
I followed the basic *getting started* instructions for Node.js on Heroku here:
<https://devcenter.heroku.com/categories/nodejs>
These instructions don't tell you to create a .gitignore node_modules, and therefore imply that fold... | ## Second Update
The FAQ is not available anymore.
From the documentation of [`shrinkwrap`](https://docs.npmjs.com/cli/shrinkwrap):
> If you wish to lock down the specific bytes included in a package, for example to have 100% confidence in being able to reproduce a deployment or build, then you ought to check your d... |
2620775 | Revert changes to a file in a commit | 254 | 2010-04-12 08:44:19 | <p>I want to revert changes made by a particular commit to a given file only.</p>
<p>Can I use git revert command for that?</p>
<p>Any other simple way to do it?</p>
| 177,349 | 55,562 | 2025-05-01 14:39:12 | 7,196,615 | 410 | 2011-08-25 20:12:58 | 209,050 | 2024-11-01 16:52:23 | https://stackoverflow.com/q/2620775 | https://stackoverflow.com/a/7196615 | <p>The cleanest way I've seen of doing this is described <a href="http://git.661346.n2.nabble.com/Revert-a-single-commit-in-a-single-file-tp6064050p6064406.html" rel="noreferrer">here</a></p>
<pre><code>git show some_commit_sha1 -- some_file.c | git apply -R
</code></pre>
<p>Show the change and reverse it. Similar to V... | <p>The cleanest way I've seen of doing this is described <a href="http://git.661346.n2.nabble.com/Revert-a-single-commit-in-a-single-file-tp6064050p6064406.html" rel="noreferrer">here</a></p> <pre><code>git show some_commit_sha1 -- some_file.c | git apply -R </code></pre> <p>Show the change and reverse it. Similar to V... | 119, 456, 12309 | git, revert, version-control | <h1>Revert changes to a file in a commit</h1>
<p>I want to revert changes made by a particular commit to a given file only.</p>
<p>Can I use git revert command for that?</p>
<p>Any other simple way to do it?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,455 | git | # Revert changes to a file in a commit
I want to revert changes made by a particular commit to a given file only.
Can I use git revert command for that?
Any other simple way to do it? | The cleanest way I've seen of doing this is described [here](http://git.661346.n2.nabble.com/Revert-a-single-commit-in-a-single-file-tp6064050p6064406.html)
```
git show some_commit_sha1 -- some_file.c | git apply -R
```
Show the change and reverse it. Similar to VonC's response but using `git show` and `git apply`. |
71768999 | How to merge when you get error "Hint: You have divergent branches and need to specify how to reconcile them." | 231 | 2022-04-06 14:53:07 | <p>I'm working with one other developer who has created a branch that needs to be merged with <em>master</em>.</p>
<p>I get this error when attempting to pull in Git in Visual Studio Community (not Visual Studio Code) to a Bitbucket repository.</p>
<p>If I attempt to push, it says "unable to push because your loca... | 320,910 | 2,254,951 | 2025-05-03 01:37:27 | 71,774,640 | 410 | 2022-04-06 23:22:28 | 1,256,452 | 2024-01-04 01:26:46 | https://stackoverflow.com/q/71768999 | https://stackoverflow.com/a/71774640 | <p>As is often the case with confusing stuff in Git, there's some history involved.</p>
<p>The first thing to know is that <code>git pull</code> does too much stuff. Well, for some people (me), it does too much; others like that it does this much; but in fact, it does two jobs, each of which has its own separate Git c... | <p>As is often the case with confusing stuff in Git, there's some history involved.</p> <p>The first thing to know is that <code>git pull</code> does too much stuff. Well, for some people (me), it does too much; others like that it does this much; but in fact, it does two jobs, each of which has its own separate Git c... | 119, 28896, 33953 | git, git-pull, visual-studio | <h1>How to merge when you get error "Hint: You have divergent branches and need to specify how to reconcile them."</h1>
<p>I'm working with one other developer who has created a branch that needs to be merged with <em>master</em>.</p>
<p>I get this error when attempting to pull in Git in Visual Studio Community (not Vi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,456 | git | # How to merge when you get error "Hint: You have divergent branches and need to specify how to reconcile them."
I'm working with one other developer who has created a branch that needs to be merged with *master*.
I get this error when attempting to pull in Git in Visual Studio Community (not Visual Studio Code) to a... | As is often the case with confusing stuff in Git, there's some history involved.
The first thing to know is that `git pull` does too much stuff. Well, for some people (me), it does too much; others like that it does this much; but in fact, it does two jobs, each of which has its own separate Git command:
1. `git pull... |
3161204 | How to find the nearest parent of a Git branch | 627 | 2010-07-01 19:52:13 | <p>Let's say I have the following local repository with a commit tree like this:</p>
<pre><code>master --> a
\
\
develop c --> d
\
\
feature f --> g --> h
</code></pre>
<p><code>master</code> is my <em>this is the latest stable release c... | 862,877 | 66,020 | 2025-02-24 05:58:54 | 3,162,929 | 409 | 2010-07-02 02:27:10 | 193,688 | 2021-07-06 21:24:43 | https://stackoverflow.com/q/3161204 | https://stackoverflow.com/a/3162929 | <p>Assuming that the remote repository has a copy of the <em>develop</em> branch (your initial description describes it in a local repository, but it sounds like it also exists in the remote), you should be able to achieve what I think you want, but the approach is a bit different from what you have envisioned.</p>
<p>... | <p>Assuming that the remote repository has a copy of the <em>develop</em> branch (your initial description describes it in a local repository, but it sounds like it also exists in the remote), you should be able to achieve what I think you want, but the approach is a bit different from what you have envisioned.</p> <p>... | 119, 1879 | branch, git | <h1>How to find the nearest parent of a Git branch</h1>
<p>Let's say I have the following local repository with a commit tree like this:</p>
<pre><code>master --> a
\
\
develop c --> d
\
\
feature f --> g --> h
</code></pre>
<p><code>mas... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,457 | git | # How to find the nearest parent of a Git branch
Let's say I have the following local repository with a commit tree like this:
```
master --> a
\
\
develop c --> d
\
\
feature f --> g --> h
```
`master` is my *this is the latest stable release co... | Assuming that the remote repository has a copy of the *develop* branch (your initial description describes it in a local repository, but it sounds like it also exists in the remote), you should be able to achieve what I think you want, but the approach is a bit different from what you have envisioned.
Git’s history is... |
48524417 | Should the package-lock.json file be added to .gitignore? | 225 | 2018-01-30 14:58:40 | <p>To lock the versions of dependencies that are installed over a project, the command <code>npm install</code> creates a file called <code>package-lock.json</code>. This was made since <a href="https://nodejs.org/en/blog/release/v8.0.0/" rel="noreferrer">Node.js v8.0.0</a> and <a href="https://www.npmjs.com/package/np... | 245,835 | 2,371,987 | 2022-05-04 10:39:07 | 48,524,475 | 409 | 2018-01-30 15:02:49 | 457,268 | 2022-05-04 10:39:07 | https://stackoverflow.com/q/48524417 | https://stackoverflow.com/a/48524475 | <p>No, the <code>package-lock.json</code> <strong>SHOULD NOT</strong> be added to <code>.gitignore</code>. Instead, I strongly advise:</p>
<ol>
<li><strong>Add the <code>package-lock.json</code> you to your version control repository</strong></li>
<li><strong>Use <code>npm ci</code> instead of <code>npm install</code><... | <p>No, the <code>package-lock.json</code> <strong>SHOULD NOT</strong> be added to <code>.gitignore</code>. Instead, I strongly advise:</p> <ol> <li><strong>Add the <code>package-lock.json</code> you to your version control repository</strong></li> <li><strong>Use <code>npm ci</code> instead of <code>npm install</code><... | 3, 119, 25056, 46426, 61387 | git, gitignore, javascript, node.js, npm | <h1>Should the package-lock.json file be added to .gitignore?</h1>
<p>To lock the versions of dependencies that are installed over a project, the command <code>npm install</code> creates a file called <code>package-lock.json</code>. This was made since <a href="https://nodejs.org/en/blog/release/v8.0.0/" rel="noreferre... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,458 | git | # Should the package-lock.json file be added to .gitignore?
To lock the versions of dependencies that are installed over a project, the command `npm install` creates a file called `package-lock.json`. This was made since [Node.js v8.0.0](https://nodejs.org/en/blog/release/v8.0.0/) and [npm v5.0.0](https://www.npmjs.co... | No, the `package-lock.json` **SHOULD NOT** be added to `.gitignore`. Instead, I strongly advise:
1. **Add the `package-lock.json` you to your version control repository**
2. **Use `npm ci` instead of `npm install`** when building your application both locally and in your deployment pipeline.
(The `ci` command is ... |
53682247 | How to point Go module dependency in go.mod to a latest commit in a repo? | 290 | 2018-12-08 11:53:31 | <p>Starting with v1.11 Go added support for modules. Commands</p>
<pre class="lang-bash prettyprint-override"><code>go mod init <package name>
go build
</code></pre>
<p>would generate <code>go.mod</code> and <code>go.sum</code> files that contain all found versions for the package dependencies. If a module does n... | 344,250 | 23,080 | 2025-03-27 20:55:07 | 53,682,399 | 407 | 2018-12-08 12:10:29 | 1,011,695 | 2018-12-08 12:10:29 | https://stackoverflow.com/q/53682247 | https://stackoverflow.com/a/53682399 | <p>Just 'go get' at the commit hash you want:</p>
<pre><code>go get github.com/someone/some_module@af044c0995fe
</code></pre>
<p>'go get' will correctly update the dependency files (go.mod, go.sum).</p>
<p>More information: <a href="https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies"... | <p>Just 'go get' at the commit hash you want:</p> <pre><code>go get github.com/someone/some_module@af044c0995fe </code></pre> <p>'go get' will correctly update the dependency files (go.mod, go.sum).</p> <p>More information: <a href="https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies"... | 119, 3849, 15627 | git, go, module | <h1>How to point Go module dependency in go.mod to a latest commit in a repo?</h1>
<p>Starting with v1.11 Go added support for modules. Commands</p>
<pre class="lang-bash prettyprint-override"><code>go mod init <package name>
go build
</code></pre>
<p>would generate <code>go.mod</code> and <code>go.sum</code> fil... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,460 | git | # How to point Go module dependency in go.mod to a latest commit in a repo?
Starting with v1.11 Go added support for modules. Commands
```
go mod init <package name>
go build
```
would generate `go.mod` and `go.sum` files that contain all found versions for the package dependencies. If a module does not have any rel... | Just 'go get' at the commit hash you want:
```
go get github.com/someone/some_module@af044c0995fe
```
'go get' will correctly update the dependency files (go.mod, go.sum).
More information: <https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies> |
6650215 | How to keep the local file or the remote file during merge using Git and the command line? | 272 | 2011-07-11 12:41:08 | <p>I know how to merge modification using vimdiff, but, assuming I just know that the entire file is good to keep or to throw away, how do I do that? </p>
<p>I don't want to open vimdiff for each of them, I change want a command that says 'keep local' or 'keep remote'.</p>
<p>E.G: I got a merge with files marked as c... | 205,858 | 9,951 | 2021-06-24 01:25:05 | 12,025,832 | 407 | 2012-08-19 10:31:24 | 877,028 | 2020-01-21 17:24:35 | https://stackoverflow.com/q/6650215 | https://stackoverflow.com/a/12025832 | <p>You can as well do:</p>
<pre><code>git checkout --theirs /path/to/file
</code></pre>
<p>to keep the remote file, and:</p>
<pre><code>git checkout --ours /path/to/file
</code></pre>
<p>to keep local file.</p>
<p>Then <code>git add</code> them and everything is done.</p>
<p><strong>Edition:
Keep in mind that thi... | <p>You can as well do:</p> <pre><code>git checkout --theirs /path/to/file </code></pre> <p>to keep the remote file, and:</p> <pre><code>git checkout --ours /path/to/file </code></pre> <p>to keep local file.</p> <p>Then <code>git add</code> them and everything is done.</p> <p><strong>Edition: Keep in mind that thi... | 119, 717, 6923 | git, local, merge | <h1>How to keep the local file or the remote file during merge using Git and the command line?</h1>
<p>I know how to merge modification using vimdiff, but, assuming I just know that the entire file is good to keep or to throw away, how do I do that? </p>
<p>I don't want to open vimdiff for each of them, I change want ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,461 | git | # How to keep the local file or the remote file during merge using Git and the command line?
I know how to merge modification using vimdiff, but, assuming I just know that the entire file is good to keep or to throw away, how do I do that?
I don't want to open vimdiff for each of them, I change want a command that sa... | You can as well do:
```
git checkout --theirs /path/to/file
```
to keep the remote file, and:
```
git checkout --ours /path/to/file
```
to keep local file.
Then `git add` them and everything is done.
**Edition:
Keep in mind that this is for a `merge` scenario. During a `rebase` `--theirs` refers to the branch whe... |
10414769 | git pull keeping local uncommitted changes | 228 | 2012-05-02 13:29:21 | <p>How can I safely update (pull) a git project, keeping specific files untouched, even if there's upstream changes?</p>
<p>myrepo/config/config.php</p>
<p>Is there a way, of, even if this file was being changed on remote, when I git pull, everything else is updated, but this file is unchanged (not even merged)?</p>
<p... | 303,140 | 547,564 | 2024-09-06 12:52:38 | 10,416,070 | 405 | 2012-05-02 14:42:20 | 1,286,639 | 2014-06-26 20:59:37 | https://stackoverflow.com/q/10414769 | https://stackoverflow.com/a/10416070 | <p>There is a simple solution based on Git stash. Stash everything that you've changed, pull all the new stuff, apply your stash.</p>
<pre><code>git stash
git pull
git stash pop
</code></pre>
<p>On stash pop there may be conflicts. In the case you describe there would in fact be a conflict for <code>config.php</cod... | <p>There is a simple solution based on Git stash. Stash everything that you've changed, pull all the new stuff, apply your stash.</p> <pre><code>git stash git pull git stash pop </code></pre> <p>On stash pop there may be conflicts. In the case you describe there would in fact be a conflict for <code>config.php</cod... | 119 | git | <h1>git pull keeping local uncommitted changes</h1>
<p>How can I safely update (pull) a git project, keeping specific files untouched, even if there's upstream changes?</p>
<p>myrepo/config/config.php</p>
<p>Is there a way, of, even if this file was being changed on remote, when I git pull, everything else is updated, ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,463 | git | # git pull keeping local uncommitted changes
How can I safely update (pull) a git project, keeping specific files untouched, even if there's upstream changes?
myrepo/config/config.php
Is there a way, of, even if this file was being changed on remote, when I git pull, everything else is updated, but this file is unch... | There is a simple solution based on Git stash. Stash everything that you've changed, pull all the new stuff, apply your stash.
```
git stash
git pull
git stash pop
```
On stash pop there may be conflicts. In the case you describe there would in fact be a conflict for `config.php`. But, resolving the conflict is easy ... |
8801729 | Is it possible to have different Git configuration for different projects? | 730 | 2012-01-10 10:25:17 | <p><code>.gitconfig</code> is usually stored in the <code>user.home</code> directory.</p>
<p>I use a different identity to work on projects for Company A and something else for Company B (primarily the name / email). How can I have two different Git configurations so that my check-ins don't go with the name / email?</... | 419,260 | 1,004,443 | 2024-12-06 07:22:16 | 8,801,759 | 404 | 2012-01-10 10:27:24 | 148,870 | 2012-01-10 10:27:24 | https://stackoverflow.com/q/8801729 | https://stackoverflow.com/a/8801759 | <p>The <code>.git/config</code> file in a particular clone of a repository is local to that clone. Any settings placed there will only affect actions for that particular project.</p>
<p>(By default, <code>git config</code> modifies <code>.git/config</code>, not <code>~/.gitconfig</code> - only with <code>--global</cod... | <p>The <code>.git/config</code> file in a particular clone of a repository is local to that clone. Any settings placed there will only affect actions for that particular project.</p> <p>(By default, <code>git config</code> modifies <code>.git/config</code>, not <code>~/.gitconfig</code> - only with <code>--global</cod... | 119, 32868 | git, git-config | <h1>Is it possible to have different Git configuration for different projects?</h1>
<p><code>.gitconfig</code> is usually stored in the <code>user.home</code> directory.</p>
<p>I use a different identity to work on projects for Company A and something else for Company B (primarily the name / email). How can I have two... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,464 | git | # Is it possible to have different Git configuration for different projects?
`.gitconfig` is usually stored in the `user.home` directory.
I use a different identity to work on projects for Company A and something else for Company B (primarily the name / email). How can I have two different Git configurations so that ... | The `.git/config` file in a particular clone of a repository is local to that clone. Any settings placed there will only affect actions for that particular project.
(By default, `git config` modifies `.git/config`, not `~/.gitconfig` - only with `--global` does it modify the latter.) |
8527597 | How do I ignore files in a directory in Git? | 577 | 2011-12-15 22:34:35 | <p>What is the proper syntax for the <code>.gitignore</code> file to ignore files in a directory?</p>
<p>Would it be</p>
<pre><code>config/databases.yml
cache/*
log/*
data/sql/*
lib/filter/base/*
lib/form/base/*
lib/model/map/*
lib/model/om/*
</code></pre>
<p>or</p>
<pre><code>/config/databases.yml
/cache/*
/log/*
... | 631,509 | 530,808 | 2019-06-14 13:32:57 | 8,527,650 | 404 | 2011-12-15 22:39:52 | 742,469 | 2017-05-02 05:14:19 | https://stackoverflow.com/q/8527597 | https://stackoverflow.com/a/8527650 | <p><strong>PATTERN FORMAT</strong></p>
<ul>
<li><p>A blank line matches no files, so it can serve as a separator for readability.</p></li>
<li><p>A line starting with <code>#</code> serves as a comment.</p></li>
<li><p>An optional prefix <code>!</code> which negates the pattern; any matching file excluded by a previou... | <p><strong>PATTERN FORMAT</strong></p> <ul> <li><p>A blank line matches no files, so it can serve as a separator for readability.</p></li> <li><p>A line starting with <code>#</code> serves as a comment.</p></li> <li><p>An optional prefix <code>!</code> which negates the pattern; any matching file excluded by a previou... | 119, 25056 | git, gitignore | <h1>How do I ignore files in a directory in Git?</h1>
<p>What is the proper syntax for the <code>.gitignore</code> file to ignore files in a directory?</p>
<p>Would it be</p>
<pre><code>config/databases.yml
cache/*
log/*
data/sql/*
lib/filter/base/*
lib/form/base/*
lib/model/map/*
lib/model/om/*
</code></pre>
<p>or<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,465 | git | # How do I ignore files in a directory in Git?
What is the proper syntax for the `.gitignore` file to ignore files in a directory?
Would it be
```
config/databases.yml
cache/*
log/*
data/sql/*
lib/filter/base/*
lib/form/base/*
lib/model/map/*
lib/model/om/*
```
or
```
/config/databases.yml
/cache/*
/log/*
/data/sq... | **PATTERN FORMAT**
- A blank line matches no files, so it can serve as a separator for readability.
- A line starting with `#` serves as a comment.
- An optional prefix `!` which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will ov... |
21820715 | How to install latest version of git on CentOS 8.x/7.x/6.x | 269 | 2014-02-17 04:23:49 | <p>I used the usual: </p>
<pre><code>yum install git
</code></pre>
<p>It did not install the latest version of git on my CentOS 6. How can I update to the latest version of git for CentOS 6? The solution can be applicable to newer versions of CentOS such as CentOS 7.</p>
| 279,715 | 2,210,206 | 2024-01-22 13:51:16 | 27,674,776 | 404 | 2014-12-28 08:23:40 | 1,470,731 | 2020-03-02 01:15:57 | https://stackoverflow.com/q/21820715 | https://stackoverflow.com/a/27674776 | <p>You can use WANDisco's CentOS repository to install Git 2.x: for <a href="http://opensource.wandisco.com/centos/6/git/x86_64/" rel="noreferrer">CentOS 6</a>, for <a href="http://opensource.wandisco.com/centos/7/git/x86_64/" rel="noreferrer">CentOS 7</a></p>
<ol>
<li><p>Install WANDisco repo package:</p>
<pre><code... | <p>You can use WANDisco's CentOS repository to install Git 2.x: for <a href="http://opensource.wandisco.com/centos/6/git/x86_64/" rel="noreferrer">CentOS 6</a>, for <a href="http://opensource.wandisco.com/centos/7/git/x86_64/" rel="noreferrer">CentOS 7</a></p> <ol> <li><p>Install WANDisco repo package:</p> <pre><code... | 58, 119, 529, 4956, 7425 | centos, git, installation, linux, yum | <h1>How to install latest version of git on CentOS 8.x/7.x/6.x</h1>
<p>I used the usual: </p>
<pre><code>yum install git
</code></pre>
<p>It did not install the latest version of git on my CentOS 6. How can I update to the latest version of git for CentOS 6? The solution can be applicable to newer versions of CentOS ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,466 | git | # How to install latest version of git on CentOS 8.x/7.x/6.x
I used the usual:
```
yum install git
```
It did not install the latest version of git on my CentOS 6. How can I update to the latest version of git for CentOS 6? The solution can be applicable to newer versions of CentOS such as CentOS 7. | You can use WANDisco's CentOS repository to install Git 2.x: for [CentOS 6](http://opensource.wandisco.com/centos/6/git/x86_64/), for [CentOS 7](http://opensource.wandisco.com/centos/7/git/x86_64/)
1. Install WANDisco repo package:
```
yum install http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-... |
15798862 | What does git rev-parse do? | 507 | 2013-04-03 21:53:47 | <p>What does <code>git rev-parse</code> do?</p>
<p>I have read the man page but it raised more questions than answers. Things like:</p>
<blockquote>
<p>Pick out and <strong>massage</strong> parameters</p>
</blockquote>
<p><em>Massage</em>? What does that mean?</p>
<p>I'm using as a resolver (to SHA1) of revision ... | 293,644 | 1,316,620 | 2024-08-30 11:12:27 | 15,802,301 | 403 | 2013-04-04 04:03:28 | 380,757 | 2022-05-01 12:04:47 | https://stackoverflow.com/q/15798862 | https://stackoverflow.com/a/15802301 | <p><a href="http://git-scm.com/docs/git-rev-parse" rel="noreferrer"><code>git rev-parse</code></a> is an ancillary <code>plumbing</code> command primarily used for manipulation.</p>
<p>One common usage of <code>git rev-parse</code> is to print the SHA1 hashes given a revision specifier. In addition, it has various opti... | <p><a href="http://git-scm.com/docs/git-rev-parse" rel="noreferrer"><code>git rev-parse</code></a> is an ancillary <code>plumbing</code> command primarily used for manipulation.</p> <p>One common usage of <code>git rev-parse</code> is to print the SHA1 hashes given a revision specifier. In addition, it has various opti... | 119, 134384 | git, git-rev-parse | <h1>What does git rev-parse do?</h1>
<p>What does <code>git rev-parse</code> do?</p>
<p>I have read the man page but it raised more questions than answers. Things like:</p>
<blockquote>
<p>Pick out and <strong>massage</strong> parameters</p>
</blockquote>
<p><em>Massage</em>? What does that mean?</p>
<p>I'm using... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,467 | git | # What does git rev-parse do?
What does `git rev-parse` do?
I have read the man page but it raised more questions than answers. Things like:
> Pick out and **massage** parameters
*Massage*? What does that mean?
I'm using as a resolver (to SHA1) of revision specifiers, like
```
git rev-parse HEAD^
```
or
```
git... | [`git rev-parse`](http://git-scm.com/docs/git-rev-parse) is an ancillary `plumbing` command primarily used for manipulation.
One common usage of `git rev-parse` is to print the SHA1 hashes given a revision specifier. In addition, it has various options to format this output such as `--short` for printing a shorter uni... |
14655816 | How to commit changes to another pre-existent branch | 235 | 2013-02-01 22:05:55 | <p>I just made changes to a branch. How can I commit the changes to the other branch?</p>
<p>I am trying to use:</p>
<pre><code>git checkout "the commmit to the changed branch" -b "the other branch"
</code></pre>
<p>However, I don't think this is the right thing to do, because in this case I'm creating a new branch ... | 530,540 | 1,988,385 | 2023-04-24 08:51:05 | 14,655,842 | 402 | 2013-02-01 22:08:38 | 1,634,912 | 2021-03-11 15:53:40 | https://stackoverflow.com/q/14655816 | https://stackoverflow.com/a/14655842 | <pre><code>git checkout -b your-new-branch
git add <files>
git commit -m <message>
</code></pre>
<p>First, checkout to your new branch. Then, add all the files you want to commit to staging. Lastly, commit all the files you just added. You might want to do a <code>git push origin your-new-branch</code> afte... | <pre><code>git checkout -b your-new-branch git add <files> git commit -m <message> </code></pre> <p>First, checkout to your new branch. Then, add all the files you want to commit to staging. Lastly, commit all the files you just added. You might want to do a <code>git push origin your-new-branch</code> afte... | 119 | git | <h1>How to commit changes to another pre-existent branch</h1>
<p>I just made changes to a branch. How can I commit the changes to the other branch?</p>
<p>I am trying to use:</p>
<pre><code>git checkout "the commmit to the changed branch" -b "the other branch"
</code></pre>
<p>However, I don't think this is the righ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,471 | git | # How to commit changes to another pre-existent branch
I just made changes to a branch. How can I commit the changes to the other branch?
I am trying to use:
```
git checkout "the commmit to the changed branch" -b "the other branch"
```
However, I don't think this is the right thing to do, because in this case I'm ... | ```
git checkout -b your-new-branch
git add <files>
git commit -m <message>
```
First, checkout to your new branch. Then, add all the files you want to commit to staging. Lastly, commit all the files you just added. You might want to do a `git push origin your-new-branch` afterwards, so your changes show up on the rem... |
7239333 | How do I commit only some files? | 415 | 2011-08-30 06:12:08 | <p>I have two projects. One is the "official" project and the second is a light modification (some files added). I created new branch and I put new files to them. But in during development some files common to both branches is changed.</p>
<p>How do I commit only these files?</p>
| 805,789 | 671,391 | 2024-10-28 13:03:09 | 7,239,454 | 400 | 2011-08-30 06:28:09 | 887,836 | 2017-09-22 21:12:51 | https://stackoverflow.com/q/7239333 | https://stackoverflow.com/a/7239454 | <p>I suppose you want to commit the changes to one branch and then make those changes visible in the other branch. In git you should have no changes on top of HEAD when changing branches.</p>
<p>You commit only the changed files by:</p>
<pre><code>git commit [some files]
</code></pre>
<p>Or if you are sure that you ... | <p>I suppose you want to commit the changes to one branch and then make those changes visible in the other branch. In git you should have no changes on top of HEAD when changing branches.</p> <p>You commit only the changed files by:</p> <pre><code>git commit [some files] </code></pre> <p>Or if you are sure that you ... | 119, 53850, 76220 | git, git-branch, git-commit | <h1>How do I commit only some files?</h1>
<p>I have two projects. One is the "official" project and the second is a light modification (some files added). I created new branch and I put new files to them. But in during development some files common to both branches is changed.</p>
<p>How do I commit only these files?<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,474 | git | # How do I commit only some files?
I have two projects. One is the "official" project and the second is a light modification (some files added). I created new branch and I put new files to them. But in during development some files common to both branches is changed.
How do I commit only these files? | I suppose you want to commit the changes to one branch and then make those changes visible in the other branch. In git you should have no changes on top of HEAD when changing branches.
You commit only the changed files by:
```
git commit [some files]
```
Or if you are sure that you have a clean staging area you can
... |
16343659 | How to show Git log history (i.e., all the related commits) for a sub directory of a Git repository | 365 | 2013-05-02 16:58:06 | <p>Let’s say that I have a Git repository that looks like this:</p>
<pre><code>foo/
.git/
A/
... big tree here
B/
... big tree here
</code></pre>
<p>Is there a way to ask <code>git log</code> to show only the log messages for a specific directory? For example, I want to see what commits touched files in <co... | 241,952 | 438,319 | 2024-08-22 22:11:31 | 16,343,950 | 400 | 2013-05-02 17:15:42 | 1,286,639 | 2024-08-22 22:11:31 | https://stackoverflow.com/q/16343659 | https://stackoverflow.com/a/16343950 | <p>For directory <code>foo/</code>, use</p>
<pre><code> git log -- foo
</code></pre>
<p>You need the '--' to separate <code><path>..</code> from the <code><since>..<until></code> refspecs.</p>
<pre><code># Show changes for src/nvfs
$ git log --oneline -- src/nvfs
d6f6b3b Changes for Mac OS X
803fcc3 ... | <p>For directory <code>foo/</code>, use</p> <pre><code> git log -- foo </code></pre> <p>You need the '--' to separate <code><path>..</code> from the <code><since>..<until></code> refspecs.</p> <pre><code># Show changes for src/nvfs $ git log --oneline -- src/nvfs d6f6b3b Changes for Mac OS X 803fcc3 ... | 119 | git | <h1>How to show Git log history (i.e., all the related commits) for a sub directory of a Git repository</h1>
<p>Let’s say that I have a Git repository that looks like this:</p>
<pre><code>foo/
.git/
A/
... big tree here
B/
... big tree here
</code></pre>
<p>Is there a way to ask <code>git log</code> to show... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,475 | git | # How to show Git log history (i.e., all the related commits) for a sub directory of a Git repository
Let’s say that I have a Git repository that looks like this:
```
foo/
.git/
A/
... big tree here
B/
... big tree here
```
Is there a way to ask `git log` to show only the log messages for a specific dire... | For directory `foo/`, use
```
git log -- foo
```
You need the '--' to separate `<path>..` from the `<since>..<until>` refspecs.
```
# Show changes for src/nvfs
$ git log --oneline -- src/nvfs
d6f6b3b Changes for Mac OS X
803fcc3 Initial Commit
# Show all changes (one additional commit besides in src/nvfs).
$ git ... |
2155887 | Git submodule head 'reference is not a tree' error | 347 | 2010-01-28 16:03:39 | <p>I have a project with a submodule that is pointing to an invalid commit: the submodule commit remained local and when I try to fetch it from another repo I get:</p>
<pre><code>$ git submodule update
fatal: reference is not a tree: 2d7cfbd09fc96c04c4c41148d44ed7778add6b43
Unable to checkout '2d7cfbd09fc96c04c4c41148... | 347,838 | 21,239 | 2023-05-26 17:51:28 | 2,161,389 | 400 | 2010-01-29 10:53:49 | 193,688 | 2021-06-15 18:47:30 | https://stackoverflow.com/q/2155887 | https://stackoverflow.com/a/2161389 | <p>Assuming the submodule's repository does contain a commit you want to use (unlike the commit that is referenced from the current state of the super-project), there are two ways to do it.</p>
<p>The first requires you to already know the commit from the submodule that you want to use. It works from the “inside, out” ... | <p>Assuming the submodule's repository does contain a commit you want to use (unlike the commit that is referenced from the current state of the super-project), there are two ways to do it.</p> <p>The first requires you to already know the commit from the submodule that you want to use. It works from the “inside, out” ... | 119, 41612 | git, git-submodules | <h1>Git submodule head 'reference is not a tree' error</h1>
<p>I have a project with a submodule that is pointing to an invalid commit: the submodule commit remained local and when I try to fetch it from another repo I get:</p>
<pre><code>$ git submodule update
fatal: reference is not a tree: 2d7cfbd09fc96c04c4c41148d... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,476 | git | # Git submodule head 'reference is not a tree' error
I have a project with a submodule that is pointing to an invalid commit: the submodule commit remained local and when I try to fetch it from another repo I get:
```
$ git submodule update
fatal: reference is not a tree: 2d7cfbd09fc96c04c4c41148d44ed7778add6b43
Unab... | Assuming the submodule's repository does contain a commit you want to use (unlike the commit that is referenced from the current state of the super-project), there are two ways to do it.
The first requires you to already know the commit from the submodule that you want to use. It works from the “inside, out” by direct... |
10161198 | Is there a way to "autosign" commits in Git with a GPG key? | 329 | 2012-04-15 10:26:03 | <p>Is there an easy way to make Git always signs each commit or tag that is created?</p>
<p>I tried it with something like:</p>
<pre>alias commit = commit -S</pre>
<p>But that didn't do the trick.</p>
<p>I don't want to install a different program to make this happen. Is it doable with ease?</p>
<p>Just a side que... | 165,425 | 182,868 | 2024-12-10 10:01:02 | 20,628,522 | 400 | 2013-12-17 07:40:05 | 6,309 | 2022-06-12 08:32:39 | https://stackoverflow.com/q/10161198 | https://stackoverflow.com/a/20628522 | <p>Note: if you don't want to add <code>-S</code> all the time to make sure your commits are signed, there is a proposal (branch '<code>pu</code>' for now, December 2013, so no guarantee it will make it to a git release) to add a config which will take care of that option for you.<br />
Update May 2014: it is in Git 2.... | <p>Note: if you don't want to add <code>-S</code> all the time to make sure your commits are signed, there is a proposal (branch '<code>pu</code>' for now, December 2013, so no guarantee it will make it to a git release) to add a config which will take care of that option for you.<br /> Update May 2014: it is in Git 2.... | 119, 6735, 27232 | git, gnupg, public-key-encryption | <h1>Is there a way to "autosign" commits in Git with a GPG key?</h1>
<p>Is there an easy way to make Git always signs each commit or tag that is created?</p>
<p>I tried it with something like:</p>
<pre>alias commit = commit -S</pre>
<p>But that didn't do the trick.</p>
<p>I don't want to install a different program... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,477 | git | # Is there a way to "autosign" commits in Git with a GPG key?
Is there an easy way to make Git always signs each commit or tag that is created?
I tried it with something like:
```
alias commit = commit -S
```
But that didn't do the trick.
I don't want to install a different program to make this happen. Is it doabl... | Note: if you don't want to add `-S` all the time to make sure your commits are signed, there is a proposal (branch '`pu`' for now, December 2013, so no guarantee it will make it to a git release) to add a config which will take care of that option for you.
Update May 2014: it is in Git 2.0 (after being [resend in thi... |
3305869 | Are multiple `.gitignore`s frowned on? | 383 | 2010-07-22 04:56:21 | <p>Unless a repo consisted of several independent projects, it seems it would be simplest to just have one <code>.gitignore</code> file at the root of the repo than various ones throughout. Is there a standard best practice on this or some analysis online of when one approach is better than the other?</p>
| 244,528 | 308,581 | 2022-11-29 00:10:35 | 3,307,252 | 399 | 2010-07-22 09:01:44 | 46,058 | 2019-05-16 15:46:02 | https://stackoverflow.com/q/3305869 | https://stackoverflow.com/a/3307252 | <p>I can think of at least two situations where you would want to have multiple <code>.gitignore</code> files in different (sub)directories.</p>
<ul>
<li><p>Different directories have different types of file to ignore. For example the <code>.gitignore</code> in the top directory of your project ignores generated prog... | <p>I can think of at least two situations where you would want to have multiple <code>.gitignore</code> files in different (sub)directories.</p> <ul> <li><p>Different directories have different types of file to ignore. For example the <code>.gitignore</code> in the top directory of your project ignores generated prog... | 119 | git | <h1>Are multiple `.gitignore`s frowned on?</h1>
<p>Unless a repo consisted of several independent projects, it seems it would be simplest to just have one <code>.gitignore</code> file at the root of the repo than various ones throughout. Is there a standard best practice on this or some analysis online of when one app... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,478 | git | # Are multiple `.gitignore`s frowned on?
Unless a repo consisted of several independent projects, it seems it would be simplest to just have one `.gitignore` file at the root of the repo than various ones throughout. Is there a standard best practice on this or some analysis online of when one approach is better than ... | I can think of at least two situations where you would want to have multiple `.gitignore` files in different (sub)directories.
- Different directories have different types of file to ignore. For example the `.gitignore` in the top directory of your project ignores generated programs, while `Documentation/.gitignore` i... |
8766525 | 'git branch -av' showing remote branch that no longer exists | 201 | 2012-01-07 01:18:00 | <p>This is probably a dumb question, but I'm brand new to git and am seeing a remote branch that no longer exists.</p>
<pre><code>$ git branch -a
* master
remotes/origin/master
remotes/origin/production
</code></pre>
<p>I don't believe the production branch exists remotely and can't figure out why it still shows ... | 31,826 | 226,030 | 2024-08-18 14:19:26 | 8,766,540 | 399 | 2012-01-07 01:21:00 | 526,535 | 2012-01-07 01:21:00 | https://stackoverflow.com/q/8766525 | https://stackoverflow.com/a/8766540 | <p>You have to do:</p>
<pre><code>git remote prune origin
</code></pre>
| <p>You have to do:</p> <pre><code>git remote prune origin </code></pre> | 119 | git | <h1>'git branch -av' showing remote branch that no longer exists</h1>
<p>This is probably a dumb question, but I'm brand new to git and am seeing a remote branch that no longer exists.</p>
<pre><code>$ git branch -a
* master
remotes/origin/master
remotes/origin/production
</code></pre>
<p>I don't believe the prod... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,479 | git | # 'git branch -av' showing remote branch that no longer exists
This is probably a dumb question, but I'm brand new to git and am seeing a remote branch that no longer exists.
```
$ git branch -a
* master
remotes/origin/master
remotes/origin/production
```
I don't believe the production branch exists remotely and... | You have to do:
```
git remote prune origin
``` |
855767 | Can I use git diff on untracked files? | 418 | 2009-05-13 02:20:27 | <p>Is it possible to ask <code>git diff</code> to include untracked files in its diff output, or is my best bet to use <code>git add</code> on the newly created files and the existing files I have edited, then use:</p>
<pre><code>git diff --cached
</code></pre>
| 294,305 | 38,765 | 2025-03-19 11:26:19 | 857,696 | 398 | 2009-05-13 12:33:14 | 85,134 | 2017-06-29 14:43:36 | https://stackoverflow.com/q/855767 | https://stackoverflow.com/a/857696 | <p>With recent git versions you can <code>git add -N</code> the file (or <code>--intent-to-add</code>), which adds a zero-length blob to the index at that location. The upshot is that your "untracked" file now becomes a modification to add all the content to this zero-length file, and that shows up in the "git diff" ou... | <p>With recent git versions you can <code>git add -N</code> the file (or <code>--intent-to-add</code>), which adds a zero-length blob to the index at that location. The upshot is that your "untracked" file now becomes a modification to add all the content to this zero-length file, and that shows up in the "git diff" ou... | 119, 606 | diff, git | <h1>Can I use git diff on untracked files?</h1>
<p>Is it possible to ask <code>git diff</code> to include untracked files in its diff output, or is my best bet to use <code>git add</code> on the newly created files and the existing files I have edited, then use:</p>
<pre><code>git diff --cached
</code></pre>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,480 | git | # Can I use git diff on untracked files?
Is it possible to ask `git diff` to include untracked files in its diff output, or is my best bet to use `git add` on the newly created files and the existing files I have edited, then use:
```
git diff --cached
``` | With recent git versions you can `git add -N` the file (or `--intent-to-add`), which adds a zero-length blob to the index at that location. The upshot is that your "untracked" file now becomes a modification to add all the content to this zero-length file, and that shows up in the "git diff" output.
```
git diff
echo... |
6887228 | Git hangs while writing objects | 169 | 2011-07-31 02:45:09 | <p>I'm trying to <code>git push -u origin master</code> And it just hangs at</p>
<pre><code>Writing objects: 99% (219/220), 12.65 MiB | 97 KiB/s
</code></pre>
<p>The <code>12.65</code> part shifts around. When I exit the process and run it again, it resumes at 99% but never finishes, same as before.</p>
<p>It's nev... | 122,932 | 334,966 | 2025-01-13 16:03:12 | 26,663,047 | 398 | 2014-10-30 20:52:14 | 231,759 | 2019-03-26 13:29:27 | https://stackoverflow.com/q/6887228 | https://stackoverflow.com/a/26663047 | <p>I followed VonC's advice: </p>
<pre><code>git config --global http.postBuffer 524288000
</code></pre>
<hr>
<p>For future references, based on comments:</p>
<pre><code>500 MB: 524288000 (as posted in the original answer)
1 GB: 1048576000
2 GB: 2097152000 (anything higher is rejected as 'out of range')
</code></pr... | <p>I followed VonC's advice: </p> <pre><code>git config --global http.postBuffer 524288000 </code></pre> <hr> <p>For future references, based on comments:</p> <pre><code>500 MB: 524288000 (as posted in the original answer) 1 GB: 1048576000 2 GB: 2097152000 (anything higher is rejected as 'out of range') </code></pr... | 119 | git | <h1>Git hangs while writing objects</h1>
<p>I'm trying to <code>git push -u origin master</code> And it just hangs at</p>
<pre><code>Writing objects: 99% (219/220), 12.65 MiB | 97 KiB/s
</code></pre>
<p>The <code>12.65</code> part shifts around. When I exit the process and run it again, it resumes at 99% but never f... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,484 | git | # Git hangs while writing objects
I'm trying to `git push -u origin master` And it just hangs at
```
Writing objects: 99% (219/220), 12.65 MiB | 97 KiB/s
```
The `12.65` part shifts around. When I exit the process and run it again, it resumes at 99% but never finishes, same as before.
It's never pushed successfull... | I followed VonC's advice:
```
git config --global http.postBuffer 524288000
```
---
For future references, based on comments:
```
500 MB: 524288000 (as posted in the original answer)
1 GB: 1048576000
2 GB: 2097152000 (anything higher is rejected as 'out of range')
``` |
8200622 | How to remove untracked files in Git? | 205 | 2011-11-20 09:30:42 | <p>I'm working on a branch, say "experimental", which I branch out from my master branch. Then, I generate a user model in the experimental branch, but don't add them to the index yet.</p>
<p>What do I have to do if I want to discard all the changes of the files recently added in my experimental branch? The u... | 199,554 | 1,765,871 | 2023-02-28 10:12:25 | 8,200,645 | 397 | 2011-11-20 09:35:27 | 526,535 | 2020-08-13 13:13:30 | https://stackoverflow.com/q/8200622 | https://stackoverflow.com/a/8200645 | <p>To remove untracked files / directories do:</p>
<pre><code>git clean -fdx
</code></pre>
<p>-f - force</p>
<p>-d - directories too</p>
<p>-x - remove ignored files too ( don't use this if you don't want to remove ignored files)</p>
<hr />
<p><strong>Use with Caution!</strong><br />
These commands can permanently dele... | <p>To remove untracked files / directories do:</p> <pre><code>git clean -fdx </code></pre> <p>-f - force</p> <p>-d - directories too</p> <p>-x - remove ignored files too ( don't use this if you don't want to remove ignored files)</p> <hr /> <p><strong>Use with Caution!</strong><br /> These commands can permanently dele... | 119 | git | <h1>How to remove untracked files in Git?</h1>
<p>I'm working on a branch, say "experimental", which I branch out from my master branch. Then, I generate a user model in the experimental branch, but don't add them to the index yet.</p>
<p>What do I have to do if I want to discard all the changes of the files ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,485 | git | # How to remove untracked files in Git?
I'm working on a branch, say "experimental", which I branch out from my master branch. Then, I generate a user model in the experimental branch, but don't add them to the index yet.
What do I have to do if I want to discard all the changes of the files recently added in my expe... | To remove untracked files / directories do:
```
git clean -fdx
```
-f - force
-d - directories too
-x - remove ignored files too ( don't use this if you don't want to remove ignored files)
---
**Use with Caution!**
These commands can permanently delete arbitrary files, that you havn't thought of at first. Pleas... |
3878624 | How do I programmatically determine if there are uncommitted changes? | 373 | 2010-10-07 04:16:13 | <p>In a Makefile, I'd like to perform certain actions if there are uncommitted changes (either in the working tree or the index). What's the cleanest and most efficient way to do that? A command that exits with a return value of zero in one case and non-zero in the other would suit my purposes.</p>
<p>I can run <cod... | 179,002 | 219,162 | 2025-05-30 06:40:42 | 3,879,077 | 396 | 2010-10-07 05:58:57 | 6,309 | 2023-10-30 06:35:39 | https://stackoverflow.com/q/3878624 | https://stackoverflow.com/a/3879077 | <p><strong>UPDATES</strong>:</p>
<ul>
<li><p><a href="https://stackoverflow.com/users/454780/trusktr">trusktr</a> mentions in <a href="https://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommitted-changes/3879077#comment136425825_3878934">the comments</a> of <a href="https://s... | <p><strong>UPDATES</strong>:</p> <ul> <li><p><a href="https://stackoverflow.com/users/454780/trusktr">trusktr</a> mentions in <a href="https://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommitted-changes/3879077#comment136425825_3878934">the comments</a> of <a href="https://s... | 119 | git | <h1>How do I programmatically determine if there are uncommitted changes?</h1>
<p>In a Makefile, I'd like to perform certain actions if there are uncommitted changes (either in the working tree or the index). What's the cleanest and most efficient way to do that? A command that exits with a return value of zero in on... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,486 | git | # How do I programmatically determine if there are uncommitted changes?
In a Makefile, I'd like to perform certain actions if there are uncommitted changes (either in the working tree or the index). What's the cleanest and most efficient way to do that? A command that exits with a return value of zero in one case and ... | **UPDATES**:
- [trusktr](https://stackoverflow.com/users/454780/trusktr) mentions in [the comments](https://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommitted-changes/3879077#comment136425825_3878934) of [Josh Lee](https://stackoverflow.com/users/19750/josh-lee)'s [answer]... |
30875205 | Restore a deleted folder in a Git repo | 172 | 2015-06-16 18:18:23 | <p>I have deleted all the contents inside a folder and the folder is empty. I still had a copy in my remote repo. But when I did a <code>git pull</code> it didn't put back the deleted files, isn't it supposed to do that?</p>
<p>So I did some research and saw that you can revert a file by doing:</p>
<pre><code>git check... | 189,621 | 4,778,668 | 2025-06-13 12:43:30 | 30,875,442 | 396 | 2015-06-16 18:31:25 | 2,790,048 | 2024-09-03 10:39:08 | https://stackoverflow.com/q/30875205 | https://stackoverflow.com/a/30875442 | <h2>Folder was deleted, but not committed yet</h2>
<p>Everything you can do with a file, you can do with a folder too.</p>
<p>If you've just recently removed the folder but have not yet indexed (<code>git add</code>) the changes, you can undo the changes with one command:</p>
<pre><code>git checkout -- path/to/folder
<... | <h2>Folder was deleted, but not committed yet</h2> <p>Everything you can do with a file, you can do with a folder too.</p> <p>If you've just recently removed the folder but have not yet indexed (<code>git add</code>) the changes, you can undo the changes with one command:</p> <pre><code>git checkout -- path/to/folder <... | 119, 37230 | git, git-checkout | <h1>Restore a deleted folder in a Git repo</h1>
<p>I have deleted all the contents inside a folder and the folder is empty. I still had a copy in my remote repo. But when I did a <code>git pull</code> it didn't put back the deleted files, isn't it supposed to do that?</p>
<p>So I did some research and saw that you can ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,487 | git | # Restore a deleted folder in a Git repo
I have deleted all the contents inside a folder and the folder is empty. I still had a copy in my remote repo. But when I did a `git pull` it didn't put back the deleted files, isn't it supposed to do that?
So I did some research and saw that you can revert a file by doing:
`... | ## Folder was deleted, but not committed yet
Everything you can do with a file, you can do with a folder too.
If you've just recently removed the folder but have not yet indexed (`git add`) the changes, you can undo the changes with one command:
```
git checkout -- path/to/folder
```
If you have already done `git a... |
27226886 | How to abort a git rebase from inside vim during interactive editing | 211 | 2014-12-01 10:58:21 | <p>When I do an interactive rebase, e.g.</p>
<pre><code>git rebase -i HEAD~3
</code></pre>
<p>the rebase interactive editor (vim in my case) opens to let me edit the commits to rebase</p>
<pre><code>pick c843ea2 Set Vim column limit to 80 (OS X)
pick fc32eac Add Bash alias for `pbcopy` (OS X)
....
</code></pre>
<p>... | 86,230 | 974,186 | 2024-03-11 08:34:09 | 29,419,286 | 395 | 2015-04-02 17:48:46 | 1,538,199 | 2018-05-04 16:01:07 | https://stackoverflow.com/q/27226886 | https://stackoverflow.com/a/29419286 | <p>If you exit the editor with an error code, the rebase will be aborted.</p>
<p>To exit with an error code on vim, do</p>
<pre><code>:cq
</code></pre>
<p>See <a href="https://stackoverflow.com/questions/16595908/git-exit-vim-without-commiting">here</a> and vimdoc <a href="http://vimdoc.sourceforge.net/htmldoc/quick... | <p>If you exit the editor with an error code, the rebase will be aborted.</p> <p>To exit with an error code on vim, do</p> <pre><code>:cq </code></pre> <p>See <a href="https://stackoverflow.com/questions/16595908/git-exit-vim-without-commiting">here</a> and vimdoc <a href="http://vimdoc.sourceforge.net/htmldoc/quick... | 119, 370, 29934 | git, git-rebase, vim | <h1>How to abort a git rebase from inside vim during interactive editing</h1>
<p>When I do an interactive rebase, e.g.</p>
<pre><code>git rebase -i HEAD~3
</code></pre>
<p>the rebase interactive editor (vim in my case) opens to let me edit the commits to rebase</p>
<pre><code>pick c843ea2 Set Vim column limit to 80 ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,488 | git | # How to abort a git rebase from inside vim during interactive editing
When I do an interactive rebase, e.g.
```
git rebase -i HEAD~3
```
the rebase interactive editor (vim in my case) opens to let me edit the commits to rebase
```
pick c843ea2 Set Vim column limit to 80 (OS X)
pick fc32eac Add Bash alias for `pbco... | If you exit the editor with an error code, the rebase will be aborted.
To exit with an error code on vim, do
```
:cq
```
See [here](https://stackoverflow.com/questions/16595908/git-exit-vim-without-commiting) and vimdoc [here](http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:cq). |
46941346 | How to know the git username and email saved during configuration? | 880 | 2017-10-25 20:17:42 | <p>While configuring <code>git</code> I ran these two commands:</p>
<pre><code>git config --global user.name "My Name"
git config --global user.email "myemail@example.com"
</code></pre>
<p>However, I doubt whether I made a typo or not. So, is there any command to know the <strong>name</strong> and <strong>email</str... | 2,263,665 | 8,821,451 | 2024-07-29 21:26:15 | 46,941,650 | 394 | 2017-10-25 20:38:21 | 8,821,451 | 2023-04-28 22:30:17 | https://stackoverflow.com/q/46941346 | https://stackoverflow.com/a/46941650 | <p>Considering what <a href="https://stackoverflow.com/a/46941431">@Robert said</a>, I tried to play around with the <code>config</code> command and it seems that there is a direct way to know both the name and email.</p>
<p>To know the username, type:</p>
<pre><code>git config user.name
</code></pre>
<p>To know the em... | <p>Considering what <a href="https://stackoverflow.com/a/46941431">@Robert said</a>, I tried to play around with the <code>config</code> command and it seems that there is a direct way to know both the name and email.</p> <p>To know the username, type:</p> <pre><code>git config user.name </code></pre> <p>To know the em... | 119, 32868 | git, git-config | <h1>How to know the git username and email saved during configuration?</h1>
<p>While configuring <code>git</code> I ran these two commands:</p>
<pre><code>git config --global user.name "My Name"
git config --global user.email "myemail@example.com"
</code></pre>
<p>However, I doubt whether I made a typo or not. So, i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,489 | git | # How to know the git username and email saved during configuration?
While configuring `git` I ran these two commands:
```
git config --global user.name "My Name"
git config --global user.email "myemail@example.com"
```
However, I doubt whether I made a typo or not. So, is there any command to know the **name** and... | Considering what [@Robert said](https://stackoverflow.com/a/46941431), I tried to play around with the `config` command and it seems that there is a direct way to know both the name and email.
To know the username, type:
```
git config user.name
```
To know the email, type:
```
git config user.email
```
These two ... |
3559076 | How to get back to most recent version in Git? | 327 | 2010-08-24 17:16:07 | <p>I have recently moved from SVN to Git and am a bit confused about something. I needed to run the previous version of a script through a debugger, so I did <code>git checkout <previous version hash></code> and did what I needed to do.</p>
<p>Now I want to get back to the newest version, but I don't know the ha... | 334,229 | 4,376 | 2020-01-05 19:54:56 | 3,559,096 | 394 | 2010-08-24 17:17:29 | 5,728 | 2010-08-24 17:17:29 | https://stackoverflow.com/q/3559076 | https://stackoverflow.com/a/3559096 | <p><code>git checkout master</code> should do the trick. To go back two versions, you could say something like <code>git checkout HEAD~2</code>, but better to create a temporary branch <em>based</em> on that time, so <code>git checkout -b temp_branch HEAD~2</code></p>
| <p><code>git checkout master</code> should do the trick. To go back two versions, you could say something like <code>git checkout HEAD~2</code>, but better to create a temporary branch <em>based</em> on that time, so <code>git checkout -b temp_branch HEAD~2</code></p> | 119, 37230 | git, git-checkout | <h1>How to get back to most recent version in Git?</h1>
<p>I have recently moved from SVN to Git and am a bit confused about something. I needed to run the previous version of a script through a debugger, so I did <code>git checkout <previous version hash></code> and did what I needed to do.</p>
<p>Now I want to... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,490 | git | # How to get back to most recent version in Git?
I have recently moved from SVN to Git and am a bit confused about something. I needed to run the previous version of a script through a debugger, so I did `git checkout <previous version hash>` and did what I needed to do.
Now I want to get back to the newest version, ... | `git checkout master` should do the trick. To go back two versions, you could say something like `git checkout HEAD~2`, but better to create a temporary branch *based* on that time, so `git checkout -b temp_branch HEAD~2` |
8633981 | What does "Auto packing the repository for optimum performance" mean? | 306 | 2011-12-26 08:03:54 | <p>I'm having a problem with my git repo. For the last couple of days whenever I do a push to the server I get this message: "Auto packing the repository for optimum performance", and it does not seem to go away and return the shell.</p>
<p>I also tried checking out to a new branch and then doing a rebase on my previo... | 111,733 | 271,590 | 2024-10-23 00:37:24 | 8,638,219 | 393 | 2011-12-26 18:31:46 | 119,963 | 2011-12-26 18:31:46 | https://stackoverflow.com/q/8633981 | https://stackoverflow.com/a/8638219 | <p>Short version: it means what it says, and if you just let it finish, all will be well.</p>
<p>During most operations which can potentially increase the number of loose (unpacked) objects in the repository (including pushes), Git invokes <code>git gc --auto</code>. If there are enough loose objects (by default, at l... | <p>Short version: it means what it says, and if you just let it finish, all will be well.</p> <p>During most operations which can potentially increase the number of loose (unpacked) objects in the repository (including pushes), Git invokes <code>git gc --auto</code>. If there are enough loose objects (by default, at l... | 119, 28898, 29934 | git, git-push, git-rebase | <h1>What does "Auto packing the repository for optimum performance" mean?</h1>
<p>I'm having a problem with my git repo. For the last couple of days whenever I do a push to the server I get this message: "Auto packing the repository for optimum performance", and it does not seem to go away and return the shell.</p>
<p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,491 | git | # What does "Auto packing the repository for optimum performance" mean?
I'm having a problem with my git repo. For the last couple of days whenever I do a push to the server I get this message: "Auto packing the repository for optimum performance", and it does not seem to go away and return the shell.
I also tried ch... | Short version: it means what it says, and if you just let it finish, all will be well.
During most operations which can potentially increase the number of loose (unpacked) objects in the repository (including pushes), Git invokes `git gc --auto`. If there are enough loose objects (by default, at least 6700), it will t... |
8951275 | How can I make Sublime Text the default editor for Git? | 249 | 2012-01-21 06:52:03 | <p>I have a problem setting Sublime Text 2 as the <code>core.editor</code> with <code>git</code>.</p>
<p>I've read through every post I could find addressing the problem, but still nothing is working for me. I am running Windows.</p>
<p>I have done:</p>
<pre><code>git config --global core.editor "'C:/Program Files/S... | 113,293 | 1,161,982 | 2025-08-05 14:45:50 | 9,408,117 | 392 | 2012-02-23 06:18:02 | 49,914 | 2016-12-30 18:30:28 | https://stackoverflow.com/q/8951275 | https://stackoverflow.com/a/9408117 | <h2>Windows</h2>
<h3>Sublime Text 2 (Build 2181)</h3>
<p>The latest <a href="http://www.sublimetext.com/blog/articles/sublime-text-2-build-2181" rel="noreferrer">Build 2181</a> just added support for the <code>-w</code> (wait) command line argument. The following configuration will allow ST2 to work as your default g... | <h2>Windows</h2> <h3>Sublime Text 2 (Build 2181)</h3> <p>The latest <a href="http://www.sublimetext.com/blog/articles/sublime-text-2-build-2181" rel="noreferrer">Build 2181</a> just added support for the <code>-w</code> (wait) command line argument. The following configuration will allow ST2 to work as your default g... | 119, 3070, 5025, 32868, 72788 | default, editor, git, git-config, sublimetext | <h1>How can I make Sublime Text the default editor for Git?</h1>
<p>I have a problem setting Sublime Text 2 as the <code>core.editor</code> with <code>git</code>.</p>
<p>I've read through every post I could find addressing the problem, but still nothing is working for me. I am running Windows.</p>
<p>I have done:</p>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,492 | git | # How can I make Sublime Text the default editor for Git?
I have a problem setting Sublime Text 2 as the `core.editor` with `git`.
I've read through every post I could find addressing the problem, but still nothing is working for me. I am running Windows.
I have done:
```
git config --global core.editor "'C:/Progra... | ## Windows
### Sublime Text 2 (Build 2181)
The latest [Build 2181](http://www.sublimetext.com/blog/articles/sublime-text-2-build-2181) just added support for the `-w` (wait) command line argument. The following configuration will allow ST2 to work as your default git editor on Windows. This will allow git to open ST2... |
2227062 | How do I move a Git branch out into its own repository? | 242 | 2010-02-09 05:50:08 | <p>I have a branch that I'd like to move into a separate Git repository, and ideally keep that branch's history in the process. So far I've been looking at <code>git filter-branch</code>, but I can't make out whether it can do what I want to do.</p>
<p>How do I extract a Git branch out into its own repository?</p>
| 96,203 | 10,407 | 2021-01-20 11:21:58 | 2,227,571 | 392 | 2010-02-09 07:59:39 | 19,563 | 2017-04-26 21:05:36 | https://stackoverflow.com/q/2227062 | https://stackoverflow.com/a/2227571 | <p>You can simply push a branch to a new repository. All of its history will go with it. You can then choose whether to delete the branch from the original repository.</p>
<p>e.g.</p>
<pre><code>git push url://to/new/repository.git branch-to-move:new-branch-name
</code></pre>
<p>For a new repository, new-branch-name... | <p>You can simply push a branch to a new repository. All of its history will go with it. You can then choose whether to delete the branch from the original repository.</p> <p>e.g.</p> <pre><code>git push url://to/new/repository.git branch-to-move:new-branch-name </code></pre> <p>For a new repository, new-branch-name... | 119, 1879, 5352 | branch, extract, git | <h1>How do I move a Git branch out into its own repository?</h1>
<p>I have a branch that I'd like to move into a separate Git repository, and ideally keep that branch's history in the process. So far I've been looking at <code>git filter-branch</code>, but I can't make out whether it can do what I want to do.</p>
<p>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,493 | git | # How do I move a Git branch out into its own repository?
I have a branch that I'd like to move into a separate Git repository, and ideally keep that branch's history in the process. So far I've been looking at `git filter-branch`, but I can't make out whether it can do what I want to do.
How do I extract a Git branc... | You can simply push a branch to a new repository. All of its history will go with it. You can then choose whether to delete the branch from the original repository.
e.g.
```
git push url://to/new/repository.git branch-to-move:new-branch-name
```
For a new repository, new-branch-name is typically master.
Creating a ... |
2006032 | View differences of branches with meld? | 196 | 2010-01-05 12:44:18 | <p>I know that I can view the difference between HEAD and current state with <code>meld .</code>. But how can I view the differences between branches, for example <code>master</code> and <code>devel</code> with meld?</p>
<p>At the moment I do the following steps:</p>
<ol>
<li>Rename folder of working copy<br/>
Fo... | 121,631 | 236,835 | 2025-11-28 11:42:12 | 2,006,241 | 392 | 2010-01-05 13:21:42 | 2,988 | 2025-11-28 11:42:12 | https://stackoverflow.com/q/2006032 | https://stackoverflow.com/a/2006241 | <p>Git allows launching a graphical diff tool instead of the textual one by running <code>git difftool</code> instead of <code>git diff</code>.</p>
<p>Set up which graphical tool to use:</p>
<pre><code>git config --global diff.tool meld
</code></pre>
<p>To get the differences between two branches as between two folders... | <p>Git allows launching a graphical diff tool instead of the textual one by running <code>git difftool</code> instead of <code>git diff</code>.</p> <p>Set up which graphical tool to use:</p> <pre><code>git config --global diff.tool meld </code></pre> <p>To get the differences between two branches as between two folders... | 119, 606, 1879, 13630 | branch, diff, git, meld | <h1>View differences of branches with meld?</h1>
<p>I know that I can view the difference between HEAD and current state with <code>meld .</code>. But how can I view the differences between branches, for example <code>master</code> and <code>devel</code> with meld?</p>
<p>At the moment I do the following steps:</p>
<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,494 | git | # View differences of branches with meld?
I know that I can view the difference between HEAD and current state with `meld .`. But how can I view the differences between branches, for example `master` and `devel` with meld?
At the moment I do the following steps:
1. Rename folder of working copy
For example `mv ... | Git allows launching a graphical diff tool instead of the textual one by running `git difftool` instead of `git diff`.
Set up which graphical tool to use:
```
git config --global diff.tool meld
```
To get the differences between two branches as between two folders:
```
git difftool -d master..devel
```
Note withou... |
2825428 | Why should I use core.autocrlf=true in Git? | 482 | 2010-05-13 08:50:11 | <p>I have a Git repository that is accessed from both Windows and OS X, and that I know already contains some files with CRLF line-endings. As far as I can tell, there are two ways to deal with this:</p>
<ol>
<li><p>Set <code>core.autocrlf</code> to <code>false</code> everywhere,</p></li>
<li><p>Follow the instruction... | 544,649 | 328,936 | 2025-02-19 13:49:45 | 2,825,829 | 391 | 2010-05-13 09:55:15 | 6,309 | 2019-11-01 08:48:56 | https://stackoverflow.com/q/2825428 | https://stackoverflow.com/a/2825829 | <p>The only specific reasons to set <code>autocrlf</code> to <code>true</code> are:</p>
<ul>
<li>avoid <code>git status</code> showing all your files as <code>modified</code> because of the automatic EOL conversion done when cloning a Unix-based EOL Git repo to a Windows one (see <a href="http://web.archive.org/web/20... | <p>The only specific reasons to set <code>autocrlf</code> to <code>true</code> are:</p> <ul> <li>avoid <code>git status</code> showing all your files as <code>modified</code> because of the automatic EOL conversion done when cloning a Unix-based EOL Git repo to a Windows one (see <a href="http://web.archive.org/web/20... | 119, 8329 | git, line-endings | <h1>Why should I use core.autocrlf=true in Git?</h1>
<p>I have a Git repository that is accessed from both Windows and OS X, and that I know already contains some files with CRLF line-endings. As far as I can tell, there are two ways to deal with this:</p>
<ol>
<li><p>Set <code>core.autocrlf</code> to <code>false</cod... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,495 | git | # Why should I use core.autocrlf=true in Git?
I have a Git repository that is accessed from both Windows and OS X, and that I know already contains some files with CRLF line-endings. As far as I can tell, there are two ways to deal with this:
1. Set `core.autocrlf` to `false` everywhere,
2. Follow the instructions [h... | The only specific reasons to set `autocrlf` to `true` are:
- avoid `git status` showing all your files as `modified` because of the automatic EOL conversion done when cloning a Unix-based EOL Git repo to a Windows one (see [issue 83](http://web.archive.org/web/20100526033050/http://code.google.com/p/msysgit/issues/det... |
4185365 | No submodule mapping found in .gitmodule for a path that's not a submodule | 442 | 2010-11-15 14:38:56 | <p>I have a project that has a submodule at <code>lib/three20</code></p>
<p>My <code>.gitmodule</code> file looks like this:</p>
<pre><code>[submodule "lib/three20"]
path = lib/three20
url = git://github.com/facebook/three20.git
</code></pre>
<p>I have cloned this in the past without errors, (<code>git submo... | 398,902 | 3,381 | 2026-01-24 04:42:45 | 4,185,579 | 391 | 2010-11-15 14:58:48 | 6,309 | 2025-01-02 07:21:16 | https://stackoverflow.com/q/4185365 | https://stackoverflow.com/a/4185579 | <p>Following <a href="https://stackoverflow.com/users/769228/rajibchowdhury">rajibchowdhury</a>'s <a href="https://stackoverflow.com/a/13394710/6309">answer</a> (upvoted), <strong>use <code>git rm</code></strong> command which is advised is for removing the <a href="https://stackoverflow.com/a/2227598/6309"><strong>spe... | <p>Following <a href="https://stackoverflow.com/users/769228/rajibchowdhury">rajibchowdhury</a>'s <a href="https://stackoverflow.com/a/13394710/6309">answer</a> (upvoted), <strong>use <code>git rm</code></strong> command which is advised is for removing the <a href="https://stackoverflow.com/a/2227598/6309"><strong>spe... | 119, 41612 | git, git-submodules | <h1>No submodule mapping found in .gitmodule for a path that's not a submodule</h1>
<p>I have a project that has a submodule at <code>lib/three20</code></p>
<p>My <code>.gitmodule</code> file looks like this:</p>
<pre><code>[submodule "lib/three20"]
path = lib/three20
url = git://github.com/facebook/three20.g... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,496 | git | # No submodule mapping found in .gitmodule for a path that's not a submodule
I have a project that has a submodule at `lib/three20`
My `.gitmodule` file looks like this:
```
[submodule "lib/three20"]
path = lib/three20
url = git://github.com/facebook/three20.git
```
I have cloned this in the past without er... | Following [rajibchowdhury](https://stackoverflow.com/users/769228/rajibchowdhury)'s [answer](https://stackoverflow.com/a/13394710/6309) (upvoted), **use `git rm`** command which is advised is for removing the [**special entry** in the index indicating a submodule](https://stackoverflow.com/a/2227598/6309) (a 'folder' w... |
21353656 | Merge git repo into branch of another repo | 226 | 2014-01-25 17:21:11 | <p>Given repo Foo and repo Bar. I want to merge Bar with Foo, <em>but</em> only into a separate branch, called <code>baz</code>.</p>
<p><code>git switch -c baz</code> <= put the Bar repo here.</p>
| 196,595 | 296,155 | 2025-09-04 11:05:21 | 21,353,836 | 390 | 2014-01-25 17:34:05 | 147,356 | 2024-03-19 23:58:14 | https://stackoverflow.com/q/21353656 | https://stackoverflow.com/a/21353836 | <p>You can't merge a <em>repository</em> into a <em>branch</em>. You can merge a <em>branch</em> from another repository into a <em>branch</em> in your local repository.</p>
<p>Assuming that you have two repositories, <code>base-repo</code> and <code>other-repo</code>, where you want to merge other-repo into base-repo... | <p>You can't merge a <em>repository</em> into a <em>branch</em>. You can merge a <em>branch</em> from another repository into a <em>branch</em> in your local repository.</p> <p>Assuming that you have two repositories, <code>base-repo</code> and <code>other-repo</code>, where you want to merge other-repo into base-repo... | 119 | git | <h1>Merge git repo into branch of another repo</h1>
<p>Given repo Foo and repo Bar. I want to merge Bar with Foo, <em>but</em> only into a separate branch, called <code>baz</code>.</p>
<p><code>git switch -c baz</code> <= put the Bar repo here.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,497 | git | # Merge git repo into branch of another repo
Given repo Foo and repo Bar. I want to merge Bar with Foo, *but* only into a separate branch, called `baz`.
`git switch -c baz` <= put the Bar repo here. | You can't merge a *repository* into a *branch*. You can merge a *branch* from another repository into a *branch* in your local repository.
Assuming that you have two repositories, `base-repo` and `other-repo`, where you want to merge other-repo into base-repo:
Change into the `base-repo` repository:
```
$ cd base-re... |
457927 | Git workflow and rebase vs merge questions | 1,046 | 2009-01-19 15:16:52 | <p>I've been using Git now for a couple of months on a project with one other developer. I have several years of experience with <a href="http://en.wikipedia.org/wiki/Apache_Subversion" rel="noreferrer">SVN</a>, so I guess I bring a lot of baggage to the relationship.</p>
<p>I have heard that Git is excellent for bran... | 236,360 | 19,964 | 2021-03-16 09:48:47 | 457,988 | 389 | 2009-01-19 15:32:24 | 6,309 | 2020-01-05 20:40:49 | https://stackoverflow.com/q/457927 | https://stackoverflow.com/a/457988 | <p>"Conflicts" mean "parallel evolutions of a same content". So if it goes "all to hell" during a merge, it means you have massive evolutions on the same set of files.</p>
<p>The reason why a rebase is then better than a merge is that:</p>
<ul>
<li>you rewrite your local commit history with the one of the master (and... | <p>"Conflicts" mean "parallel evolutions of a same content". So if it goes "all to hell" during a merge, it means you have massive evolutions on the same set of files.</p> <p>The reason why a rebase is then better than a merge is that:</p> <ul> <li>you rewrite your local commit history with the one of the master (and... | 119, 456, 28897, 29934 | git, git-merge, git-rebase, version-control | <h1>Git workflow and rebase vs merge questions</h1>
<p>I've been using Git now for a couple of months on a project with one other developer. I have several years of experience with <a href="http://en.wikipedia.org/wiki/Apache_Subversion" rel="noreferrer">SVN</a>, so I guess I bring a lot of baggage to the relationship.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,498 | git | # Git workflow and rebase vs merge questions
I've been using Git now for a couple of months on a project with one other developer. I have several years of experience with [SVN](http://en.wikipedia.org/wiki/Apache_Subversion), so I guess I bring a lot of baggage to the relationship.
I have heard that Git is excellent ... | "Conflicts" mean "parallel evolutions of a same content". So if it goes "all to hell" during a merge, it means you have massive evolutions on the same set of files.
The reason why a rebase is then better than a merge is that:
- you rewrite your local commit history with the one of the master (and then reapply your wo... |
2641146 | Handling file renames in Git | 532 | 2010-04-14 21:23:09 | <p>I'd read that when <a href="https://bauermann.wordpress.com/2008/01/03/take-care-when-renaming-files-in-git/" rel="noreferrer">renaming files in Git</a>, you should commit any changes, perform your rename and then stage your renamed file. Git will recognise the file from the contents, rather than seeing it as a new ... | 524,671 | 122,075 | 2023-11-21 08:46:42 | 2,641,227 | 389 | 2010-04-14 21:35:39 | 52,444 | 2021-04-13 07:17:59 | https://stackoverflow.com/q/2641146 | https://stackoverflow.com/a/2641227 | <p>For <code>git mv</code> <a href="http://kernel.org/pub/software/scm/git/docs/git-mv.html" rel="noreferrer">the manual page</a> says</p>
<blockquote>
<p>The index is updated after successful completion,
[…]</p>
</blockquote>
<p>So, at first, you have to update the index on your own
(by using <code>git add mobile.css<... | <p>For <code>git mv</code> <a href="http://kernel.org/pub/software/scm/git/docs/git-mv.html" rel="noreferrer">the manual page</a> says</p> <blockquote> <p>The index is updated after successful completion, […]</p> </blockquote> <p>So, at first, you have to update the index on your own (by using <code>git add mobile.css<... | 119, 112902 | git, git-mv | <h1>Handling file renames in Git</h1>
<p>I'd read that when <a href="https://bauermann.wordpress.com/2008/01/03/take-care-when-renaming-files-in-git/" rel="noreferrer">renaming files in Git</a>, you should commit any changes, perform your rename and then stage your renamed file. Git will recognise the file from the con... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,499 | git | # Handling file renames in Git
I'd read that when [renaming files in Git](https://bauermann.wordpress.com/2008/01/03/take-care-when-renaming-files-in-git/), you should commit any changes, perform your rename and then stage your renamed file. Git will recognise the file from the contents, rather than seeing it as a new... | For `git mv` [the manual page](http://kernel.org/pub/software/scm/git/docs/git-mv.html) says
> The index is updated after successful completion,
> […]
So, at first, you have to update the index on your own
(by using `git add mobile.css`). However `git status`
will still show two different files:
```
$ git status
# O... |
38512124 | How to remove branches already deleted on GitHub that still show up in VS Code? | 256 | 2016-07-21 18:46:52 | <p>In VS Code, after I do a pull request and delete the branch on GitHub, that branch still shows up in Visual Studio Code. If I select the branch, it gives an Error, as expected.</p>
<p>How do I remove these now-deleted branches from VS Code. Can it be done automatically?</p>
| 270,018 | 271,012 | 2025-12-30 14:30:13 | 44,854,800 | 389 | 2017-06-30 21:04:28 | 6,496,010 | 2017-12-07 09:10:20 | https://stackoverflow.com/q/38512124 | https://stackoverflow.com/a/44854800 | <p>Apparently, this feature is intentional. I found out that a correct way to remove all remote branches that have been deleted from Github is to run the following command.</p>
<pre><code>git fetch --prune
</code></pre>
<p>Then restart visual studio to remove the branches from the command palette </p>
| <p>Apparently, this feature is intentional. I found out that a correct way to remove all remote branches that have been deleted from Github is to run the following command.</p> <pre><code>git fetch --prune </code></pre> <p>Then restart visual studio to remove the branches from the command palette </p> | 119, 111608 | git, visual-studio-code | <h1>How to remove branches already deleted on GitHub that still show up in VS Code?</h1>
<p>In VS Code, after I do a pull request and delete the branch on GitHub, that branch still shows up in Visual Studio Code. If I select the branch, it gives an Error, as expected.</p>
<p>How do I remove these now-deleted branches f... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,500 | git | # How to remove branches already deleted on GitHub that still show up in VS Code?
In VS Code, after I do a pull request and delete the branch on GitHub, that branch still shows up in Visual Studio Code. If I select the branch, it gives an Error, as expected.
How do I remove these now-deleted branches from VS Code. Ca... | Apparently, this feature is intentional. I found out that a correct way to remove all remote branches that have been deleted from Github is to run the following command.
```
git fetch --prune
```
Then restart visual studio to remove the branches from the command palette |
2474097 | How do I finish the merge after resolving my merge conflicts? | 446 | 2010-03-18 23:43:08 | <p>I've read the <a href="https://book.git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging" rel="noreferrer">Basic Branching and Merging</a> section of the Git Community Book.</p>
<p>So I follow it and create one branch: <code>experimental</code>.</p>
<p>Then I:</p>
<ol>
<li>switch to experimental branc... | 695,756 | 286,802 | 2025-12-08 07:40:39 | 2,474,139 | 387 | 2010-03-18 23:52:38 | 242,493 | 2021-03-19 12:47:28 | https://stackoverflow.com/q/2474097 | https://stackoverflow.com/a/2474139 | <p>When there is a conflict during a merge, you have to finish the merge commit manually. It sounds like you've done the first two steps, to edit the files that conflicted and then run <code>git add</code> on them to mark them as resolved. Finally, you need to actually commit the merge with <code>git commit</code>. At ... | <p>When there is a conflict during a merge, you have to finish the merge commit manually. It sounds like you've done the first two steps, to edit the files that conflicted and then run <code>git add</code> on them to mark them as resolved. Finally, you need to actually commit the merge with <code>git commit</code>. At ... | 119, 28897 | git, git-merge | <h1>How do I finish the merge after resolving my merge conflicts?</h1>
<p>I've read the <a href="https://book.git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging" rel="noreferrer">Basic Branching and Merging</a> section of the Git Community Book.</p>
<p>So I follow it and create one branch: <code>experime... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,501 | git | # How do I finish the merge after resolving my merge conflicts?
I've read the [Basic Branching and Merging](https://book.git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging) section of the Git Community Book.
So I follow it and create one branch: `experimental`.
Then I:
1. switch to experimental branch... | When there is a conflict during a merge, you have to finish the merge commit manually. It sounds like you've done the first two steps, to edit the files that conflicted and then run `git add` on them to mark them as resolved. Finally, you need to actually commit the merge with `git commit`. At that point you will be ab... |
1265040 | How to count total lines changed by a specific author in a Git repository? | 654 | 2009-08-12 08:59:44 | <p>Is there a command I can invoke which will count the lines changed by a specific author in a Git repository? I know that there must be ways to count the number of commits as Github does this for their Impact graph.</p>
| 504,475 | 135,722 | 2025-10-23 21:04:37 | 1,265,229 | 385 | 2009-08-12 09:46:24 | 19,563 | 2009-08-12 12:32:30 | https://stackoverflow.com/q/1265040 | https://stackoverflow.com/a/1265229 | <p>The output of the following command should be reasonably easy to send to script to add up the totals:</p>
<pre><code>git log --author="<authorname>" --oneline --shortstat
</code></pre>
<p>This gives stats for all commits on the current HEAD. If you want to add up stats in other branches you will have to supp... | <p>The output of the following command should be reasonably easy to send to script to add up the totals:</p> <pre><code>git log --author="<authorname>" --oneline --shortstat </code></pre> <p>This gives stats for all commits on the current HEAD. If you want to add up stats in other branches you will have to supp... | 119, 1231, 7330 | command-line, git, repository | <h1>How to count total lines changed by a specific author in a Git repository?</h1>
<p>Is there a command I can invoke which will count the lines changed by a specific author in a Git repository? I know that there must be ways to count the number of commits as Github does this for their Impact graph.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,502 | git | # How to count total lines changed by a specific author in a Git repository?
Is there a command I can invoke which will count the lines changed by a specific author in a Git repository? I know that there must be ways to count the number of commits as Github does this for their Impact graph. | The output of the following command should be reasonably easy to send to script to add up the totals:
```
git log --author="<authorname>" --oneline --shortstat
```
This gives stats for all commits on the current HEAD. If you want to add up stats in other branches you will have to supply them as arguments to `git log`... |
6648995 | How to create a remote Git repository from a local one? | 347 | 2011-07-11 10:50:32 | <p>I have a local Git repository. I would like to make it available on a remote, ssh-enabled, server. How do I do this?</p>
| 421,657 | 671,391 | 2024-09-30 19:33:37 | 6,649,016 | 385 | 2011-07-11 10:53:27 | 596,781 | 2013-09-03 09:52:57 | https://stackoverflow.com/q/6648995 | https://stackoverflow.com/a/6649016 | <p>I think you make a bare repository on the remote side, <code>git init --bare</code>, add the remote side as the push/pull tracker for your local repository (<code>git remote add origin URL</code>), and then locally you just say <code>git push origin master</code>. Now any other repository can <code>pull</code> from ... | <p>I think you make a bare repository on the remote side, <code>git init --bare</code>, add the remote side as the push/pull tracker for your local repository (<code>git remote add origin URL</code>), and then locally you just say <code>git push origin master</code>. Now any other repository can <code>pull</code> from ... | 119, 529, 41346 | git, git-remote, installation | <h1>How to create a remote Git repository from a local one?</h1>
<p>I have a local Git repository. I would like to make it available on a remote, ssh-enabled, server. How do I do this?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,503 | git | # How to create a remote Git repository from a local one?
I have a local Git repository. I would like to make it available on a remote, ssh-enabled, server. How do I do this? | I think you make a bare repository on the remote side, `git init --bare`, add the remote side as the push/pull tracker for your local repository (`git remote add origin URL`), and then locally you just say `git push origin master`. Now any other repository can `pull` from the remote repository. |
21297970 | Can I comment out a line in a .git/config file? | 289 | 2014-01-23 02:05:51 | <p>I have a <code>http.proxy</code> line on my repository configuration file that I would like to 'turn on and off' easily without having to remember and type again the whole configuration every time I'm behind or free from this proxied connection.</p>
<p>Another possibility would be to use this repository configurati... | 74,720 | 1,700,479 | 2022-03-31 11:35:14 | 21,298,038 | 385 | 2014-01-23 02:11:59 | 354,577 | 2014-01-23 02:11:59 | https://stackoverflow.com/q/21297970 | https://stackoverflow.com/a/21298038 | <p>Yes, you can comment lines out of Git config files using <code>#</code> or <code>;</code>.</p>
<p>From <a href="http://git-scm.com/docs/git-config#_syntax" rel="noreferrer">the documentation</a>:</p>
<blockquote>
<p><strong>Syntax</strong></p>
<p>The syntax is fairly flexible and permissive; whitespaces are... | <p>Yes, you can comment lines out of Git config files using <code>#</code> or <code>;</code>.</p> <p>From <a href="http://git-scm.com/docs/git-config#_syntax" rel="noreferrer">the documentation</a>:</p> <blockquote> <p><strong>Syntax</strong></p> <p>The syntax is fairly flexible and permissive; whitespaces are... | 119, 3574 | config, git | <h1>Can I comment out a line in a .git/config file?</h1>
<p>I have a <code>http.proxy</code> line on my repository configuration file that I would like to 'turn on and off' easily without having to remember and type again the whole configuration every time I'm behind or free from this proxied connection.</p>
<p>Anothe... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,504 | git | # Can I comment out a line in a .git/config file?
I have a `http.proxy` line on my repository configuration file that I would like to 'turn on and off' easily without having to remember and type again the whole configuration every time I'm behind or free from this proxied connection.
Another possibility would be to u... | Yes, you can comment lines out of Git config files using `#` or `;`.
From [the documentation](http://git-scm.com/docs/git-config#_syntax):
> **Syntax**
>
> The syntax is fairly flexible and permissive; whitespaces are mostly ignored. The `#` and `;` characters begin comments to the end of line, blank lines are ignore... |
1556119 | SSH Private Key Permissions using Git GUI or ssh-keygen are too open | 262 | 2009-10-12 18:26:21 | <p>Recently I've been unable to clone or push to github, and I'm trying to find the root cause.</p>
<p><em>This is on windows</em></p>
<p>I have cygwin + git as well as msysgit.</p>
<p>Msysgit was installed with the following options:</p>
<ul>
<li>OpenSSH</li>
<li>Use Git from Windows Command Prompt</li>
</ul>
<p>... | 293,982 | 3,381 | 2020-02-24 15:33:56 | 1,560,807 | 384 | 2009-10-13 15:01:43 | 165,017 | 2009-10-13 15:01:43 | https://stackoverflow.com/q/1556119 | https://stackoverflow.com/a/1560807 | <p>You changed the permissions on the whole directory, which I agree with Splash is a bad idea. If you can remember what the original permissions for the directory are, I would try to set them back to that and then do the following</p>
<pre><code>cd ~/.ssh
chmod 700 id_rsa
</code></pre>
<p>inside the .ssh folder. T... | <p>You changed the permissions on the whole directory, which I agree with Splash is a bad idea. If you can remember what the original permissions for the directory are, I would try to set them back to that and then do the following</p> <pre><code>cd ~/.ssh chmod 700 id_rsa </code></pre> <p>inside the .ssh folder. T... | 119, 386, 1731, 3305, 21628 | cygwin, git, msysgit, openssh, ssh | <h1>SSH Private Key Permissions using Git GUI or ssh-keygen are too open</h1>
<p>Recently I've been unable to clone or push to github, and I'm trying to find the root cause.</p>
<p><em>This is on windows</em></p>
<p>I have cygwin + git as well as msysgit.</p>
<p>Msysgit was installed with the following options:</p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,505 | git | # SSH Private Key Permissions using Git GUI or ssh-keygen are too open
Recently I've been unable to clone or push to github, and I'm trying to find the root cause.
*This is on windows*
I have cygwin + git as well as msysgit.
Msysgit was installed with the following options:
- OpenSSH
- Use Git from Windows Command... | You changed the permissions on the whole directory, which I agree with Splash is a bad idea. If you can remember what the original permissions for the directory are, I would try to set them back to that and then do the following
```
cd ~/.ssh
chmod 700 id_rsa
```
inside the .ssh folder. That will set the id_rsa file ... |
6900328 | git command to show all (lightweight) tags creation dates | 241 | 2011-08-01 14:58:52 | <p>Is there a one liner that shows me the dates where all git lightweight tags where created ?</p>
<p>Something like: <code>git show tags --format=date</code> ?</p>
| 91,408 | 937 | 2022-03-15 07:41:33 | 6,900,369 | 384 | 2011-08-01 15:01:32 | 937 | 2016-04-20 20:46:39 | https://stackoverflow.com/q/6900328 | https://stackoverflow.com/a/6900369 | <p>I found in this <a href="http://osdir.com/ml/git/2009-05/msg01404.html" rel="noreferrer">link</a> a solution that fits my needs:</p>
<pre><code>git log --tags --simplify-by-decoration --pretty="format:%ai %d"
</code></pre>
<p>I've put that command in an alias in my <code>~/.alias</code>, so now everytime I run <co... | <p>I found in this <a href="http://osdir.com/ml/git/2009-05/msg01404.html" rel="noreferrer">link</a> a solution that fits my needs:</p> <pre><code>git log --tags --simplify-by-decoration --pretty="format:%ai %d" </code></pre> <p>I've put that command in an alias in my <code>~/.alias</code>, so now everytime I run <co... | 115, 119, 5002 | date, git, tags | <h1>git command to show all (lightweight) tags creation dates</h1>
<p>Is there a one liner that shows me the dates where all git lightweight tags where created ?</p>
<p>Something like: <code>git show tags --format=date</code> ?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,506 | git | # git command to show all (lightweight) tags creation dates
Is there a one liner that shows me the dates where all git lightweight tags where created ?
Something like: `git show tags --format=date` ? | I found in this [link](http://osdir.com/ml/git/2009-05/msg01404.html) a solution that fits my needs:
```
git log --tags --simplify-by-decoration --pretty="format:%ai %d"
```
I've put that command in an alias in my `~/.alias`, so now everytime I run `gitshowtagbydate` I get what I needed. |
16190387 | When applying a patch is there any way to resolve conflicts? | 195 | 2013-04-24 11:07:56 | <p>I am on windows. </p>
<p>For various reasons we have multiple git instances of different svn branches. </p>
<p>Many times I want to fix an issue in repository A, generate a patch, and apply it to repository B. This works fine except if there are conflicts. </p>
<p>When rebasing I just right click the folder and u... | 160,586 | 200,295 | 2025-04-20 08:10:25 | 16,968,982 | 384 | 2013-06-06 18:00:35 | 496,405 | 2017-11-23 08:58:50 | https://stackoverflow.com/q/16190387 | https://stackoverflow.com/a/16968982 | <p>To generate your patch do the following:</p>
<pre><code>git format-patch --stdout first_commit^..last_commit > changes.patch
</code></pre>
<p>Now when you are ready to apply the patches:</p>
<pre><code>git am -3 < changes.patch
</code></pre>
<p>the <code>-3</code> will do a three-way merge if there are con... | <p>To generate your patch do the following:</p> <pre><code>git format-patch --stdout first_commit^..last_commit > changes.patch </code></pre> <p>Now when you are ready to apply the patches:</p> <pre><code>git am -3 < changes.patch </code></pre> <p>the <code>-3</code> will do a three-way merge if there are con... | 119, 84451, 94361 | git, git-am, git-apply | <h1>When applying a patch is there any way to resolve conflicts?</h1>
<p>I am on windows. </p>
<p>For various reasons we have multiple git instances of different svn branches. </p>
<p>Many times I want to fix an issue in repository A, generate a patch, and apply it to repository B. This works fine except if there are... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,507 | git | # When applying a patch is there any way to resolve conflicts?
I am on windows.
For various reasons we have multiple git instances of different svn branches.
Many times I want to fix an issue in repository A, generate a patch, and apply it to repository B. This works fine except if there are conflicts.
When rebasin... | To generate your patch do the following:
```
git format-patch --stdout first_commit^..last_commit > changes.patch
```
Now when you are ready to apply the patches:
```
git am -3 < changes.patch
```
the `-3` will do a three-way merge if there are conflicts. At this point you can do a `git mergetool` if you want to go... |
964876 | HEAD and ORIG_HEAD in Git | 309 | 2009-06-08 13:17:18 | <p>What do these symbols refer to and what do they mean? </p>
<p>(I can't find any explanation in official documentation)</p>
| 137,297 | 51,387 | 2024-07-17 18:34:33 | 967,611 | 383 | 2009-06-09 00:05:51 | 46,058 | 2020-10-29 08:42:13 | https://stackoverflow.com/q/964876 | https://stackoverflow.com/a/967611 | <p><code>HEAD</code> is (direct or indirect, i.e. symbolic) reference to the current commit. It is a commit that you have checked in the working directory (unless you made some changes, or equivalent), and it is a commit on top of which "git commit" would make a new one. Usually <code>HEAD</code> is symbolic ... | <p><code>HEAD</code> is (direct or indirect, i.e. symbolic) reference to the current commit. It is a commit that you have checked in the working directory (unless you made some changes, or equivalent), and it is a commit on top of which "git commit" would make a new one. Usually <code>HEAD</code> is symbolic ... | 119, 158321 | git, git-head | <h1>HEAD and ORIG_HEAD in Git</h1>
<p>What do these symbols refer to and what do they mean? </p>
<p>(I can't find any explanation in official documentation)</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,508 | git | # HEAD and ORIG_HEAD in Git
What do these symbols refer to and what do they mean?
(I can't find any explanation in official documentation) | `HEAD` is (direct or indirect, i.e. symbolic) reference to the current commit. It is a commit that you have checked in the working directory (unless you made some changes, or equivalent), and it is a commit on top of which "git commit" would make a new one. Usually `HEAD` is symbolic reference to some other named branc... |
7987687 | What is the difference between "git branch" and "git checkout -b"? | 276 | 2011-11-02 21:44:36 | <p>I used <code>git checkout -b</code> to create a new branch. I think that <code>git branch</code> does the same thing.
How do these two commands differ, if they differ at all?</p>
| 154,695 | 592,254 | 2020-09-07 03:23:29 | 7,987,711 | 383 | 2011-11-02 21:46:44 | 480,949 | 2020-09-07 03:23:29 | https://stackoverflow.com/q/7987687 | https://stackoverflow.com/a/7987711 | <p><code>git checkout -b BRANCH_NAME</code> creates a new branch and checks out the new branch while <code>git branch BRANCH_NAME</code> creates a new branch but leaves you on the same branch.</p>
<p>In other words <code>git checkout -b BRANCH_NAME</code> does the following for you.</p>
<pre><code>git branch BRANCH_NAM... | <p><code>git checkout -b BRANCH_NAME</code> creates a new branch and checks out the new branch while <code>git branch BRANCH_NAME</code> creates a new branch but leaves you on the same branch.</p> <p>In other words <code>git checkout -b BRANCH_NAME</code> does the following for you.</p> <pre><code>git branch BRANCH_NAM... | 119, 37230, 76220 | git, git-branch, git-checkout | <h1>What is the difference between "git branch" and "git checkout -b"?</h1>
<p>I used <code>git checkout -b</code> to create a new branch. I think that <code>git branch</code> does the same thing.
How do these two commands differ, if they differ at all?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,509 | git | # What is the difference between "git branch" and "git checkout -b"?
I used `git checkout -b` to create a new branch. I think that `git branch` does the same thing.
How do these two commands differ, if they differ at all? | `git checkout -b BRANCH_NAME` creates a new branch and checks out the new branch while `git branch BRANCH_NAME` creates a new branch but leaves you on the same branch.
In other words `git checkout -b BRANCH_NAME` does the following for you.
```
git branch BRANCH_NAME # create a new branch
git switch BRANCH_NAME ... |
44549733 | How to use Visual Studio Code as the default editor for Git MergeTool including for 3-way merge | 204 | 2017-06-14 16:07:39 | <p>Today I was trying to use the <code>git mergetool</code> on the Windows command prompt and realized that it was defaulting to use <em>Vim</em>, which is cool, but I'd prefer <em>VS Code</em>.</p>
<p>How can I have <em>Visual Studio Code</em> function as my GUI for handling merge conflicts (or even as a diffing tool)... | 125,895 | 3,018,212 | 2022-08-19 16:46:43 | 44,549,734 | 383 | 2017-06-14 16:07:39 | 3,018,212 | 2022-08-19 16:46:43 | https://stackoverflow.com/q/44549733 | https://stackoverflow.com/a/44549734 | <p><strong>Update:</strong> As of <a href="https://code.visualstudio.com/updates/v1_70#_3way-merge-editor-improvements" rel="noreferrer">Visual Studio Code 1.70</a> <em>Three-way merge</em> with improvements were added. <a href="https://code.visualstudio.com/updates/v1_69#_3-way-merge-editor" rel="noreferrer">Visuals a... | <p><strong>Update:</strong> As of <a href="https://code.visualstudio.com/updates/v1_70#_3way-merge-editor-improvements" rel="noreferrer">Visual Studio Code 1.70</a> <em>Three-way merge</em> with improvements were added. <a href="https://code.visualstudio.com/updates/v1_69#_3-way-merge-editor" rel="noreferrer">Visuals a... | 119, 25165, 28897, 33953, 111608 | git, git-merge, mergetool, visual-studio, visual-studio-code | <h1>How to use Visual Studio Code as the default editor for Git MergeTool including for 3-way merge</h1>
<p>Today I was trying to use the <code>git mergetool</code> on the Windows command prompt and realized that it was defaulting to use <em>Vim</em>, which is cool, but I'd prefer <em>VS Code</em>.</p>
<p>How can I hav... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,510 | git | # How to use Visual Studio Code as the default editor for Git MergeTool including for 3-way merge
Today I was trying to use the `git mergetool` on the Windows command prompt and realized that it was defaulting to use *Vim*, which is cool, but I'd prefer *VS Code*.
How can I have *Visual Studio Code* function as my GU... | **Update:** As of [Visual Studio Code 1.70](https://code.visualstudio.com/updates/v1_70#_3way-merge-editor-improvements) *Three-way merge* with improvements were added. [Visuals and further explanations](https://code.visualstudio.com/updates/v1_69#_3-way-merge-editor) are available if that's of interest to you 😉.
As ... |
19032296 | How to use Git Revert | 396 | 2013-09-26 15:23:50 | <p>How is <code>git revert</code> used?</p>
<p>This might sound like a duplicate question but when people ask it, the response is often, use <code>git reset</code> as per <em><a href="https://stackoverflow.com/questions/1895059/revert-to-a-commit-by-sha-hash">Revert to a commit by a SHA hash in Git?</a></em>.</p>
<p>Th... | 950,161 | 107,783 | 2025-08-04 11:32:08 | 19,032,678 | 382 | 2013-09-26 15:41:15 | 761,202 | 2025-08-04 11:17:22 | https://stackoverflow.com/q/19032296 | https://stackoverflow.com/a/19032678 | <h2>git revert makes a new commit</h2>
<p><code>git revert</code> simply creates a new commit that is the opposite of an existing commit.</p>
<p>It leaves the files in the same state as if the commit that has been reverted never existed. For example, consider the following simple example:</p>
<pre class="lang-console ... | <h2>git revert makes a new commit</h2> <p><code>git revert</code> simply creates a new commit that is the opposite of an existing commit.</p> <p>It leaves the files in the same state as if the commit that has been reverted never existed. For example, consider the following simple example:</p> <pre class="lang-console ... | 119, 34403 | git, git-revert | <h1>How to use Git Revert</h1>
<p>How is <code>git revert</code> used?</p>
<p>This might sound like a duplicate question but when people ask it, the response is often, use <code>git reset</code> as per <em><a href="https://stackoverflow.com/questions/1895059/revert-to-a-commit-by-sha-hash">Revert to a commit by a SHA h... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,511 | git | # How to use Git Revert
How is `git revert` used?
This might sound like a duplicate question but when people ask it, the response is often, use `git reset` as per *[Revert to a commit by a SHA hash in Git?](https://stackoverflow.com/questions/1895059/revert-to-a-commit-by-sha-hash)*.
Then when someone asks how to us... | ## git revert makes a new commit
`git revert` simply creates a new commit that is the opposite of an existing commit.
It leaves the files in the same state as if the commit that has been reverted never existed. For example, consider the following simple example:
```
$ cd /tmp/example
$ git init
Initialized empty Git... |
7298598 | What is the difference between git clone and checkout? | 388 | 2011-09-04 10:33:03 | <p>What is the difference between <code>git clone</code> and <code>git checkout</code>?</p>
| 379,221 | 614,157 | 2018-05-05 18:11:27 | 7,298,621 | 382 | 2011-09-04 10:37:59 | 26,051 | 2017-10-27 09:36:19 | https://stackoverflow.com/q/7298598 | https://stackoverflow.com/a/7298621 | <p>The man page for checkout: <a href="http://git-scm.com/docs/git-checkout" rel="noreferrer">http://git-scm.com/docs/git-checkout</a></p>
<p>The man page for clone: <a href="http://git-scm.com/docs/git-clone" rel="noreferrer">http://git-scm.com/docs/git-clone</a></p>
<p>To sum it up, clone is for fetching repositori... | <p>The man page for checkout: <a href="http://git-scm.com/docs/git-checkout" rel="noreferrer">http://git-scm.com/docs/git-checkout</a></p> <p>The man page for clone: <a href="http://git-scm.com/docs/git-clone" rel="noreferrer">http://git-scm.com/docs/git-clone</a></p> <p>To sum it up, clone is for fetching repositori... | 119, 1796 | command, git | <h1>What is the difference between git clone and checkout?</h1>
<p>What is the difference between <code>git clone</code> and <code>git checkout</code>?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,512 | git | # What is the difference between git clone and checkout?
What is the difference between `git clone` and `git checkout`? | The man page for checkout: <http://git-scm.com/docs/git-checkout>
The man page for clone: <http://git-scm.com/docs/git-clone>
To sum it up, clone is for fetching repositories you don't have, checkout is for switching between branches in a repository you already have.
Note: for those who have a SVN/CVS background and... |
27330446 | Getting a fatal error in git for multiple stage entries | 241 | 2014-12-06 10:00:08 | <p>Using Git version 2.2.0 with unity game engine on OS X, and wanted to commit my code. I added everything and did not get an error message. then commit -m , and got this error message:</p>
<pre><code>fatal: multiple stage entries for merged file 'Assets/Prefabs/Resources'
</code></pre>
<p>Not noticing it I pushed... | 64,286 | 1,371,285 | 2019-01-02 16:17:05 | 27,481,661 | 382 | 2014-12-15 10:11:06 | 6,309 | 2015-10-14 17:29:33 | https://stackoverflow.com/q/27330446 | https://stackoverflow.com/a/27481661 | <p>The first workaround, which seems to work with recent versions of Git (2.3+, Q2+ 2015) is mentioned in <a href="https://stackoverflow.com/users/2403277/grant">grant</a>'s <a href="https://stackoverflow.com/a/29261818/6309">more up-to-date answer</a>:</p>
<ol>
<li><p>Delete the index</p>
<pre><code>$ rm .git/index
... | <p>The first workaround, which seems to work with recent versions of Git (2.3+, Q2+ 2015) is mentioned in <a href="https://stackoverflow.com/users/2403277/grant">grant</a>'s <a href="https://stackoverflow.com/a/29261818/6309">more up-to-date answer</a>:</p> <ol> <li><p>Delete the index</p> <pre><code>$ rm .git/index ... | 119 | git | <h1>Getting a fatal error in git for multiple stage entries</h1>
<p>Using Git version 2.2.0 with unity game engine on OS X, and wanted to commit my code. I added everything and did not get an error message. then commit -m , and got this error message:</p>
<pre><code>fatal: multiple stage entries for merged file 'Ass... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,513 | git | # Getting a fatal error in git for multiple stage entries
Using Git version 2.2.0 with unity game engine on OS X, and wanted to commit my code. I added everything and did not get an error message. then commit -m , and got this error message:
```
fatal: multiple stage entries for merged file 'Assets/Prefabs/Resources'... | The first workaround, which seems to work with recent versions of Git (2.3+, Q2+ 2015) is mentioned in [grant](https://stackoverflow.com/users/2403277/grant)'s [more up-to-date answer](https://stackoverflow.com/a/29261818/6309):
1. Delete the index
```
$ rm .git/index
```
2. Add all
```
$ git add -A
... |
19303898 | How to undo last commit | 188 | 2013-10-10 18:50:55 | <p>I did the following comments</p>
<pre><code>git add /file1/path
git rm /file/path
git commit -m "message"
</code></pre>
<p>how do I undo my last commit using git?</p>
<p>Like I don't want to have those files committed.</p>
| 182,328 | 1,748,387 | 2018-01-18 19:56:46 | 19,303,993 | 382 | 2013-10-10 18:55:52 | 526,535 | 2018-01-18 19:56:46 | https://stackoverflow.com/q/19303898 | https://stackoverflow.com/a/19303993 | <p><strong>Warning: Don't do this if you've already pushed</strong></p>
<p>You want to do:</p>
<pre><code>git reset HEAD~
</code></pre>
<p>If you don't want the changes and blow everything away:</p>
<pre><code>git reset --hard HEAD~
</code></pre>
| <p><strong>Warning: Don't do this if you've already pushed</strong></p> <p>You want to do:</p> <pre><code>git reset HEAD~ </code></pre> <p>If you don't want the changes and blow everything away:</p> <pre><code>git reset --hard HEAD~ </code></pre> | 119 | git | <h1>How to undo last commit</h1>
<p>I did the following comments</p>
<pre><code>git add /file1/path
git rm /file/path
git commit -m "message"
</code></pre>
<p>how do I undo my last commit using git?</p>
<p>Like I don't want to have those files committed.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,514 | git | # How to undo last commit
I did the following comments
```
git add /file1/path
git rm /file/path
git commit -m "message"
```
how do I undo my last commit using git?
Like I don't want to have those files committed. | **Warning: Don't do this if you've already pushed**
You want to do:
```
git reset HEAD~
```
If you don't want the changes and blow everything away:
```
git reset --hard HEAD~
``` |
3357122 | What is the difference between git pull and git fetch + git rebase? | 341 | 2010-07-28 20:16:04 | <p><a href="https://stackoverflow.com/questions/292357/whats-the-difference-between-git-pull-and-git-fetch">Another question</a> says that <code>git pull</code> is like a <code>git fetch</code> + <code>git merge</code>.</p>
<p>But what is the difference between <code>git pull</code> and <code>git fetch</code> + <code>g... | 201,518 | 286,802 | 2020-10-10 10:50:07 | 3,357,174 | 380 | 2010-07-28 20:23:49 | 119,963 | 2015-02-19 11:04:40 | https://stackoverflow.com/q/3357122 | https://stackoverflow.com/a/3357174 | <p>It should be pretty obvious from your question that you're actually just asking about the difference between <code>git merge</code> and <code>git rebase</code>. </p>
<p>So let's suppose you're in the common case - you've done some work on your master branch, and you pull from origin's, which also has done some work... | <p>It should be pretty obvious from your question that you're actually just asking about the difference between <code>git merge</code> and <code>git rebase</code>. </p> <p>So let's suppose you're in the common case - you've done some work on your master branch, and you pull from origin's, which also has done some work... | 119, 28896, 29934, 33720 | git, git-fetch, git-pull, git-rebase | <h1>What is the difference between git pull and git fetch + git rebase?</h1>
<p><a href="https://stackoverflow.com/questions/292357/whats-the-difference-between-git-pull-and-git-fetch">Another question</a> says that <code>git pull</code> is like a <code>git fetch</code> + <code>git merge</code>.</p>
<p>But what is the ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,517 | git | # What is the difference between git pull and git fetch + git rebase?
[Another question](https://stackoverflow.com/questions/292357/whats-the-difference-between-git-pull-and-git-fetch) says that `git pull` is like a `git fetch` + `git merge`.
But what is the difference between `git pull` and `git fetch` + `git rebase... | It should be pretty obvious from your question that you're actually just asking about the difference between `git merge` and `git rebase`.
So let's suppose you're in the common case - you've done some work on your master branch, and you pull from origin's, which also has done some work. After the fetch, things look li... |
3973034 | Export a stash to another computer | 465 | 2010-10-19 21:41:46 | <p>I need a way to export a stashed change to another computer.</p>
<p>On computer 1 I did</p>
<pre><code>$ git stash save feature
</code></pre>
<p>I'm trying to get the stash patch to a file and then import it to another computer</p>
<pre><code>$ git stash show -p > patch
</code></pre>
<p>This command gives me a fi... | 208,997 | 340,711 | 2025-08-22 07:26:26 | 3,973,058 | 378 | 2010-10-19 21:46:20 | 216,074 | 2010-10-19 21:46:20 | https://stackoverflow.com/q/3973034 | https://stackoverflow.com/a/3973058 | <p>You can apply a patch file (without committing the changes yet) by simply running</p>
<pre><code>git apply patchfile
</code></pre>
<p>Then you can simply create a new stash from the current working directory:</p>
<pre><code>git stash
</code></pre>
| <p>You can apply a patch file (without committing the changes yet) by simply running</p> <pre><code>git apply patchfile </code></pre> <p>Then you can simply create a new stash from the current working directory:</p> <pre><code>git stash </code></pre> | 119 | git | <h1>Export a stash to another computer</h1>
<p>I need a way to export a stashed change to another computer.</p>
<p>On computer 1 I did</p>
<pre><code>$ git stash save feature
</code></pre>
<p>I'm trying to get the stash patch to a file and then import it to another computer</p>
<pre><code>$ git stash show -p > patch... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,520 | git | # Export a stash to another computer
I need a way to export a stashed change to another computer.
On computer 1 I did
```
$ git stash save feature
```
I'm trying to get the stash patch to a file and then import it to another computer
```
$ git stash show -p > patch
```
This command gives me a file that I can move... | You can apply a patch file (without committing the changes yet) by simply running
```
git apply patchfile
```
Then you can simply create a new stash from the current working directory:
```
git stash
``` |
5685007 | Making 'git log' ignore changes for certain paths | 201 | 2011-04-16 06:52:53 | <p>How can I make <code>git log</code> only show commits that changed files other than the ones I specify?</p>
<p>With <code>git log</code>, I can filter the commits I see to those that touch a given set of paths. What I want is to invert that filter so that only commits that touch paths other than the specified ones w... | 53,782 | 2,391 | 2024-02-17 23:33:58 | 21,079,437 | 378 | 2014-01-12 19:47:17 | 6,309 | 2024-02-17 23:33:58 | https://stackoverflow.com/q/5685007 | https://stackoverflow.com/a/21079437 | <p>It is implemented now (git 1.9/2.0, Q1 2014) with the introduction <strong>pathspec magic <code>:(exclude)</code> and its short form <code>:!</code></strong> in <a href="https://github.com/git/git/commit/ef79b1f8704668a6cdf4278f9255e03ca785bfb4" rel="noreferrer">commit ef79b1f</a> and <a href="https://github.com/git... | <p>It is implemented now (git 1.9/2.0, Q1 2014) with the introduction <strong>pathspec magic <code>:(exclude)</code> and its short form <code>:!</code></strong> in <a href="https://github.com/git/git/commit/ef79b1f8704668a6cdf4278f9255e03ca785bfb4" rel="noreferrer">commit ef79b1f</a> and <a href="https://github.com/git... | 119 | git | <h1>Making 'git log' ignore changes for certain paths</h1>
<p>How can I make <code>git log</code> only show commits that changed files other than the ones I specify?</p>
<p>With <code>git log</code>, I can filter the commits I see to those that touch a given set of paths. What I want is to invert that filter so that on... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,521 | git | # Making 'git log' ignore changes for certain paths
How can I make `git log` only show commits that changed files other than the ones I specify?
With `git log`, I can filter the commits I see to those that touch a given set of paths. What I want is to invert that filter so that only commits that touch paths other tha... | It is implemented now (git 1.9/2.0, Q1 2014) with the introduction **pathspec magic `:(exclude)` and its short form `:!`** in [commit ef79b1f](https://github.com/git/git/commit/ef79b1f8704668a6cdf4278f9255e03ca785bfb4) and [commit 1649612](https://github.com/git/git/commit/1649612a227eaa5af7cb0e2d059728c0148485d9), by
... |
31203001 | What does 'git blame' do? | 568 | 2015-07-03 09:15:18 | <p>I saw a lot of questions about methods of using <code>git blame</code>, but I don't really understand them.</p>
<p>I see a <kbd>Blame</kbd> button on top of files on the GitHub interface. Upon clicking it, it shows some diff with usernames on the left bar. What does that indicate?</p>
<p>Why is <code>git blame</co... | 450,906 | 4,698,026 | 2025-02-14 18:03:59 | 31,204,980 | 377 | 2015-07-03 10:49:04 | 2,853,903 | 2020-01-20 19:52:24 | https://stackoverflow.com/q/31203001 | https://stackoverflow.com/a/31204980 | <p>From <em><a href="http://git-scm.com/docs/git-blame" rel="noreferrer">git-blame</a></em>:</p>
<blockquote>
<p>Annotates each line in the given file with information from the revision which last modified the line. Optionally, start annotating from the given revision.</p>
<p>When specified one or more times, -... | <p>From <em><a href="http://git-scm.com/docs/git-blame" rel="noreferrer">git-blame</a></em>:</p> <blockquote> <p>Annotates each line in the given file with information from the revision which last modified the line. Optionally, start annotating from the given revision.</p> <p>When specified one or more times, -... | 119, 105902 | git, git-blame | <h1>What does 'git blame' do?</h1>
<p>I saw a lot of questions about methods of using <code>git blame</code>, but I don't really understand them.</p>
<p>I see a <kbd>Blame</kbd> button on top of files on the GitHub interface. Upon clicking it, it shows some diff with usernames on the left bar. What does that indicate?... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,522 | git | # What does 'git blame' do?
I saw a lot of questions about methods of using `git blame`, but I don't really understand them.
I see a `Blame` button on top of files on the GitHub interface. Upon clicking it, it shows some diff with usernames on the left bar. What does that indicate?
Why is `git blame` actually used, ... | From *[git-blame](http://git-scm.com/docs/git-blame)*:
> Annotates each line in the given file with information from the revision which last modified the line. Optionally, start annotating from the given revision.
>
> When specified one or more times, -L restricts annotation to the requested lines.
**Example:**
```
... |
18930527 | Difference between git pull and git pull --rebase | 368 | 2013-09-21 08:24:21 | <p>I started using git sometime back and do not fully understand the intricacies. My basic question here is to find out the difference between a <code>git pull</code> and <code>git pull --rebase</code> , since adding the <code>--rebase</code> option does not seem to do something very different : just does a pull.</p>
... | 268,658 | 1,416,970 | 2023-07-03 09:03:37 | 18,930,564 | 377 | 2013-09-21 08:28:26 | 1,734,130 | 2015-07-27 10:56:28 | https://stackoverflow.com/q/18930527 | https://stackoverflow.com/a/18930564 | <p><strong><code>git pull</code></strong> = <strong><code>git fetch</code></strong> + <strong><code>git merge</code></strong> against tracking upstream branch</p>
<p><strong><code>git pull --rebase</code></strong> = <strong><code>git fetch</code></strong> + <strong><code>git rebase</code></strong> against tracking ups... | <p><strong><code>git pull</code></strong> = <strong><code>git fetch</code></strong> + <strong><code>git merge</code></strong> against tracking upstream branch</p> <p><strong><code>git pull --rebase</code></strong> = <strong><code>git fetch</code></strong> + <strong><code>git rebase</code></strong> against tracking ups... | 119, 8974, 28896 | git, git-pull, rebase | <h1>Difference between git pull and git pull --rebase</h1>
<p>I started using git sometime back and do not fully understand the intricacies. My basic question here is to find out the difference between a <code>git pull</code> and <code>git pull --rebase</code> , since adding the <code>--rebase</code> option does not se... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,523 | git | # Difference between git pull and git pull --rebase
I started using git sometime back and do not fully understand the intricacies. My basic question here is to find out the difference between a `git pull` and `git pull --rebase` , since adding the `--rebase` option does not seem to do something very different : just d... | **`git pull`** = **`git fetch`** + **`git merge`** against tracking upstream branch
**`git pull --rebase`** = **`git fetch`** + **`git rebase`** against tracking upstream branch
If you want to know how `git merge` and `git rebase` differ, [read this](https://stackoverflow.com/a/16666418/1734130). |
8600652 | Git on Bitbucket: Always asked for password, even after uploading my public SSH key | 256 | 2011-12-22 07:28:48 | <p>I uploaded my <code>~/.ssh/id_rsa.pub</code> to <a href="https://bitbucket.org/account/ssh-keys/" rel="noreferrer">Bitbucket's SSH keys</a> as <a href="https://confluence.atlassian.com/bitbucket/use-the-ssh-protocol-with-bitbucket-cloud-221449711.html" rel="noreferrer">explained</a>, but Git still asks me for my pas... | 198,642 | 226,958 | 2022-10-10 11:16:11 | 8,600,699 | 377 | 2011-12-22 07:35:34 | 526,535 | 2019-11-14 14:45:38 | https://stackoverflow.com/q/8600652 | https://stackoverflow.com/a/8600699 | <p>Are you sure you cloned it using the ssh url?</p>
<p>The url for origin says <code>url = https://Nicolas_Raoul@bitbucket.org/Nicolas_Raoul/therepo.git</code> so if it is using https it will ask for password irrespective of your ssh keys.</p>
<p>So what you want to do is the following:</p>
<p>open your config file... | <p>Are you sure you cloned it using the ssh url?</p> <p>The url for origin says <code>url = https://Nicolas_Raoul@bitbucket.org/Nicolas_Raoul/therepo.git</code> so if it is using https it will ask for password irrespective of your ssh keys.</p> <p>So what you want to do is the following:</p> <p>open your config file... | 119, 386, 8337 | bitbucket, git, ssh | <h1>Git on Bitbucket: Always asked for password, even after uploading my public SSH key</h1>
<p>I uploaded my <code>~/.ssh/id_rsa.pub</code> to <a href="https://bitbucket.org/account/ssh-keys/" rel="noreferrer">Bitbucket's SSH keys</a> as <a href="https://confluence.atlassian.com/bitbucket/use-the-ssh-protocol-with-bit... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,524 | git | # Git on Bitbucket: Always asked for password, even after uploading my public SSH key
I uploaded my `~/.ssh/id_rsa.pub` to [Bitbucket's SSH keys](https://bitbucket.org/account/ssh-keys/) as [explained](https://confluence.atlassian.com/bitbucket/use-the-ssh-protocol-with-bitbucket-cloud-221449711.html), but Git still a... | Are you sure you cloned it using the ssh url?
The url for origin says `url = https://Nicolas_Raoul@bitbucket.org/Nicolas_Raoul/therepo.git` so if it is using https it will ask for password irrespective of your ssh keys.
So what you want to do is the following:
open your config file in your current repo ..
`vim .git... |
5195859 | How do you push a tag to a remote repository using Git? | 3,684 | 2011-03-04 15:37:24 | <p>I added a tag to the master branch on my machine:</p>
<pre><code>git tag mytag master
</code></pre>
<p>How do I push this to the remote repository? Running <code>git push</code> gives the message:</p>
<blockquote>
<p>Everything up-to-date</p>
</blockquote>
<p>However, the remote repository does not contain my tag.</... | 2,590,081 | 213,269 | 2025-03-13 15:07:32 | 13,051,597 | 376 | 2012-10-24 14:43:31 | 356,959 | 2012-10-24 14:43:31 | https://stackoverflow.com/q/5195859 | https://stackoverflow.com/a/13051597 | <p>To push specific, one tag do following
<code>git push origin tag_name</code></p>
| <p>To push specific, one tag do following <code>git push origin tag_name</code></p> | 119, 28898, 60718 | git, git-push, git-tag | <h1>How do you push a tag to a remote repository using Git?</h1>
<p>I added a tag to the master branch on my machine:</p>
<pre><code>git tag mytag master
</code></pre>
<p>How do I push this to the remote repository? Running <code>git push</code> gives the message:</p>
<blockquote>
<p>Everything up-to-date</p>
</blockqu... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,525 | git | # How do you push a tag to a remote repository using Git?
I added a tag to the master branch on my machine:
```
git tag mytag master
```
How do I push this to the remote repository? Running `git push` gives the message:
> Everything up-to-date
However, the remote repository does not contain my tag. | To push specific, one tag do following
`git push origin tag_name` |
32315156 | How to inject a commit between some two arbitrary commits in the past? | 279 | 2015-08-31 15:48:46 | <p>Suppose I have the following commit history on my local-only branch:</p>
<pre><code>A -- B -- C
</code></pre>
<p>How do I insert a new commit between <code>A</code> and <code>B</code>?</p>
| 111,859 | 2,642,204 | 2023-09-18 19:37:37 | 32,315,197 | 376 | 2015-08-31 15:51:54 | 34,397 | 2017-08-29 01:01:43 | https://stackoverflow.com/q/32315156 | https://stackoverflow.com/a/32315197 | <p>It's even easier than in OP's answer.</p>
<ol>
<li><code>git rebase -i <any earlier commit></code>. This displays a list of commits in your configured text editor.</li>
<li>Find the commit you want to insert after (let's assume it's <code>a1b2c3d</code>). In your editor, for that line, change <code>pick</code... | <p>It's even easier than in OP's answer.</p> <ol> <li><code>git rebase -i <any earlier commit></code>. This displays a list of commits in your configured text editor.</li> <li>Find the commit you want to insert after (let's assume it's <code>a1b2c3d</code>). In your editor, for that line, change <code>pick</code... | 119, 29934 | git, git-rebase | <h1>How to inject a commit between some two arbitrary commits in the past?</h1>
<p>Suppose I have the following commit history on my local-only branch:</p>
<pre><code>A -- B -- C
</code></pre>
<p>How do I insert a new commit between <code>A</code> and <code>B</code>?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,526 | git | # How to inject a commit between some two arbitrary commits in the past?
Suppose I have the following commit history on my local-only branch:
```
A -- B -- C
```
How do I insert a new commit between `A` and `B`? | It's even easier than in OP's answer.
1. `git rebase -i <any earlier commit>`. This displays a list of commits in your configured text editor.
2. Find the commit you want to insert after (let's assume it's `a1b2c3d`). In your editor, for that line, change `pick` to `edit`.
3. Begin the rebase by closing your text edit... |
17223527 | How do I force git to checkout the master branch and remove carriage returns after I've normalized files using the "text" attribute? | 156 | 2013-06-20 20:51:03 | <p>Okay, so I added the file <code>.gitattributes</code> with lines like this</p>
<pre><code>*.css text
*.js text
etc...
</code></pre>
<p>I then followed the instructions at <a href="http://git-scm.com/docs/gitattributes#_checking-out_and_checking-in">http://git-scm.com/docs/gitattributes#_checking-out_and_checking-i... | 496,964 | 361,855 | 2022-07-03 17:19:42 | 17,223,639 | 376 | 2013-06-20 20:58:20 | 361,855 | 2022-07-03 17:19:42 | https://stackoverflow.com/q/17223527 | https://stackoverflow.com/a/17223639 | <p>Ah ah! Checkout the previous commit, then checkout the master.</p>
<pre class="lang-bash prettyprint-override"><code>git checkout HEAD^
git checkout -f master
</code></pre>
| <p>Ah ah! Checkout the previous commit, then checkout the master.</p> <pre class="lang-bash prettyprint-override"><code>git checkout HEAD^ git checkout -f master </code></pre> | 119, 3705, 59139 | core.autocrlf, git, newline | <h1>How do I force git to checkout the master branch and remove carriage returns after I've normalized files using the "text" attribute?</h1>
<p>Okay, so I added the file <code>.gitattributes</code> with lines like this</p>
<pre><code>*.css text
*.js text
etc...
</code></pre>
<p>I then followed the instructions at <a... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,528 | git | # How do I force git to checkout the master branch and remove carriage returns after I've normalized files using the "text" attribute?
Okay, so I added the file `.gitattributes` with lines like this
```
*.css text
*.js text
etc...
```
I then followed the instructions at <http://git-scm.com/docs/gitattributes#_checki... | Ah ah! Checkout the previous commit, then checkout the master.
```
git checkout HEAD^
git checkout -f master
``` |
1968512 | Getting the difference between two repositories | 332 | 2009-12-28 08:14:11 | <p>How can we get the difference between two git repositories?</p>
<p>The scenario:
We have a repo_a and repo_b. The latter was created as a copy of repo_a. There have been parallel development in both the repositories afterwards. Is there a way we can list the differences of the current versions of these two reposito... | 279,849 | 1,014,040 | 2024-07-11 10:04:07 | 1,968,538 | 375 | 2009-12-28 08:25:39 | 119,005 | 2016-02-11 19:15:37 | https://stackoverflow.com/q/1968512 | https://stackoverflow.com/a/1968538 | <p>In repo_a:</p>
<pre><code>git remote add -f b path/to/repo_b.git
git remote update
git diff master remotes/b/master
git remote rm b
</code></pre>
| <p>In repo_a:</p> <pre><code>git remote add -f b path/to/repo_b.git git remote update git diff master remotes/b/master git remote rm b </code></pre> | 119, 9033 | git, git-diff | <h1>Getting the difference between two repositories</h1>
<p>How can we get the difference between two git repositories?</p>
<p>The scenario:
We have a repo_a and repo_b. The latter was created as a copy of repo_a. There have been parallel development in both the repositories afterwards. Is there a way we can list the ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,529 | git | # Getting the difference between two repositories
How can we get the difference between two git repositories?
The scenario:
We have a repo_a and repo_b. The latter was created as a copy of repo_a. There have been parallel development in both the repositories afterwards. Is there a way we can list the differences of t... | In repo_a:
```
git remote add -f b path/to/repo_b.git
git remote update
git diff master remotes/b/master
git remote rm b
``` |
1841405 | How can I show the name of branches in `git log`? | 256 | 2009-12-03 17:10:43 | <p>How can I show the name of branches in the output of <code>git log</code>?</p>
<p>For example with, <code>git log --graph --all</code> I get a nice overview of the commits, but get confused which line is master, and which is my branch for example.</p>
| 113,834 | 146,289 | 2023-02-07 10:00:07 | 1,841,429 | 375 | 2009-12-03 17:14:03 | 19,563 | 2009-12-03 17:14:03 | https://stackoverflow.com/q/1841405 | https://stackoverflow.com/a/1841429 | <p>Try the decorate option.</p>
<pre><code>git log --graph --all --decorate
</code></pre>
<p>It annotates commits which are pointed to by tags or branches.</p>
| <p>Try the decorate option.</p> <pre><code>git log --graph --all --decorate </code></pre> <p>It annotates commits which are pointed to by tags or branches.</p> | 119 | git | <h1>How can I show the name of branches in `git log`?</h1>
<p>How can I show the name of branches in the output of <code>git log</code>?</p>
<p>For example with, <code>git log --graph --all</code> I get a nice overview of the commits, but get confused which line is master, and which is my branch for example.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,530 | git | # How can I show the name of branches in `git log`?
How can I show the name of branches in the output of `git log`?
For example with, `git log --graph --all` I get a nice overview of the commits, but get confused which line is master, and which is my branch for example. | Try the decorate option.
```
git log --graph --all --decorate
```
It annotates commits which are pointed to by tags or branches. |
36984371 | Your configuration specifies to merge with the <branch name> from the remote, but no such ref was fetched.? | 605 | 2016-05-02 14:03:04 | <p>I am getting this error for pull:</p>
<blockquote>
<p>Your configuration specifies to merge with the ref
'refs/heads/feature/Sprint4/ABC-123-Branch' from the remote, but no
such ref was fetched.</p>
</blockquote>
<p>This error is not coming for any other branch.<br>The special thing about this branch is that... | 680,168 | 1,897,528 | 2024-03-20 12:49:44 | 36,989,364 | 374 | 2016-05-02 18:41:34 | 1,256,452 | 2022-03-02 19:38:30 | https://stackoverflow.com/q/36984371 | https://stackoverflow.com/a/36989364 | <h3>What this means</h3>
<p>Your upstream—the remote you call <code>origin</code>—no longer has, or maybe never had (it's impossible to tell from this information alone) a branch named <code>feature/Sprint4/ABC-123-Branch</code>. There's one particularly common reason for that: someone (probably not you, or you'd reme... | <h3>What this means</h3> <p>Your upstream—the remote you call <code>origin</code>—no longer has, or maybe never had (it's impossible to tell from this information alone) a branch named <code>feature/Sprint4/ABC-123-Branch</code>. There's one particularly common reason for that: someone (probably not you, or you'd reme... | 119, 1879, 4860, 8337, 31409 | bitbucket, branch, git, pull, tortoisegit | <h1>Your configuration specifies to merge with the <branch name> from the remote, but no such ref was fetched.?</h1>
<p>I am getting this error for pull:</p>
<blockquote>
<p>Your configuration specifies to merge with the ref
'refs/heads/feature/Sprint4/ABC-123-Branch' from the remote, but no
such ref was fetched... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,531 | git | # Your configuration specifies to merge with the from the remote, but no such ref was fetched.?
I am getting this error for pull:
> Your configuration specifies to merge with the ref
> 'refs/heads/feature/Sprint4/ABC-123-Branch' from the remote, but no
> such ref was fetched.
This error is not coming for any other b... | ### What this means
Your upstream—the remote you call `origin`—no longer has, or maybe never had (it's impossible to tell from this information alone) a branch named `feature/Sprint4/ABC-123-Branch`. There's one particularly common reason for that: someone (probably not you, or you'd remember) deleted the branch in th... |
9396240 | How do I simply create a patch from my latest git commit? | 245 | 2012-02-22 13:58:23 | <p>I am looking for the command for creating a patch from the last commit made.</p>
<p>My workflow sometimes looks like this:</p>
<pre><code>vi some.txt
git add some.txt
git commit -m "some change"
</code></pre>
<p>Now I just want to write:</p>
<pre><code>git create-patch-from-last-commit-to-file SOME-PATCH00... | 257,813 | 410,012 | 2021-04-26 21:24:51 | 9,396,390 | 374 | 2012-02-22 14:07:30 | 212,858 | 2020-11-14 09:54:13 | https://stackoverflow.com/q/9396240 | https://stackoverflow.com/a/9396390 | <p>In general,</p>
<pre><code>git format-patch -n HEAD^
</code></pre>
<p>(check help for the many options), although it's really for mailing them.
For a single commit just</p>
<pre><code>git show HEAD > some-patch0001.patch
</code></pre>
<p>will give you a useable patch.</p>
| <p>In general,</p> <pre><code>git format-patch -n HEAD^ </code></pre> <p>(check help for the many options), although it's really for mailing them. For a single commit just</p> <pre><code>git show HEAD > some-patch0001.patch </code></pre> <p>will give you a useable patch.</p> | 119, 2132 | git, patch | <h1>How do I simply create a patch from my latest git commit?</h1>
<p>I am looking for the command for creating a patch from the last commit made.</p>
<p>My workflow sometimes looks like this:</p>
<pre><code>vi some.txt
git add some.txt
git commit -m "some change"
</code></pre>
<p>Now I just want to write:</p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,532 | git | # How do I simply create a patch from my latest git commit?
I am looking for the command for creating a patch from the last commit made.
My workflow sometimes looks like this:
```
vi some.txt
git add some.txt
git commit -m "some change"
```
Now I just want to write:
```
git create-patch-from-last-commit-to-file SO... | In general,
```
git format-patch -n HEAD^
```
(check help for the many options), although it's really for mailing them.
For a single commit just
```
git show HEAD > some-patch0001.patch
```
will give you a useable patch. |
3329943 | What are the differences between git branch, fork, fetch, merge, rebase and clone? | 521 | 2010-07-25 16:14:23 | <p>I want to understand the difference between a branch, a fork and a clone in Git?</p>
<p>Similarly, what does it mean when I do a <code>git fetch</code> as opposed to a <code>git pull</code>? </p>
<p>Also, what does <code>rebase</code> mean in comparison to <code>merge</code>? </p>
<p>How can I squash individual c... | 184,342 | 394,880 | 2021-10-13 12:27:33 | 3,329,997 | 372 | 2010-07-25 16:27:12 | 394,487 | 2012-07-17 15:36:36 | https://stackoverflow.com/q/3329943 | https://stackoverflow.com/a/3329997 | <p>A clone is simply a copy of a repository. On the surface, its result is equivalent to <code>svn checkout</code>, where you download source code from some other repository. The difference between centralized VCS like Subversion and DVCSs like Git is that in Git, when you clone, you are actually copying the entire s... | <p>A clone is simply a copy of a repository. On the surface, its result is equivalent to <code>svn checkout</code>, where you download source code from some other repository. The difference between centralized VCS like Subversion and DVCSs like Git is that in Git, when you clone, you are actually copying the entire s... | 119, 1879, 3050, 34099, 37258 | branch, clone, git, git-clone, gitx | <h1>What are the differences between git branch, fork, fetch, merge, rebase and clone?</h1>
<p>I want to understand the difference between a branch, a fork and a clone in Git?</p>
<p>Similarly, what does it mean when I do a <code>git fetch</code> as opposed to a <code>git pull</code>? </p>
<p>Also, what does <code>re... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,533 | git | # What are the differences between git branch, fork, fetch, merge, rebase and clone?
I want to understand the difference between a branch, a fork and a clone in Git?
Similarly, what does it mean when I do a `git fetch` as opposed to a `git pull`?
Also, what does `rebase` mean in comparison to `merge`?
How can I squ... | A clone is simply a copy of a repository. On the surface, its result is equivalent to `svn checkout`, where you download source code from some other repository. The difference between centralized VCS like Subversion and DVCSs like Git is that in Git, when you clone, you are actually copying the entire source repository... |
1557183 | Include/import a file in .gitconfig | 293 | 2009-10-12 22:01:51 | <p>I want to include a file in my .gitconfig. Is something like the following possible?</p>
<pre class="lang-ini prettyprint-override"><code>[core]
include = /path/to/file
</code></pre>
<p>Motivation: I want to keep my private credentials in a separate file.</p>
| 55,131 | 188,709 | 2024-08-07 22:58:50 | 9,733,277 | 372 | 2012-03-16 07:09:33 | 179,675 | 2024-08-07 22:57:24 | https://stackoverflow.com/q/1557183 | https://stackoverflow.com/a/9733277 | <p>Git (1.7.10+) now <a href="http://git-scm.com/docs/git-config#_includes" rel="noreferrer">supports</a> this syntax in <code>.gitconfig</code>:</p>
<pre class="lang-ini prettyprint-override"><code>[include]
path = /path/to/file
</code></pre>
<p>See <a href="https://github.com/gitster/git/commit/9b25a0b52e09400719... | <p>Git (1.7.10+) now <a href="http://git-scm.com/docs/git-config#_includes" rel="noreferrer">supports</a> this syntax in <code>.gitconfig</code>:</p> <pre class="lang-ini prettyprint-override"><code>[include] path = /path/to/file </code></pre> <p>See <a href="https://github.com/gitster/git/commit/9b25a0b52e09400719... | 119 | git | <h1>Include/import a file in .gitconfig</h1>
<p>I want to include a file in my .gitconfig. Is something like the following possible?</p>
<pre class="lang-ini prettyprint-override"><code>[core]
include = /path/to/file
</code></pre>
<p>Motivation: I want to keep my private credentials in a separate file.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,534 | git | # Include/import a file in .gitconfig
I want to include a file in my .gitconfig. Is something like the following possible?
```
[core]
include = /path/to/file
```
Motivation: I want to keep my private credentials in a separate file. | Git (1.7.10+) now [supports](http://git-scm.com/docs/git-config#_includes) this syntax in `.gitconfig`:
```
[include]
path = /path/to/file
```
See [here](https://github.com/gitster/git/commit/9b25a0b52e09400719366f0a33d0d0da98bbf7b0) for a detailed description of the git change and its edge cases.
By the way, a ... |
7654822 | Remove refs/original/heads/master from git repo after filter-branch --tree-filter? | 205 | 2011-10-04 22:38:56 | <p>I had the same question as asked here: <a href="https://stackoverflow.com/questions/7193507/new-git-repository-in-root-directory-to-subsume-an-exist-repository-in-a-sub-dire">New git repository in root directory to subsume an exist repository in a sub-directory</a></p>
<p>I followed this answer here: <a href="https... | 52,372 | 979,412 | 2018-09-19 08:38:31 | 7,654,880 | 372 | 2011-10-04 22:44:55 | 119,963 | 2012-07-24 15:31:13 | https://stackoverflow.com/q/7654822 | https://stackoverflow.com/a/7654880 | <p><code>refs/original/*</code> is there as a backup, in case you mess up your filter-branch. Believe me, it's a <em>really</em> good idea.</p>
<p>Once you've inspected the results, and you're very confident that you have what you want, you can remove the backed up ref:</p>
<pre><code>git update-ref -d refs/original/... | <p><code>refs/original/*</code> is there as a backup, in case you mess up your filter-branch. Believe me, it's a <em>really</em> good idea.</p> <p>Once you've inspected the results, and you're very confident that you have what you want, you can remove the backed up ref:</p> <pre><code>git update-ref -d refs/original/... | 119, 91259, 106016 | git, git-plumbing, git-rewrite-history | <h1>Remove refs/original/heads/master from git repo after filter-branch --tree-filter?</h1>
<p>I had the same question as asked here: <a href="https://stackoverflow.com/questions/7193507/new-git-repository-in-root-directory-to-subsume-an-exist-repository-in-a-sub-dire">New git repository in root directory to subsume an... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,535 | git | # Remove refs/original/heads/master from git repo after filter-branch --tree-filter?
I had the same question as asked here: [New git repository in root directory to subsume an exist repository in a sub-directory](https://stackoverflow.com/questions/7193507/new-git-repository-in-root-directory-to-subsume-an-exist-repos... | `refs/original/*` is there as a backup, in case you mess up your filter-branch. Believe me, it's a *really* good idea.
Once you've inspected the results, and you're very confident that you have what you want, you can remove the backed up ref:
```
git update-ref -d refs/original/refs/heads/master
```
or if you did th... |
6366408 | Calculating Distance between two Latitude and Longitude GeoCoordinates | 187 | 2011-06-16 02:09:47 | <p>I'm calculating the distance between two GeoCoordinates. I'm testing my app against 3-4 other apps. When I'm calculating distance, I tend to get an average of 3.3 miles for my calculation whereas other apps are getting 3.5 miles. It's a big difference for the calculation I'm trying to perform. Are there any good cla... | 231,787 | 21,318 | 2024-11-29 09:07:57 | 6,366,657 | 371 | 2011-06-16 02:58:26 | 90,457 | 2016-08-21 07:32:56 | https://stackoverflow.com/q/6366408 | https://stackoverflow.com/a/6366657 | <p>The <a href="https://msdn.microsoft.com/en-us/library/ee808858(v=vs.110).aspx">GeoCoordinate</a> class (.NET Framework 4 and higher) already has <a href="http://msdn.microsoft.com/en-us/library/system.device.location.geocoordinate.getdistanceto.aspx"><code>GetDistanceTo</code></a> method.</p>
<pre><code>var sCoord ... | <p>The <a href="https://msdn.microsoft.com/en-us/library/ee808858(v=vs.110).aspx">GeoCoordinate</a> class (.NET Framework 4 and higher) already has <a href="http://msdn.microsoft.com/en-us/library/system.device.location.geocoordinate.getdistanceto.aspx"><code>GetDistanceTo</code></a> method.</p> <pre><code>var sCoord ... | 9, 2965, 20301, 50027 | c#, geocoding, latitude-longitude, windows-phone-7 | <h1>Calculating Distance between two Latitude and Longitude GeoCoordinates</h1>
<p>I'm calculating the distance between two GeoCoordinates. I'm testing my app against 3-4 other apps. When I'm calculating distance, I tend to get an average of 3.3 miles for my calculation whereas other apps are getting 3.5 miles. It's a ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,536 | git | # Calculating Distance between two Latitude and Longitude GeoCoordinates
I'm calculating the distance between two GeoCoordinates. I'm testing my app against 3-4 other apps. When I'm calculating distance, I tend to get an average of 3.3 miles for my calculation whereas other apps are getting 3.5 miles. It's a big diffe... | The [GeoCoordinate](https://msdn.microsoft.com/en-us/library/ee808858(v=vs.110).aspx) class (.NET Framework 4 and higher) already has [`GetDistanceTo`](http://msdn.microsoft.com/en-us/library/system.device.location.geocoordinate.getdistanceto.aspx) method.
```
var sCoord = new GeoCoordinate(sLatitude, sLongitude);
var... |
4784575 | How do I find the most recent git commit that modified a file? | 288 | 2011-01-24 16:46:07 | <p>I want to find the most recent commit that modified a source file. </p>
<p>I can use <code>git blame</code> to see all the dates for commits by each line, but it’s difficult to see exactly which commit was the last one to touch the file.</p>
<p>How can I find the last commit that touched a given file in my git re... | 129,728 | 446,554 | 2025-05-29 19:52:26 | 4,784,629 | 370 | 2011-01-24 16:50:27 | 525,872 | 2025-05-29 19:52:26 | https://stackoverflow.com/q/4784575 | https://stackoverflow.com/a/4784629 | <h1>Everyday usage</h1>
<p><a href="https://git-scm.com/docs/git-log" rel="nofollow noreferrer"><code>git log</code></a> supports looking at the history of specific files (and directories), so you can call it like this:</p>
<pre><code>git log path/to/file
</code></pre>
<p>Tip: Whenever I look at the history of a specif... | <h1>Everyday usage</h1> <p><a href="https://git-scm.com/docs/git-log" rel="nofollow noreferrer"><code>git log</code></a> supports looking at the history of specific files (and directories), so you can call it like this:</p> <pre><code>git log path/to/file </code></pre> <p>Tip: Whenever I look at the history of a specif... | 119, 816 | git, search | <h1>How do I find the most recent git commit that modified a file?</h1>
<p>I want to find the most recent commit that modified a source file. </p>
<p>I can use <code>git blame</code> to see all the dates for commits by each line, but it’s difficult to see exactly which commit was the last one to touch the file.</p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,537 | git | # How do I find the most recent git commit that modified a file?
I want to find the most recent commit that modified a source file.
I can use `git blame` to see all the dates for commits by each line, but it’s difficult to see exactly which commit was the last one to touch the file.
How can I find the last commit th... | # Everyday usage
[`git log`](https://git-scm.com/docs/git-log) supports looking at the history of specific files (and directories), so you can call it like this:
```
git log path/to/file
```
Tip: Whenever I look at the history of a specific file, I tend to also want to see the diffs, by passing `-p` (or `--patch`):
... |
19864934 | How can I throw away local git commits when getting "Your branch and 'origin/master' have diverged"? | 134 | 2013-11-08 17:21:16 | <p>I have the following message in git: </p>
<pre><code># Your branch and 'origin/master' have diverged,
# and have 3 and 8 different commits each, respectively.
# (use "git pull" to merge the remote branch into yours)
</code></pre>
<p>I would like to throw away the 3 local commits, and pull the 8 remote commits at... | 168,624 | 194,000 | 2023-04-29 10:06:55 | 19,864,960 | 370 | 2013-11-08 17:22:38 | 34,397 | 2023-04-29 10:05:41 | https://stackoverflow.com/q/19864934 | https://stackoverflow.com/a/19864960 | <pre><code>git fetch origin
git reset --hard origin/master
</code></pre>
<p>Note that any non-pushed commits or local changes will be lost.</p>
| <pre><code>git fetch origin git reset --hard origin/master </code></pre> <p>Note that any non-pushed commits or local changes will be lost.</p> | 119 | git | <h1>How can I throw away local git commits when getting "Your branch and 'origin/master' have diverged"?</h1>
<p>I have the following message in git: </p>
<pre><code># Your branch and 'origin/master' have diverged,
# and have 3 and 8 different commits each, respectively.
# (use "git pull" to merge the remote branch ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,540 | git | # How can I throw away local git commits when getting "Your branch and 'origin/master' have diverged"?
I have the following message in git:
```
# Your branch and 'origin/master' have diverged,
# and have 3 and 8 different commits each, respectively.
# (use "git pull" to merge the remote branch into yours)
```
I wo... | ```
git fetch origin
git reset --hard origin/master
```
Note that any non-pushed commits or local changes will be lost. |
2290016 | Git Commit Messages: 50/72 Formatting | 418 | 2010-02-18 16:02:56 | <p>Tim Pope argues for a particular Git commit message style in his blog post:
<a href="http://www.tpope.net/node/106" rel="noreferrer">http://www.tpope.net/node/106</a>.</p>
<p>Here is a quick summary of what he recommends:</p>
<ul>
<li>First line is 50 characters or less.</li>
<li>Then a blank line.</li>
<li>Remain... | 171,203 | 109,618 | 2023-10-30 19:02:37 | 11,993,051 | 369 | 2012-08-16 18:12:05 | 209,050 | 2020-02-20 03:06:45 | https://stackoverflow.com/q/2290016 | https://stackoverflow.com/a/11993051 | <p>Regarding the “summary” line (the 50 in your formula), the Linux kernel documentation <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=bc7938deaca7f474918c41a0372a410049bd4e13#n664" rel="noreferrer">has this to say</a>:</p>
<pre><code>F... | <p>Regarding the “summary” line (the 50 in your formula), the Linux kernel documentation <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=bc7938deaca7f474918c41a0372a410049bd4e13#n664" rel="noreferrer">has this to say</a>:</p> <pre><code>F... | 119, 3809, 53850 | commit-message, git, git-commit | <h1>Git Commit Messages: 50/72 Formatting</h1>
<p>Tim Pope argues for a particular Git commit message style in his blog post:
<a href="http://www.tpope.net/node/106" rel="noreferrer">http://www.tpope.net/node/106</a>.</p>
<p>Here is a quick summary of what he recommends:</p>
<ul>
<li>First line is 50 characters or le... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,541 | git | # Git Commit Messages: 50/72 Formatting
Tim Pope argues for a particular Git commit message style in his blog post:
<http://www.tpope.net/node/106>.
Here is a quick summary of what he recommends:
- First line is 50 characters or less.
- Then a blank line.
- Remaining text should be wrapped at 72 characters.
His blo... | Regarding the “summary” line (the 50 in your formula), the Linux kernel documentation [has this to say](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=bc7938deaca7f474918c41a0372a410049bd4e13#n664):
```
For these reasons, the "summary" must be no... |
4639091 | Undo “git add <dir>”? | 251 | 2011-01-09 12:25:28 | <p>I mistakenly added files using the command "git add dir". I have not yet run "git commit". Is there a way to remove this dir and everything contained within it from the commit?</p>
<p>I have tried <code>git reset dir</code>, but it didn't work. Apparently <code>git reset file</code> is the way to undo it. But I hav... | 115,614 | 78,336 | 2020-01-19 07:31:44 | 4,639,113 | 369 | 2011-01-09 12:32:10 | 9,410 | 2017-05-27 07:33:43 | https://stackoverflow.com/q/4639091 | https://stackoverflow.com/a/4639113 | <p>To remove a directory and everything inside it from the index,</p>
<pre><code>git rm <strong>--cached -r</strong> dir</code></pre>
<p>The <code>--cached</code> switch makes <code>git rm</code> operate on the index only and not touch the working copy. The <code>-r</code> switch makes it recursive.</p>
| <p>To remove a directory and everything inside it from the index,</p> <pre><code>git rm <strong>--cached -r</strong> dir</code></pre> <p>The <code>--cached</code> switch makes <code>git rm</code> operate on the index only and not touch the working copy. The <code>-r</code> switch makes it recursive.</p> | 119, 51381 | git, git-reset | <h1>Undo “git add <dir>”?</h1>
<p>I mistakenly added files using the command "git add dir". I have not yet run "git commit". Is there a way to remove this dir and everything contained within it from the commit?</p>
<p>I have tried <code>git reset dir</code>, but it didn't work. Apparently <code>git reset file</code> i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,542 | git | # Undo “git add ”?
I mistakenly added files using the command "git add dir". I have not yet run "git commit". Is there a way to remove this dir and everything contained within it from the commit?
I have tried `git reset dir`, but it didn't work. Apparently `git reset file` is the way to undo it. But I have so many fi... | To remove a directory and everything inside it from the index,
```
git rm --cached -r dir
```
The `--cached` switch makes `git rm` operate on the index only and not touch the working copy. The `-r` switch makes it recursive. |
3239759 | Checkout remote branch using git svn | 192 | 2010-07-13 17:31:41 | <p>I have checked out a svn repository using git svn. Now I need to checkout one of the branches and track it. Which is the best way to do it?</p>
| 123,597 | 181,150 | 2013-09-05 15:55:48 | 3,240,146 | 369 | 2010-07-13 18:18:47 | 123,109 | 2013-09-05 15:55:48 | https://stackoverflow.com/q/3239759 | https://stackoverflow.com/a/3240146 | <h2>Standard Subversion layout</h2>
<p>Create a git clone of that includes your Subversion trunk, tags, and branches with</p>
<pre>git svn clone http://svn.example.com/project -T trunk -b branches -t tags</pre>
<p>The <code>--stdlayout</code> option is a nice shortcut if your Subversion repository uses the typical s... | <h2>Standard Subversion layout</h2> <p>Create a git clone of that includes your Subversion trunk, tags, and branches with</p> <pre>git svn clone http://svn.example.com/project -T trunk -b branches -t tags</pre> <p>The <code>--stdlayout</code> option is a nice shortcut if your Subversion repository uses the typical s... | 119, 6452 | git, git-svn | <h1>Checkout remote branch using git svn</h1>
<p>I have checked out a svn repository using git svn. Now I need to checkout one of the branches and track it. Which is the best way to do it?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,543 | git | # Checkout remote branch using git svn
I have checked out a svn repository using git svn. Now I need to checkout one of the branches and track it. Which is the best way to do it? | ## Standard Subversion layout
Create a git clone of that includes your Subversion trunk, tags, and branches with
```
git svn clone http://svn.example.com/project -T trunk -b branches -t tags
```
The `--stdlayout` option is a nice shortcut if your Subversion repository uses the typical structure:
```
git svn clone h... |
10018533 | is it possible to `git status` only modified files? | 245 | 2012-04-04 20:10:59 | <p>Is it possible to have <code>git status</code> only show the modified files due, in my case, to having too many staged files?</p>
| 133,453 | 171,217 | 2025-06-06 02:46:09 | 10,018,728 | 368 | 2012-04-04 20:26:40 | 582 | 2019-01-19 22:10:53 | https://stackoverflow.com/q/10018533 | https://stackoverflow.com/a/10018728 | <p>You can't do this with <code>git status</code>, but you could use <code>git ls-files -m</code> to show all modified files.</p>
| <p>You can't do this with <code>git status</code>, but you could use <code>git ls-files -m</code> to show all modified files.</p> | 119, 549, 54839 | git, git-status, ubuntu | <h1>is it possible to `git status` only modified files?</h1>
<p>Is it possible to have <code>git status</code> only show the modified files due, in my case, to having too many staged files?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,545 | git | # is it possible to `git status` only modified files?
Is it possible to have `git status` only show the modified files due, in my case, to having too many staged files? | You can't do this with `git status`, but you could use `git ls-files -m` to show all modified files. |
36778375 | git - apply a commit on another branch to the working copy / Share content between branches and repositories | 226 | 2016-04-21 19:05:49 | <p>So I have a commit that has a helpful code change but it's on another branch.</p>
<p>I would like to apply this commit in the other branch to my working copy on my current branch (not as another commit).</p>
<p>Is this possible? How would I do this?</p>
<p>Thought I'd share this is related to my previous question bu... | 151,633 | 4,127,646 | 2025-02-28 00:33:59 | 36,782,730 | 368 | 2016-04-22 00:37:21 | 1,755,598 | 2025-02-28 00:33:59 | https://stackoverflow.com/q/36778375 | https://stackoverflow.com/a/36782730 | <h2>Use <a href="https://git-scm.com/docs/git-cherry-pick" rel="noreferrer"><code>git cherry-pick</code></a> to apply changes from existing commit(s)</h2>
<h3>Default: <code>cherry-pick</code> with immediate committing</h3>
<p>By default, <code>git cherry-pick <SHA-1> ...</code>
applies the changes introduced by ... | <h2>Use <a href="https://git-scm.com/docs/git-cherry-pick" rel="noreferrer"><code>git cherry-pick</code></a> to apply changes from existing commit(s)</h2> <h3>Default: <code>cherry-pick</code> with immediate committing</h3> <p>By default, <code>git cherry-pick <SHA-1> ...</code> applies the changes introduced by ... | 119 | git | <h1>git - apply a commit on another branch to the working copy / Share content between branches and repositories</h1>
<p>So I have a commit that has a helpful code change but it's on another branch.</p>
<p>I would like to apply this commit in the other branch to my working copy on my current branch (not as another comm... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,546 | git | # git - apply a commit on another branch to the working copy / Share content between branches and repositories
So I have a commit that has a helpful code change but it's on another branch.
I would like to apply this commit in the other branch to my working copy on my current branch (not as another commit).
Is this p... | ## Use [`git cherry-pick`](https://git-scm.com/docs/git-cherry-pick) to apply changes from existing commit(s)
### Default: `cherry-pick` with immediate committing
By default, `git cherry-pick <SHA-1> ...`
applies the changes introduced by each given commit and immediately creates one new commit on the current branch ... |
2073841 | How can I discard remote changes and mark a file as "resolved"? | 217 | 2010-01-15 18:28:00 | <p>I have some local files, I pull from remote branch and there are conflicts. I know that I would like to keep my local changes and ignore the remote changes causing conflicts. Is there a command I can use to in effect say "mark all conflicts as resolved, use local"?</p>
| 124,952 | 1,284,823 | 2019-04-30 06:35:16 | 2,073,854 | 368 | 2010-01-15 18:29:38 | 69,755 | 2017-09-07 11:49:31 | https://stackoverflow.com/q/2073841 | https://stackoverflow.com/a/2073854 | <p><a href="http://git-scm.com/docs/git-checkout" rel="noreferrer"><code>git checkout</code></a> has the <code>--ours</code> option to check out the version of the file that you had locally (as opposed to <code>--theirs</code>, which is the version that you pulled in). You can pass <code>.</code> to <code>git checkout<... | <p><a href="http://git-scm.com/docs/git-checkout" rel="noreferrer"><code>git checkout</code></a> has the <code>--ours</code> option to check out the version of the file that you had locally (as opposed to <code>--theirs</code>, which is the version that you pulled in). You can pass <code>.</code> to <code>git checkout<... | 119, 717, 3146, 106113 | conflict, git, git-merge-conflict, merge | <h1>How can I discard remote changes and mark a file as "resolved"?</h1>
<p>I have some local files, I pull from remote branch and there are conflicts. I know that I would like to keep my local changes and ignore the remote changes causing conflicts. Is there a command I can use to in effect say "mark all conflicts as... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,547 | git | # How can I discard remote changes and mark a file as "resolved"?
I have some local files, I pull from remote branch and there are conflicts. I know that I would like to keep my local changes and ignore the remote changes causing conflicts. Is there a command I can use to in effect say "mark all conflicts as resolved,... | [`git checkout`](http://git-scm.com/docs/git-checkout) has the `--ours` option to check out the version of the file that you had locally (as opposed to `--theirs`, which is the version that you pulled in). You can pass `.` to `git checkout` to tell it to check out everything in the tree. Then you need to mark the confl... |
10215197 | Git search for string in a single file's history | 282 | 2012-04-18 18:00:25 | <p>So if I have a file called <strong>foo.rb</strong> and it is giving me an error for a missing method called <strong>bar</strong>, so I want to search the history of <strong>foo.rb</strong> for the string <code>bar</code> to see if it was ever defined in the past.</p>
<p>I found this <a href="https://stackoverflow.c... | 76,785 | 46,011 | 2022-03-14 09:18:43 | 10,216,050 | 367 | 2012-04-18 18:55:53 | 106,205 | 2012-04-18 18:55:53 | https://stackoverflow.com/q/10215197 | https://stackoverflow.com/a/10216050 | <p>For this purpose you can use the -S option to git log:</p>
<pre><code>git log -S'bar' -- foo.rb
</code></pre>
| <p>For this purpose you can use the -S option to git log:</p> <pre><code>git log -S'bar' -- foo.rb </code></pre> | 119 | git | <h1>Git search for string in a single file's history</h1>
<p>So if I have a file called <strong>foo.rb</strong> and it is giving me an error for a missing method called <strong>bar</strong>, so I want to search the history of <strong>foo.rb</strong> for the string <code>bar</code> to see if it was ever defined in the p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,548 | git | # Git search for string in a single file's history
So if I have a file called **foo.rb** and it is giving me an error for a missing method called **bar**, so I want to search the history of **foo.rb** for the string `bar` to see if it was ever defined in the past.
I found this [Search all of Git history for a string?... | For this purpose you can use the -S option to git log:
```
git log -S'bar' -- foo.rb
``` |
8198105 | How does Git store files? | 335 | 2011-11-19 23:17:15 | <p>I just started learning Git and to do so, I started reading <a href="http://book.git-scm.com/" rel="noreferrer">the Git Community Book</a>, and in this book they say that <a href="https://en.wikipedia.org/wiki/Apache_Subversion" rel="noreferrer">SVN</a> and <a href="https://en.wikipedia.org/wiki/Concurrent_Versions_... | 138,031 | 1,055,834 | 2023-12-05 12:33:54 | 8,198,276 | 366 | 2011-11-19 23:47:36 | 6,309 | 2020-12-20 02:15:51 | https://stackoverflow.com/q/8198105 | https://stackoverflow.com/a/8198276 | <p>Git does include for each commit a full copy of all the files, except that, for the content already present in the Git repo, the snapshot will simply point to said content rather than duplicate it.<br />
That also means that several files with the same content are stored only once.</p>
<p>So a snapshot is basically ... | <p>Git does include for each commit a full copy of all the files, except that, for the content already present in the Git repo, the snapshot will simply point to said content rather than duplicate it.<br /> That also means that several files with the same content are stored only once.</p> <p>So a snapshot is basically ... | 119 | git | <h1>How does Git store files?</h1>
<p>I just started learning Git and to do so, I started reading <a href="http://book.git-scm.com/" rel="noreferrer">the Git Community Book</a>, and in this book they say that <a href="https://en.wikipedia.org/wiki/Apache_Subversion" rel="noreferrer">SVN</a> and <a href="https://en.wiki... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,549 | git | # How does Git store files?
I just started learning Git and to do so, I started reading [the Git Community Book](http://book.git-scm.com/), and in this book they say that [SVN](https://en.wikipedia.org/wiki/Apache_Subversion) and [CVS](https://en.wikipedia.org/wiki/Concurrent_Versions_System) store the difference betw... | Git does include for each commit a full copy of all the files, except that, for the content already present in the Git repo, the snapshot will simply point to said content rather than duplicate it.
That also means that several files with the same content are stored only once.
So a snapshot is basically a commit, ref... |
5863426 | Get commit list between tags in git | 306 | 2011-05-02 23:03:58 | <p>If I've a git repository with tags representing the versions of the releases. </p>
<p>How can I get the list of the commits between two tags (with a pretty format if is possible) ?</p>
| 166,297 | 735,231 | 2021-01-19 12:47:51 | 5,863,452 | 366 | 2011-05-02 23:08:30 | 526,535 | 2016-08-24 10:51:39 | https://stackoverflow.com/q/5863426 | https://stackoverflow.com/a/5863452 | <p><code>git log --pretty=oneline tagA...tagB</code> (i.e. three dots)</p>
<p>If you just wanted commits reachable from tagB but not tagA:</p>
<p><code>git log --pretty=oneline tagA..tagB</code> (i.e. two dots) </p>
<p>or</p>
<p><code>git log --pretty=oneline ^tagA tagB</code></p>
| <p><code>git log --pretty=oneline tagA...tagB</code> (i.e. three dots)</p> <p>If you just wanted commits reachable from tagB but not tagA:</p> <p><code>git log --pretty=oneline tagA..tagB</code> (i.e. two dots) </p> <p>or</p> <p><code>git log --pretty=oneline ^tagA tagB</code></p> | 119 | git | <h1>Get commit list between tags in git</h1>
<p>If I've a git repository with tags representing the versions of the releases. </p>
<p>How can I get the list of the commits between two tags (with a pretty format if is possible) ?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,550 | git | # Get commit list between tags in git
If I've a git repository with tags representing the versions of the releases.
How can I get the list of the commits between two tags (with a pretty format if is possible) ? | `git log --pretty=oneline tagA...tagB` (i.e. three dots)
If you just wanted commits reachable from tagB but not tagA:
`git log --pretty=oneline tagA..tagB` (i.e. two dots)
or
`git log --pretty=oneline ^tagA tagB` |
8554776 | How to filter git diff based on file extensions? | 273 | 2011-12-18 21:01:09 | <p>Is there an option to restrict <code>git diff</code> to a given set of file extensions?</p>
| 102,181 | 172,406 | 2024-04-19 08:34:11 | 8,554,987 | 366 | 2011-12-18 21:33:46 | 19,563 | 2011-12-18 21:33:46 | https://stackoverflow.com/q/8554776 | https://stackoverflow.com/a/8554987 | <p>Yes, if you ensure that git expands a glob rather than your shell then it will match at any level so something like this (quotes are important) should work fine.</p>
<pre><code>git diff -- '*.c' '*.h'
</code></pre>
| <p>Yes, if you ensure that git expands a glob rather than your shell then it will match at any level so something like this (quotes are important) should work fine.</p> <pre><code>git diff -- '*.c' '*.h' </code></pre> | 119, 1280 | file-extension, git | <h1>How to filter git diff based on file extensions?</h1>
<p>Is there an option to restrict <code>git diff</code> to a given set of file extensions?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,551 | git | # How to filter git diff based on file extensions?
Is there an option to restrict `git diff` to a given set of file extensions? | Yes, if you ensure that git expands a glob rather than your shell then it will match at any level so something like this (quotes are important) should work fine.
```
git diff -- '*.c' '*.h'
``` |
3301956 | Git: Correct way to change Active Branch in a bare repository? | 251 | 2010-07-21 17:15:13 | <p>I have a bare repository that's used as the central store for my project. All the developers do <code>git clone <repo></code> to share with it. When they do the clone, they get a checkout of the master branch (unless they do <code>git clone -n</code>) because <code>repo.git/HEAD</code> contains <code>ref: re... | 82,034 | 232,452 | 2022-07-30 18:10:13 | 3,302,018 | 366 | 2010-07-21 17:22:16 | 6,309 | 2014-03-20 19:42:03 | https://stackoverflow.com/q/3301956 | https://stackoverflow.com/a/3302018 | <p>If you have access to the remote bare repo, this <a href="http://feeding.cloud.geek.nz/2008/12/setting-default-git-branch-in-bare.html" rel="noreferrer">article suggests</a>:</p>
<pre><code>git symbolic-ref HEAD refs/heads/mybranch
</code></pre>
<blockquote>
<p>Which will update the HEAD file in your repository ... | <p>If you have access to the remote bare repo, this <a href="http://feeding.cloud.geek.nz/2008/12/setting-default-git-branch-in-bare.html" rel="noreferrer">article suggests</a>:</p> <pre><code>git symbolic-ref HEAD refs/heads/mybranch </code></pre> <blockquote> <p>Which will update the HEAD file in your repository ... | 119 | git | <h1>Git: Correct way to change Active Branch in a bare repository?</h1>
<p>I have a bare repository that's used as the central store for my project. All the developers do <code>git clone <repo></code> to share with it. When they do the clone, they get a checkout of the master branch (unless they do <code>git cl... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,552 | git | # Git: Correct way to change Active Branch in a bare repository?
I have a bare repository that's used as the central store for my project. All the developers do `git clone <repo>` to share with it. When they do the clone, they get a checkout of the master branch (unless they do `git clone -n`) because `repo.git/HEAD` ... | If you have access to the remote bare repo, this [article suggests](http://feeding.cloud.geek.nz/2008/12/setting-default-git-branch-in-bare.html):
```
git symbolic-ref HEAD refs/heads/mybranch
```
> Which will update the HEAD file in your repository so that it contains:
```
ref: refs/heads/mybranch
```
as documente... |
11358082 | Empty Git submodule folder when repo cloned | 214 | 2012-07-06 07:53:38 | <p>I have one repo hosted at <a href="https://github.com/aikiframework/json" rel="noreferrer">https://github.com/aikiframework/json</a>. On my local copy, I added a submodule using the command:</p>
<pre><code>git submodule add git@github.com:jcubic/json-rpc.git json-rpc
</code></pre>
<p>Then I did a commit and push, an... | 104,350 | 387,194 | 2025-04-03 14:52:01 | 11,358,126 | 366 | 2012-07-06 07:56:10 | 387,194 | 2023-07-21 11:29:26 | https://stackoverflow.com/q/11358082 | https://stackoverflow.com/a/11358126 | <p>OK I found it, needed to add <code>--recursive</code> when cloning the repo.</p>
<p>So the clone command ends up as:</p>
<pre><code>git clone https://github.com/aikiframework/json.git --recursive
</code></pre>
<p>Note that if you forgot the <code>--recursive</code> flag you can do (thanks to @Amber):</p>
<pre><code>... | <p>OK I found it, needed to add <code>--recursive</code> when cloning the repo.</p> <p>So the clone command ends up as:</p> <pre><code>git clone https://github.com/aikiframework/json.git --recursive </code></pre> <p>Note that if you forgot the <code>--recursive</code> flag you can do (thanks to @Amber):</p> <pre><code>... | 119, 456, 34099, 41612 | git, git-clone, git-submodules, version-control | <h1>Empty Git submodule folder when repo cloned</h1>
<p>I have one repo hosted at <a href="https://github.com/aikiframework/json" rel="noreferrer">https://github.com/aikiframework/json</a>. On my local copy, I added a submodule using the command:</p>
<pre><code>git submodule add git@github.com:jcubic/json-rpc.git json-... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,554 | git | # Empty Git submodule folder when repo cloned
I have one repo hosted at <https://github.com/aikiframework/json>. On my local copy, I added a submodule using the command:
```
git submodule add git@github.com:jcubic/json-rpc.git json-rpc
```
Then I did a commit and push, and the changes appear on GitHub (I can click o... | OK I found it, needed to add `--recursive` when cloning the repo.
So the clone command ends up as:
```
git clone https://github.com/aikiframework/json.git --recursive
```
Note that if you forgot the `--recursive` flag you can do (thanks to @Amber):
```
git submodule update --init
```
Note that when submodules have... |
14757437 | Git restore last detached HEAD | 124 | 2013-02-07 17:38:55 | <p>I have a big problem in my project: this is the scenario.
I have an xcode project under Git. Today I realized that the last commit broke some tests, so i checked out the previous commit.
I used SourceTree and this is the warning</p>
<blockquote>
<p>Doing so will make your working copy a 'detached HEAD', which means ... | 44,030 | 1,470,785 | 2022-07-14 18:51:28 | 14,757,539 | 366 | 2013-02-07 17:45:12 | 69,755 | 2013-02-07 17:50:16 | https://stackoverflow.com/q/14757437 | https://stackoverflow.com/a/14757539 | <p>If you type <code>git reflog</code>, it will show you the history of what revisions <code>HEAD</code> pointed to. Your detached head should be in there. Once you find it, do <code>git checkout -b my-new-branch abc123</code> or <code>git branch my-new-branch abc123</code> (where <code>abc123</code> is the SHA-1 of th... | <p>If you type <code>git reflog</code>, it will show you the history of what revisions <code>HEAD</code> pointed to. Your detached head should be in there. Once you find it, do <code>git checkout -b my-new-branch abc123</code> or <code>git branch my-new-branch abc123</code> (where <code>abc123</code> is the SHA-1 of th... | 119 | git | <h1>Git restore last detached HEAD</h1>
<p>I have a big problem in my project: this is the scenario.
I have an xcode project under Git. Today I realized that the last commit broke some tests, so i checked out the previous commit.
I used SourceTree and this is the warning</p>
<blockquote>
<p>Doing so will make your work... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,555 | git | # Git restore last detached HEAD
I have a big problem in my project: this is the scenario.
I have an xcode project under Git. Today I realized that the last commit broke some tests, so i checked out the previous commit.
I used SourceTree and this is the warning
> Doing so will make your working copy a 'detached HEAD'... | If you type `git reflog`, it will show you the history of what revisions `HEAD` pointed to. Your detached head should be in there. Once you find it, do `git checkout -b my-new-branch abc123` or `git branch my-new-branch abc123` (where `abc123` is the SHA-1 of the detached HEAD) to create a new branch that points to you... |
1710894 | Using Git, show all commits that are in one branch, but not the other(s) | 634 | 2009-11-10 20:17:15 | <p>I have an old branch, which I would like to delete. However, before doing so, I want to check that all commits made to this branch were at some point merged into some other branch. Thus, I'd like to see all commits made to my current branch which have not been applied to any other branch [or, if this is not possible... | 333,879 | 196,429 | 2021-07-20 08:40:50 | 1,710,951 | 365 | 2009-11-10 20:26:28 | 39,975 | 2012-09-07 14:12:02 | https://stackoverflow.com/q/1710894 | https://stackoverflow.com/a/1710951 | <p>You probably just want</p>
<pre><code>git branch --contains branch-to-delete
</code></pre>
<p>This will list all branches which contain the commits from "branch-to-delete".
If it reports more than just "branch-to-delete", the branch has been merged.</p>
<p>Your alternatives are really just rev-list syntax things.... | <p>You probably just want</p> <pre><code>git branch --contains branch-to-delete </code></pre> <p>This will list all branches which contain the commits from "branch-to-delete". If it reports more than just "branch-to-delete", the branch has been merged.</p> <p>Your alternatives are really just rev-list syntax things.... | 119, 1879, 76220 | branch, git, git-branch | <h1>Using Git, show all commits that are in one branch, but not the other(s)</h1>
<p>I have an old branch, which I would like to delete. However, before doing so, I want to check that all commits made to this branch were at some point merged into some other branch. Thus, I'd like to see all commits made to my current b... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,556 | git | # Using Git, show all commits that are in one branch, but not the other(s)
I have an old branch, which I would like to delete. However, before doing so, I want to check that all commits made to this branch were at some point merged into some other branch. Thus, I'd like to see all commits made to my current branch whi... | You probably just want
```
git branch --contains branch-to-delete
```
This will list all branches which contain the commits from "branch-to-delete".
If it reports more than just "branch-to-delete", the branch has been merged.
Your alternatives are really just rev-list syntax things. e.g. `git log one-branch..another... |
12870928 | (Mac) -bash: __git_ps1: command not found | 249 | 2012-10-13 07:20:43 | <p>I'm trying to change my command promt in terminal. I keep getting the error:</p>
<p><code>-bash: __git_ps1: command not found</code></p>
<p>I've tried it just by typing it into the terminal as is: <code>__git_ps1</code>. I've also tried it out in the <code>.bash_profile</code></p>
<pre><code>if [ -f ~/.git-completio... | 166,355 | 908,423 | 2023-03-03 19:41:22 | 12,871,094 | 365 | 2012-10-13 07:47:19 | 223,092 | 2023-03-03 19:41:22 | https://stackoverflow.com/q/12870928 | https://stackoverflow.com/a/12871094 | <p>You've installed the version of <code>git-completion.bash</code> from <code>master</code> - in git's development history this is after a commit that split out the <code>__git_ps1</code> function from the completion functionality into a new file (<code>git-prompt.sh</code>). The commit that introduced this change, w... | <p>You've installed the version of <code>git-completion.bash</code> from <code>master</code> - in git's development history this is after a commit that split out the <code>__git_ps1</code> function from the completion functionality into a new file (<code>git-prompt.sh</code>). The commit that introduced this change, w... | 119, 369, 391, 53034 | git, macos, ps1, terminal | <h1>(Mac) -bash: __git_ps1: command not found</h1>
<p>I'm trying to change my command promt in terminal. I keep getting the error:</p>
<p><code>-bash: __git_ps1: command not found</code></p>
<p>I've tried it just by typing it into the terminal as is: <code>__git_ps1</code>. I've also tried it out in the <code>.bash_pro... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,557 | git | # (Mac) -bash: __git_ps1: command not found
I'm trying to change my command promt in terminal. I keep getting the error:
`-bash: __git_ps1: command not found`
I've tried it just by typing it into the terminal as is: `__git_ps1`. I've also tried it out in the `.bash_profile`
```
if [ -f ~/.git-completion.bash ]; the... | You've installed the version of `git-completion.bash` from `master` - in git's development history this is after a commit that split out the `__git_ps1` function from the completion functionality into a new file (`git-prompt.sh`). The commit that introduced this change, which explains the rationale, is [af31a456](https... |
7615807 | renamed heroku app from website, now it's not found | 169 | 2011-09-30 20:35:13 | <p>After renaming my heroku app from the heroku website, whenever I cd to its directory in a terminal and run any heroku command, I get <code>App not found</code>. Does anybody know of a way to remedy this?</p>
| 33,008 | 454,761 | 2020-06-07 16:19:30 | 7,616,075 | 365 | 2011-09-30 21:04:26 | 77,409 | 2011-09-30 21:04:26 | https://stackoverflow.com/q/7615807 | https://stackoverflow.com/a/7616075 | <p>Try to update the git remote for the app:</p>
<pre><code>git remote rm heroku
git remote add heroku git@heroku.com:yourappname.git
</code></pre>
| <p>Try to update the git remote for the app:</p> <pre><code>git remote rm heroku git remote add heroku git@heroku.com:yourappname.git </code></pre> | 119, 8279 | git, heroku | <h1>renamed heroku app from website, now it's not found</h1>
<p>After renaming my heroku app from the heroku website, whenever I cd to its directory in a terminal and run any heroku command, I get <code>App not found</code>. Does anybody know of a way to remedy this?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,558 | git | # renamed heroku app from website, now it's not found
After renaming my heroku app from the heroku website, whenever I cd to its directory in a terminal and run any heroku command, I get `App not found`. Does anybody know of a way to remedy this? | Try to update the git remote for the app:
```
git remote rm heroku
git remote add heroku git@heroku.com:yourappname.git
``` |
7813194 | How do I edit an existing tag message in Git? | 306 | 2011-10-18 20:21:11 | <p>We have several annotated tags in our Git repository. The older tags have bogus messages that we would like to update to be in our new style.</p>
<pre><code>% git tag -n1
v1.0 message
v1.1 message
v1.2 message
v2.0 Version 2.0 built on 15 October 2011.
</code></pre>
<p>In this example, we would like to make v1.x mes... | 149,055 | 509,608 | 2025-03-30 09:36:42 | 7,813,236 | 363 | 2011-10-18 20:24:32 | 275,354 | 2022-02-16 15:44:05 | https://stackoverflow.com/q/7813194 | https://stackoverflow.com/a/7813236 | <pre class="lang-sh prettyprint-override"><code>git tag <tag name> <tag name>^{} -f -m "<new message>"
</code></pre>
<p>This will create a new tag with the same name (by overwriting the original).</p>
| <pre class="lang-sh prettyprint-override"><code>git tag <tag name> <tag name>^{} -f -m "<new message>" </code></pre> <p>This will create a new tag with the same name (by overwriting the original).</p> | 119, 60718 | git, git-tag | <h1>How do I edit an existing tag message in Git?</h1>
<p>We have several annotated tags in our Git repository. The older tags have bogus messages that we would like to update to be in our new style.</p>
<pre><code>% git tag -n1
v1.0 message
v1.1 message
v1.2 message
v2.0 Version 2.0 built on 15 October 2011.
</code></... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,560 | git | # How do I edit an existing tag message in Git?
We have several annotated tags in our Git repository. The older tags have bogus messages that we would like to update to be in our new style.
```
% git tag -n1
v1.0 message
v1.1 message
v1.2 message
v2.0 Version 2.0 built on 15 October 2011.
```
In this example, we wou... | ```
git tag <tag name> <tag name>^{} -f -m "<new message>"
```
This will create a new tag with the same name (by overwriting the original). |
6270193 | How can I have multiple working directories with Git? | 299 | 2011-06-07 18:53:28 | <p>I'm not sure if this is something supported by Git, but in theory it seems like it should work to me.</p>
<p>My workflow often involves my editing of files in multiple branches simultaneously. In other words, I often want to open a few files in one branch is while I edit the contents of another file in another branc... | 139,538 | 379,568 | 2025-03-05 16:46:38 | 30,185,564 | 361 | 2015-05-12 08:28:41 | 6,309 | 2020-11-06 07:57:53 | https://stackoverflow.com/q/6270193 | https://stackoverflow.com/a/30185564 | <p>Git 2.5 proposes since July 2015 a replacement for <code>contrib/workdir/git-new-workdir</code>: <a href="https://git-scm.com/docs/git-worktree" rel="noreferrer"><strong>git worktree</strong></a></p>
<p>See <a href="https://github.com/git/git/commit/68a2e6a2c80303144807c8c91a087427e3c8e727" rel="noreferrer">commit 6... | <p>Git 2.5 proposes since July 2015 a replacement for <code>contrib/workdir/git-new-workdir</code>: <a href="https://git-scm.com/docs/git-worktree" rel="noreferrer"><strong>git worktree</strong></a></p> <p>See <a href="https://github.com/git/git/commit/68a2e6a2c80303144807c8c91a087427e3c8e727" rel="noreferrer">commit 6... | 119, 117020 | git, git-worktree | <h1>How can I have multiple working directories with Git?</h1>
<p>I'm not sure if this is something supported by Git, but in theory it seems like it should work to me.</p>
<p>My workflow often involves my editing of files in multiple branches simultaneously. In other words, I often want to open a few files in one branc... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,561 | git | # How can I have multiple working directories with Git?
I'm not sure if this is something supported by Git, but in theory it seems like it should work to me.
My workflow often involves my editing of files in multiple branches simultaneously. In other words, I often want to open a few files in one branch is while I ed... | Git 2.5 proposes since July 2015 a replacement for `contrib/workdir/git-new-workdir`: [**git worktree**](https://git-scm.com/docs/git-worktree)
See [commit 68a2e6a](https://github.com/git/git/commit/68a2e6a2c80303144807c8c91a087427e3c8e727) by [Junio C Hamano (`gitster`)](https://github.com/gitster).
The [release not... |
13542213 | Git, see a list of comments of my last N commits | 251 | 2012-11-24 14:36:11 | <p>Is there a way to see a list of comments and time of my last N commits in Git?</p>
<p>After looking on SO, the only relevant thing I have found is
<a href="https://stackoverflow.com/questions/1314950/git-get-all-commits-and-blobs-they-created">Git - get all commits and blobs they created</a>, but it shows all commi... | 193,094 | 1,090,562 | 2022-10-07 19:42:51 | 13,542,327 | 361 | 2012-11-24 14:50:34 | 41,116 | 2014-04-03 18:29:15 | https://stackoverflow.com/q/13542213 | https://stackoverflow.com/a/13542327 | <p>If you want to use the command line you can use the <code>--author=<your name></code></p>
<p>For example: to see your last 5 commits</p>
<pre><code>git log -n 5 --author=Salvador
</code></pre>
<p>If you want a simpler one line solution:</p>
<pre><code>git log --oneline -n 5 --author=Salvador
</code></pre>
... | <p>If you want to use the command line you can use the <code>--author=<your name></code></p> <p>For example: to see your last 5 commits</p> <pre><code>git log -n 5 --author=Salvador </code></pre> <p>If you want a simpler one line solution:</p> <pre><code>git log --oneline -n 5 --author=Salvador </code></pre> ... | 119, 53850 | git, git-commit | <h1>Git, see a list of comments of my last N commits</h1>
<p>Is there a way to see a list of comments and time of my last N commits in Git?</p>
<p>After looking on SO, the only relevant thing I have found is
<a href="https://stackoverflow.com/questions/1314950/git-get-all-commits-and-blobs-they-created">Git - get all ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,562 | git | # Git, see a list of comments of my last N commits
Is there a way to see a list of comments and time of my last N commits in Git?
After looking on SO, the only relevant thing I have found is
[Git - get all commits and blobs they created](https://stackoverflow.com/questions/1314950/git-get-all-commits-and-blobs-they-c... | If you want to use the command line you can use the `--author=<your name>`
For example: to see your last 5 commits
```
git log -n 5 --author=Salvador
```
If you want a simpler one line solution:
```
git log --oneline -n 5 --author=Salvador
```
**Edited to add**
If you like the single line version, try creating an... |
1722807 | How to convert `git:` urls to `http:` urls | 178 | 2009-11-12 15:00:23 | <p>I'm working behind an http proxy. I'm trying to clone Android's source tree using their "repo" tool. </p>
<p>This tool insists on using <code>git://</code> URLs, even though <code>http://</code> URLs also work. As a result, I can't download the source.</p>
<p>Is it possible to force <code>git</code> to always use ... | 148,890 | 38,557 | 2022-02-08 03:22:58 | 11,383,587 | 361 | 2012-07-08 13:40:40 | 229,753 | 2022-02-08 03:22:58 | https://stackoverflow.com/q/1722807 | https://stackoverflow.com/a/11383587 | <p>Here's an example of rewriting the default protocol for GitHub:</p>
<pre><code>git config --global url.https://github.com/.insteadOf git://github.com/
</code></pre>
<p>The exact values depend on the protocol in use. For example, the above command for git over ssh will look like:</p>
<pre><code>git config --global ur... | <p>Here's an example of rewriting the default protocol for GitHub:</p> <pre><code>git config --global url.https://github.com/.insteadOf git://github.com/ </code></pre> <p>The exact values depend on the protocol in use. For example, the above command for git over ssh will look like:</p> <pre><code>git config --global ur... | 119, 760 | git, proxy | <h1>How to convert `git:` urls to `http:` urls</h1>
<p>I'm working behind an http proxy. I'm trying to clone Android's source tree using their "repo" tool. </p>
<p>This tool insists on using <code>git://</code> URLs, even though <code>http://</code> URLs also work. As a result, I can't download the source.</p>
<p>Is ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,563 | git | # How to convert `git:` urls to `http:` urls
I'm working behind an http proxy. I'm trying to clone Android's source tree using their "repo" tool.
This tool insists on using `git://` URLs, even though `http://` URLs also work. As a result, I can't download the source.
Is it possible to force `git` to always use `http... | Here's an example of rewriting the default protocol for GitHub:
```
git config --global url.https://github.com/.insteadOf git://github.com/
```
The exact values depend on the protocol in use. For example, the above command for git over ssh will look like:
```
git config --global url.https://github.com/.insteadOf git... |
14489109 | How to alias 'git checkout' to 'git co' | 191 | 2013-01-23 20:49:50 | <p>I'd like the command <code>git co</code> to be the same as typing <code>git checkout</code>.</p>
<p>A normal Bash alias (<code>alias co='checkout'</code>) doesn't work.</p>
| 66,581 | 1,192,740 | 2019-12-12 21:34:00 | 14,489,111 | 359 | 2013-01-23 20:49:50 | 1,192,740 | 2013-01-23 20:49:50 | https://stackoverflow.com/q/14489109 | https://stackoverflow.com/a/14489111 | <p>The command:</p>
<p><code>git config --global alias.co checkout</code></p>
<p>will create a git alias to do that. It will add the following entry into your global <code>~/.gitconfig</code> file:</p>
<pre><code>[alias]
co = checkout
</code></pre>
| <p>The command:</p> <p><code>git config --global alias.co checkout</code></p> <p>will create a git alias to do that. It will add the following entry into your global <code>~/.gitconfig</code> file:</p> <pre><code>[alias] co = checkout </code></pre> | 119, 1448, 79211 | alias, git, git-alias | <h1>How to alias 'git checkout' to 'git co'</h1>
<p>I'd like the command <code>git co</code> to be the same as typing <code>git checkout</code>.</p>
<p>A normal Bash alias (<code>alias co='checkout'</code>) doesn't work.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,566 | git | # How to alias 'git checkout' to 'git co'
I'd like the command `git co` to be the same as typing `git checkout`.
A normal Bash alias (`alias co='checkout'`) doesn't work. | The command:
`git config --global alias.co checkout`
will create a git alias to do that. It will add the following entry into your global `~/.gitconfig` file:
```
[alias]
co = checkout
``` |
15589682 | How to fix "ssh: connect to host github.com port 22: Connection timed out" for git push/pull/... commands | 484 | 2013-03-23 17:13:26 | <p>I am under a proxy and I am pushing in to git successfully for quite a while.<br>
Now I am not able to push into git all of a sudden.<br>
I have set the RSA key and the proxy and double checked them, with no avail and git is throwing me the error shown in the title of the page.</p>
| 864,633 | 1,664,812 | 2025-12-16 17:01:40 | 15,589,683 | 358 | 2013-03-23 17:13:26 | 1,664,812 | 2024-02-27 00:21:54 | https://stackoverflow.com/q/15589682 | https://stackoverflow.com/a/15589683 | <p>The reason could be the firewall modification since you are on a network, in which case they may deliberately block some ports.</p>
<p>To double check if this is the reason, run:</p>
<pre><code>ssh -T git@github.com
</code></pre>
<p>This should timeout. If that's the case, then use the <code>http</code> protocol in... | <p>The reason could be the firewall modification since you are on a network, in which case they may deliberately block some ports.</p> <p>To double check if this is the reason, run:</p> <pre><code>ssh -T git@github.com </code></pre> <p>This should timeout. If that's the case, then use the <code>http</code> protocol in... | 119, 386 | git, ssh | <h1>How to fix "ssh: connect to host github.com port 22: Connection timed out" for git push/pull/... commands</h1>
<p>I am under a proxy and I am pushing in to git successfully for quite a while.<br>
Now I am not able to push into git all of a sudden.<br>
I have set the RSA key and the proxy and double checked them, wi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,568 | git | # How to fix "ssh: connect to host github.com port 22: Connection timed out" for git push/pull/... commands
I am under a proxy and I am pushing in to git successfully for quite a while.
Now I am not able to push into git all of a sudden.
I have set the RSA key and the proxy and double checked them, with no avail a... | The reason could be the firewall modification since you are on a network, in which case they may deliberately block some ports.
To double check if this is the reason, run:
```
ssh -T git@github.com
```
This should timeout. If that's the case, then use the `http` protocol instead of ssh. Change your url in the config... |
5785549 | Able to push to all git remotes with the one command? | 276 | 2011-04-26 03:19:49 | <p>Instead of doing:</p>
<pre><code>git push origin --all && git push nodester --all && git push duostack --all
</code></pre>
<p>Is there a way to do that with just one command?</p>
| 64,497 | 130,638 | 2024-09-11 12:02:56 | 18,674,313 | 358 | 2013-09-07 14:27:03 | 222,893 | 2024-01-27 11:29:13 | https://stackoverflow.com/q/5785549 | https://stackoverflow.com/a/18674313 | <h3>To push all branches to all remotes:</h3>
<pre><code>git remote | xargs -L1 git push --all
</code></pre>
<h3>Or if you want to push the current branch to all remotes:</h3>
<pre><code>git remote | xargs -L1 -I R git push R
</code></pre>
<h3>(Bonus) To make a git alias for the command:</h3>
<pre><code>git config --gl... | <h3>To push all branches to all remotes:</h3> <pre><code>git remote | xargs -L1 git push --all </code></pre> <h3>Or if you want to push the current branch to all remotes:</h3> <pre><code>git remote | xargs -L1 -I R git push R </code></pre> <h3>(Bonus) To make a git alias for the command:</h3> <pre><code>git config --gl... | 119 | git | <h1>Able to push to all git remotes with the one command?</h1>
<p>Instead of doing:</p>
<pre><code>git push origin --all && git push nodester --all && git push duostack --all
</code></pre>
<p>Is there a way to do that with just one command?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,569 | git | # Able to push to all git remotes with the one command?
Instead of doing:
```
git push origin --all && git push nodester --all && git push duostack --all
```
Is there a way to do that with just one command? | ### To push all branches to all remotes:
```
git remote | xargs -L1 git push --all
```
### Or if you want to push the current branch to all remotes:
```
git remote | xargs -L1 -I R git push R
```
### (Bonus) To make a git alias for the command:
```
git config --global alias.pushall '!git remote | xargs -L1 git pus... |
5096268 | How to get a list of all files that changed between two Git commits? | 263 | 2011-02-23 19:50:31 | <p>Due to bureaucracy, I need to get a list of all changed files in my repository for a report (I started with existing source code).</p>
<p>What should I run to get this list?</p>
| 355,043 | 67,505 | 2022-04-11 10:36:29 | 5,096,294 | 358 | 2011-02-23 19:52:44 | 148,870 | 2021-04-21 18:32:12 | https://stackoverflow.com/q/5096268 | https://stackoverflow.com/a/5096294 | <p>For files changed between a given SHA and your current commit:</p>
<pre><code>git diff --name-only <starting SHA> HEAD
</code></pre>
<p>or if you want to include changed-but-not-yet-committed files:</p>
<pre><code>git diff --name-only <starting SHA>
</code></pre>
<p>More generally, the following syntax w... | <p>For files changed between a given SHA and your current commit:</p> <pre><code>git diff --name-only <starting SHA> HEAD </code></pre> <p>or if you want to include changed-but-not-yet-committed files:</p> <pre><code>git diff --name-only <starting SHA> </code></pre> <p>More generally, the following syntax w... | 119 | git | <h1>How to get a list of all files that changed between two Git commits?</h1>
<p>Due to bureaucracy, I need to get a list of all changed files in my repository for a report (I started with existing source code).</p>
<p>What should I run to get this list?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,570 | git | # How to get a list of all files that changed between two Git commits?
Due to bureaucracy, I need to get a list of all changed files in my repository for a report (I started with existing source code).
What should I run to get this list? | For files changed between a given SHA and your current commit:
```
git diff --name-only <starting SHA> HEAD
```
or if you want to include changed-but-not-yet-committed files:
```
git diff --name-only <starting SHA>
```
More generally, the following syntax will always tell you which files changed between two commits... |
46273032 | Is there a way to remove all ignored files from a local git working tree? | 176 | 2017-09-18 06:42:19 | <p>Yesterday I spent several hours debugging a problem with my git repo that wasn't fixed by <code>git reset HEAD --hard</code> because the files causing the problem were ignored by <code>.gitignore</code>. Is there a way to "flush" or "clean" a git repo of all files that are being ignored, so that only the files trac... | 66,751 | 1,209,486 | 2024-06-22 17:37:32 | 46,273,201 | 358 | 2017-09-18 06:52:20 | 4,620,609 | 2024-06-19 11:15:51 | https://stackoverflow.com/q/46273032 | https://stackoverflow.com/a/46273201 | <pre><code>git clean -dfX
</code></pre>
<p><code>git-clean</code> - Remove untracked files from the working tree<br>
<code>-d</code> Remove directories<br>
<code>-f</code> Remove forcefully<br>
<code>-n</code> Don’t actually remove anything, just show what would be done.<br>
<code>-X</code> Remove only files ignored by... | <pre><code>git clean -dfX </code></pre> <p><code>git-clean</code> - Remove untracked files from the working tree<br> <code>-d</code> Remove directories<br> <code>-f</code> Remove forcefully<br> <code>-n</code> Don’t actually remove anything, just show what would be done.<br> <code>-X</code> Remove only files ignored by... | 119 | git | <h1>Is there a way to remove all ignored files from a local git working tree?</h1>
<p>Yesterday I spent several hours debugging a problem with my git repo that wasn't fixed by <code>git reset HEAD --hard</code> because the files causing the problem were ignored by <code>.gitignore</code>. Is there a way to "flush" or ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,571 | git | # Is there a way to remove all ignored files from a local git working tree?
Yesterday I spent several hours debugging a problem with my git repo that wasn't fixed by `git reset HEAD --hard` because the files causing the problem were ignored by `.gitignore`. Is there a way to "flush" or "clean" a git repo of all files ... | ```
git clean -dfX
```
`git-clean` - Remove untracked files from the working tree
`-d` Remove directories
`-f` Remove forcefully
`-n` Don’t actually remove anything, just show what would be done.
`-X` Remove only files ignored by Git. This may be useful to rebuild everything from scratch, but keep manually cre... |
15404535 | How to git reset --hard a subdirectory | 317 | 2013-03-14 08:40:35 | <blockquote>
<p><strong>UPDATE²</strong>: With Git 2.23 (August 2019), there's a new command <code>git restore</code> that does this, see the <a href="https://stackoverflow.com/a/15404733/946850">accepted answer</a>.</p>
</blockquote>
<blockquote>
<p><strong>UPDATE</strong>: This will work more intuitively as of Git 1.... | 302,981 | 946,850 | 2023-05-20 15:22:07 | 15,404,733 | 357 | 2013-03-14 08:51:14 | 6,309 | 2023-05-20 15:22:07 | https://stackoverflow.com/q/15404535 | https://stackoverflow.com/a/15404733 | <p>With Git 2.23 (August 2019), you have the <a href="https://stackoverflow.com/a/57066072/6309">new command <code>git restore</code></a> (also <a href="https://stackoverflow.com/a/58003889/6309">presented here</a>)</p>
<pre class="lang-bash prettyprint-override"><code>git restore --source=HEAD --staged --worktree -- a... | <p>With Git 2.23 (August 2019), you have the <a href="https://stackoverflow.com/a/57066072/6309">new command <code>git restore</code></a> (also <a href="https://stackoverflow.com/a/58003889/6309">presented here</a>)</p> <pre class="lang-bash prettyprint-override"><code>git restore --source=HEAD --staged --worktree -- a... | 119, 12626, 50925, 51381 | git, git-reset, reset, sparse-checkout | <h1>How to git reset --hard a subdirectory</h1>
<blockquote>
<p><strong>UPDATE²</strong>: With Git 2.23 (August 2019), there's a new command <code>git restore</code> that does this, see the <a href="https://stackoverflow.com/a/15404733/946850">accepted answer</a>.</p>
</blockquote>
<blockquote>
<p><strong>UPDATE</stron... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,572 | git | # How to git reset --hard a subdirectory
> **UPDATE²**: With Git 2.23 (August 2019), there's a new command `git restore` that does this, see the [accepted answer](https://stackoverflow.com/a/15404733/946850).
> **UPDATE**: This will work more intuitively as of Git 1.8.3, see [my own answer](https://stackoverflow.com/... | With Git 2.23 (August 2019), you have the [new command `git restore`](https://stackoverflow.com/a/57066072/6309) (also [presented here](https://stackoverflow.com/a/58003889/6309))
```
git restore --source=HEAD --staged --worktree -- aDirectory
# or, shorter
git restore -s@ -SW -- aDirectory
```
That would replace bot... |
4082126 | git log of a single revision | 234 | 2010-11-02 21:10:08 | <p>I have a commit c. I want to get the changeset of that exact commit c + metainformation and no other one. Is there a simpler way than <code>git log -p c^..c</code> to do that?</p>
| 129,142 | 42,645 | 2020-01-15 16:38:50 | 4,082,188 | 356 | 2010-11-02 21:20:16 | 308,392 | 2019-02-14 11:04:46 | https://stackoverflow.com/q/4082126 | https://stackoverflow.com/a/4082188 | <p>You can use <a href="https://git-scm.com/docs/git-show" rel="noreferrer"><code>show</code></a>:</p>
<pre><code>git show commit_id
</code></pre>
| <p>You can use <a href="https://git-scm.com/docs/git-show" rel="noreferrer"><code>show</code></a>:</p> <pre><code>git show commit_id </code></pre> | 119, 47913 | git, git-log | <h1>git log of a single revision</h1>
<p>I have a commit c. I want to get the changeset of that exact commit c + metainformation and no other one. Is there a simpler way than <code>git log -p c^..c</code> to do that?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,573 | git | # git log of a single revision
I have a commit c. I want to get the changeset of that exact commit c + metainformation and no other one. Is there a simpler way than `git log -p c^..c` to do that? | You can use [`show`](https://git-scm.com/docs/git-show):
```
git show commit_id
``` |
41049711 | Git how to rollback a rebase | 177 | 2016-12-08 22:08:45 | <p>In Git, how do you rollback a rebase if you're not happy with it?</p>
<p>Git doesn't have dry-run for rebase. If I did a rebase and have not pushed it yet, how do I rollback to before, as if it never happened?</p>
| 167,012 | 1,615,666 | 2024-11-16 09:24:32 | 41,049,867 | 356 | 2016-12-08 22:21:32 | 459,517 | 2021-11-24 11:05:48 | https://stackoverflow.com/q/41049711 | https://stackoverflow.com/a/41049867 | <p>You can use the <a href="https://git-scm.com/docs/git-reflog" rel="noreferrer">reflog</a> to find the first action before the rebase started and then reset --hard back to it. e.g.</p>
<pre><code>$ git reflog
b710729 HEAD@{0}: rebase: some commit
5ad7c1c HEAD@{1}: rebase: another commit
deafcbf HEAD@{2}: checkout: m... | <p>You can use the <a href="https://git-scm.com/docs/git-reflog" rel="noreferrer">reflog</a> to find the first action before the rebase started and then reset --hard back to it. e.g.</p> <pre><code>$ git reflog b710729 HEAD@{0}: rebase: some commit 5ad7c1c HEAD@{1}: rebase: another commit deafcbf HEAD@{2}: checkout: m... | 119, 2200, 12196, 29934 | git, git-rebase, recovery, rollback | <h1>Git how to rollback a rebase</h1>
<p>In Git, how do you rollback a rebase if you're not happy with it?</p>
<p>Git doesn't have dry-run for rebase. If I did a rebase and have not pushed it yet, how do I rollback to before, as if it never happened?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,574 | git | # Git how to rollback a rebase
In Git, how do you rollback a rebase if you're not happy with it?
Git doesn't have dry-run for rebase. If I did a rebase and have not pushed it yet, how do I rollback to before, as if it never happened? | You can use the [reflog](https://git-scm.com/docs/git-reflog) to find the first action before the rebase started and then reset --hard back to it. e.g.
```
$ git reflog
b710729 HEAD@{0}: rebase: some commit
5ad7c1c HEAD@{1}: rebase: another commit
deafcbf HEAD@{2}: checkout: moving from master to my-branch
...
$ git... |
1377845 | Git reset --hard and push to remote repository | 284 | 2009-09-04 08:05:22 | <p>I had a repository that had some bad commits on it (D, E and F for this example).</p>
<blockquote>
<p>A-B-C-D-E-F master and origin/master</p>
</blockquote>
<p>I've modified the local repository specifically with a <code>git reset --hard</code>. I took a branch before the reset so now I have a repo that looks l... | 427,814 | 11,219 | 2024-05-03 00:45:58 | 1,377,930 | 355 | 2009-09-04 08:22:36 | 46,058 | 2021-03-27 10:08:52 | https://stackoverflow.com/q/1377845 | https://stackoverflow.com/a/1377930 | <p>If forcing a push doesn't help (<code>git push --force origin</code> or <code>git push --force origin master</code> should be enough), it might mean that the remote server is refusing non fast-forward pushes, via either <code>receive.denyNonFastForwards</code> config variable (see <a href="https://git-scm.com/docs/... | <p>If forcing a push doesn't help (<code>git push --force origin</code> or <code>git push --force origin master</code> should be enough), it might mean that the remote server is refusing non fast-forward pushes, via either <code>receive.denyNonFastForwards</code> config variable (see <a href="https://git-scm.com/docs/... | 119 | git | <h1>Git reset --hard and push to remote repository</h1>
<p>I had a repository that had some bad commits on it (D, E and F for this example).</p>
<blockquote>
<p>A-B-C-D-E-F master and origin/master</p>
</blockquote>
<p>I've modified the local repository specifically with a <code>git reset --hard</code>. I took a b... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,575 | git | # Git reset --hard and push to remote repository
I had a repository that had some bad commits on it (D, E and F for this example).
> A-B-C-D-E-F master and origin/master
I've modified the local repository specifically with a `git reset --hard`. I took a branch before the reset so now I have a repo that looks like:
... | If forcing a push doesn't help (`git push --force origin` or `git push --force origin master` should be enough), it might mean that the remote server is refusing non fast-forward pushes, via either `receive.denyNonFastForwards` config variable (see [git config](https://git-scm.com/docs/git-config "git-config - Get and ... |
19987099 | How do I view all commits for a specific day? | 271 | 2013-11-14 19:55:05 | <p>I've already looked at the relevant docs from <a href="http://git-scm.com/book/ch2-3.html">git-scm.com</a> and <a href="http://gitref.org/inspect/">gitref.org</a>, but I can't seem to figure this out. </p>
<p>Let's say I want to get all commits for Tuesday, November 12th, 2013. Using an existing repo as an example,... | 131,080 | 1,094,541 | 2023-03-17 11:52:22 | 19,987,337 | 355 | 2013-11-14 20:07:32 | 1,094,541 | 2017-08-18 15:17:30 | https://stackoverflow.com/q/19987099 | https://stackoverflow.com/a/19987337 | <p><a href="https://stackoverflow.com/questions/19987099/how-do-i-view-all-commits-for-a-specific-day#comment29756543_19987099">Thanks John Bartholomew!</a> </p>
<p>The answer is to specify the time, e.g. <code>git log --after="2013-11-12 00:00" --before="2013-11-12 23:59"</code></p>
| <p><a href="https://stackoverflow.com/questions/19987099/how-do-i-view-all-commits-for-a-specific-day#comment29756543_19987099">Thanks John Bartholomew!</a> </p> <p>The answer is to specify the time, e.g. <code>git log --after="2013-11-12 00:00" --before="2013-11-12 23:59"</code></p> | 119, 47913 | git, git-log | <h1>How do I view all commits for a specific day?</h1>
<p>I've already looked at the relevant docs from <a href="http://git-scm.com/book/ch2-3.html">git-scm.com</a> and <a href="http://gitref.org/inspect/">gitref.org</a>, but I can't seem to figure this out. </p>
<p>Let's say I want to get all commits for Tuesday, Nov... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,576 | git | # How do I view all commits for a specific day?
I've already looked at the relevant docs from [git-scm.com](http://git-scm.com/book/ch2-3.html) and [gitref.org](http://gitref.org/inspect/), but I can't seem to figure this out.
Let's say I want to get all commits for Tuesday, November 12th, 2013. Using an existing rep... | [Thanks John Bartholomew!](https://stackoverflow.com/questions/19987099/how-do-i-view-all-commits-for-a-specific-day#comment29756543_19987099)
The answer is to specify the time, e.g. `git log --after="2013-11-12 00:00" --before="2013-11-12 23:59"` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.