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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
53712255 | How to use AWS CLI with Digital Ocean Spaces? | 30 | 2018-12-10 19:21:02 | <p>How to use AWS CLI with Digital Ocean Spaces? Is it possible?</p>
<p>I tried to add my key id and secret to <code>.aws/credentials</code> but I got:</p>
<blockquote>
<p>An error occurred (InvalidAccessKeyId) when calling the ListBuckets
operation: The AWS Access Key Id you provided does not exist in our
reco... | 13,109 | 9,370,832 | 2024-03-11 13:29:28 | 53,713,795 | 52 | 2018-12-10 21:19:21 | 598,929 | 2018-12-10 21:19:21 | https://stackoverflow.com/q/53712255 | https://stackoverflow.com/a/53713795 | <p>In order to use the AWS CLI with object storage service that provide an S3-compatible API like DigitalOcean Spaces, you must also configure a custom endpoint.</p>
<p>This can be done on the command line using the <code>--endpoint</code> flag:</p>
<pre><code>aws s3 ls --endpoint=https://nyc3.digitaloceanspaces.com
... | <p>In order to use the AWS CLI with object storage service that provide an S3-compatible API like DigitalOcean Spaces, you must also configure a custom endpoint.</p> <p>This can be done on the command line using the <code>--endpoint</code> flag:</p> <pre><code>aws s3 ls --endpoint=https://nyc3.digitaloceanspaces.com ... | 33388, 97102, 99166 | amazon-web-services, aws-cli, digital-ocean | <h1>How to use AWS CLI with Digital Ocean Spaces?</h1>
<p>How to use AWS CLI with Digital Ocean Spaces? Is it possible?</p>
<p>I tried to add my key id and secret to <code>.aws/credentials</code> but I got:</p>
<blockquote>
<p>An error occurred (InvalidAccessKeyId) when calling the ListBuckets
operation: The AWS ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,351 | git | # How to use AWS CLI with Digital Ocean Spaces?
How to use AWS CLI with Digital Ocean Spaces? Is it possible?
I tried to add my key id and secret to `.aws/credentials` but I got:
> An error occurred (InvalidAccessKeyId) when calling the ListBuckets
> operation: The AWS Access Key Id you provided does not exist in ou... | In order to use the AWS CLI with object storage service that provide an S3-compatible API like DigitalOcean Spaces, you must also configure a custom endpoint.
This can be done on the command line using the `--endpoint` flag:
```
aws s3 ls --endpoint=https://nyc3.digitaloceanspaces.com
``` |
5891531 | How do I get a "git log" patch for a specific commit | 30 | 2011-05-05 00:55:37 | <p>If I have a commit hash that has not yet been pushed to origin, how can I generate a patch for that commit only. I would like to use <code>git log -p --no-names</code> but can't see a switch to pass in a specific commit hash. Should I be using a different git command?</p>
| 20,421 | 336,905 | 2011-05-05 01:12:56 | 5,891,579 | 52 | 2011-05-05 01:04:09 | 526,535 | 2011-05-05 01:12:56 | https://stackoverflow.com/q/5891531 | https://stackoverflow.com/a/5891579 | <p>For git log patch:</p>
<pre><code>git log -p -1 <commit>
</code></pre>
<p>You should be using <code>git format-patch</code> for patches though:</p>
<pre><code>git format-patch -1 <commit>
</code></pre>
<p><a href="http://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html" rel="noreferrer"... | <p>For git log patch:</p> <pre><code>git log -p -1 <commit> </code></pre> <p>You should be using <code>git format-patch</code> for patches though:</p> <pre><code>git format-patch -1 <commit> </code></pre> <p><a href="http://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html" rel="noreferrer"... | 119, 456, 2132, 47913 | git, git-log, patch, version-control | <h1>How do I get a "git log" patch for a specific commit</h1>
<p>If I have a commit hash that has not yet been pushed to origin, how can I generate a patch for that commit only. I would like to use <code>git log -p --no-names</code> but can't see a switch to pass in a specific commit hash. Should I be using a differen... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,352 | git | # How do I get a "git log" patch for a specific commit
If I have a commit hash that has not yet been pushed to origin, how can I generate a patch for that commit only. I would like to use `git log -p --no-names` but can't see a switch to pass in a specific commit hash. Should I be using a different git command? | For git log patch:
```
git log -p -1 <commit>
```
You should be using `git format-patch` for patches though:
```
git format-patch -1 <commit>
```
<http://www.kernel.org/pub/software/scm/git/docs/git-format-patch.html> |
21252876 | Git repository created without a master branch | 29 | 2014-01-21 08:33:13 | <p>I want to create a new shared git repository for a new project (on a VM).</p>
<p>I ran <code>git --bare init</code> from <code>/.../git/new_proj.git</code>, but a master branch is not created in the <code>.../git/new_proj.git/refs/heads</code> directory.
I also ran <code>sudo chmod 777 -R</code> on my directory, bu... | 42,892 | 3,007,732 | 2017-03-10 16:35:15 | 21,255,920 | 52 | 2014-01-21 10:48:57 | 1,256,452 | 2014-01-21 10:48:57 | https://stackoverflow.com/q/21252876 | https://stackoverflow.com/a/21255920 | <p>It's already in the comments on the <a href="https://stackoverflow.com/a/21252989/1256452">other answer so far</a>, but this is perfectly normal: a new repository, "bare" or not, has no commits, so it has no references either.</p>
<p>It does have a <code>HEAD</code>, which is a file named <code>HEAD</code> in the r... | <p>It's already in the comments on the <a href="https://stackoverflow.com/a/21252989/1256452">other answer so far</a>, but this is perfectly normal: a new repository, "bare" or not, has no commits, so it has no references either.</p> <p>It does have a <code>HEAD</code>, which is a file named <code>HEAD</code> in the r... | 119, 7330, 76220 | git, git-branch, repository | <h1>Git repository created without a master branch</h1>
<p>I want to create a new shared git repository for a new project (on a VM).</p>
<p>I ran <code>git --bare init</code> from <code>/.../git/new_proj.git</code>, but a master branch is not created in the <code>.../git/new_proj.git/refs/heads</code> directory.
I als... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,353 | git | # Git repository created without a master branch
I want to create a new shared git repository for a new project (on a VM).
I ran `git --bare init` from `/.../git/new_proj.git`, but a master branch is not created in the `.../git/new_proj.git/refs/heads` directory.
I also ran `sudo chmod 777 -R` on my directory, but it... | It's already in the comments on the [other answer so far](https://stackoverflow.com/a/21252989/1256452), but this is perfectly normal: a new repository, "bare" or not, has no commits, so it has no references either.
It does have a `HEAD`, which is a file named `HEAD` in the repository (the `.git` directory), containin... |
7387612 | Git changelog: how to get all changes up to a specific tag? | 28 | 2011-09-12 12:10:16 | <p>Is there an easy way or command to get all git commits up to a specific tag to generate an automatic changelog for a project? I always tag my git repos with a version number like <code>v0.1.0</code> and for instance would like all commits up to tag <code>v0.1.0</code>. </p>
<p>I've looked through the docs but don't... | 33,622 | 640,288 | 2022-04-14 07:11:46 | 7,387,677 | 52 | 2011-09-12 12:14:56 | 223,092 | 2011-09-12 12:23:24 | https://stackoverflow.com/q/7387612 | https://stackoverflow.com/a/7387677 | <p>You can just do:</p>
<pre><code>git log --oneline --decorate v0.1.0
</code></pre>
<p>... to show every commit up to and including v0.1.0. Of course, <code>git log</code> allows also allows you to restrict the commits shown in any of the ways that <code>git rev-list</code> understands, so if you only wanted to see... | <p>You can just do:</p> <pre><code>git log --oneline --decorate v0.1.0 </code></pre> <p>... to show every commit up to and including v0.1.0. Of course, <code>git log</code> allows also allows you to restrict the commits shown in any of the ways that <code>git rev-list</code> understands, so if you only wanted to see... | 119, 942, 7349 | changelog, git, logging | <h1>Git changelog: how to get all changes up to a specific tag?</h1>
<p>Is there an easy way or command to get all git commits up to a specific tag to generate an automatic changelog for a project? I always tag my git repos with a version number like <code>v0.1.0</code> and for instance would like all commits up to tag... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,355 | git | # Git changelog: how to get all changes up to a specific tag?
Is there an easy way or command to get all git commits up to a specific tag to generate an automatic changelog for a project? I always tag my git repos with a version number like `v0.1.0` and for instance would like all commits up to tag `v0.1.0`.
I've loo... | You can just do:
```
git log --oneline --decorate v0.1.0
```
... to show every commit up to and including v0.1.0. Of course, `git log` allows also allows you to restrict the commits shown in any of the ways that `git rev-list` understands, so if you only wanted to see the changes between `v0.0.9` and `v0.1.0` you cou... |
60334337 | Why are my changes gone after a cancelled git commit and how do I recover them? | 27 | 2020-02-21 07:58:00 | <p>Here's what I did:</p>
<ol>
<li>Coded 8 hours worth of changes.</li>
<li><code>git status</code> displays all my changes.</li>
<li><code>git add -A</code></li>
<li><code>git commit -m "Foo"</code>. A pre-commit git hook fires with <code>husky</code> and <code>lint-staged</code>.</li>
<li>I remember that there's a T... | 10,485 | 901,944 | 2021-09-27 07:51:34 | 60,335,168 | 52 | 2020-02-21 08:58:11 | 901,944 | 2021-09-27 07:51:34 | https://stackoverflow.com/q/60334337 | https://stackoverflow.com/a/60335168 | <p>OK, it was <code>lint-staged</code> to blame. It stashed my changes.</p>
<p>So running <code>git stash apply</code> recovered them!</p>
<hr />
<p>⚠ Do not attempt running multiple instances of <code>lint-staged</code> in parallel on the same git repo (e. g. on each project in a monorepo). This will destroy your chan... | <p>OK, it was <code>lint-staged</code> to blame. It stashed my changes.</p> <p>So running <code>git stash apply</code> recovered them!</p> <hr /> <p>⚠ Do not attempt running multiple instances of <code>lint-staged</code> in parallel on the same git repo (e. g. on each project in a monorepo). This will destroy your chan... | 119, 124263, 126368, 130301 | git, git-husky, husky, lint-staged | <h1>Why are my changes gone after a cancelled git commit and how do I recover them?</h1>
<p>Here's what I did:</p>
<ol>
<li>Coded 8 hours worth of changes.</li>
<li><code>git status</code> displays all my changes.</li>
<li><code>git add -A</code></li>
<li><code>git commit -m "Foo"</code>. A pre-commit git hook fires w... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,356 | git | # Why are my changes gone after a cancelled git commit and how do I recover them?
Here's what I did:
1. Coded 8 hours worth of changes.
2. `git status` displays all my changes.
3. `git add -A`
4. `git commit -m "Foo"`. A pre-commit git hook fires with `husky` and `lint-staged`.
5. I remember that there's a TypeScript... | OK, it was `lint-staged` to blame. It stashed my changes.
So running `git stash apply` recovered them!
---
⚠ Do not attempt running multiple instances of `lint-staged` in parallel on the same git repo (e. g. on each project in a monorepo). This will destroy your changes without any way to recover them.
If you work ... |
23067388 | How do I edit my staged file? | 26 | 2014-04-14 18:23:07 | <p>I used patch mode to add a file. It took a good while to add only the changes I wanted in this commit. But then I realized I had made a mistake. There was one block of code I don't want in this commit.</p>
<p>Is there a way I can edit the staged change set without changing my working directory and not repeating ... | 10,173 | 2,777,657 | 2014-04-14 18:24:40 | 23,067,414 | 52 | 2014-04-14 18:24:40 | 1,204,143 | 2014-04-14 18:24:40 | https://stackoverflow.com/q/23067388 | https://stackoverflow.com/a/23067414 | <p>Yes, just use <code>git reset -p</code> to selectively unstage patches.</p>
| <p>Yes, just use <code>git reset -p</code> to selectively unstage patches.</p> | 119 | git | <h1>How do I edit my staged file?</h1>
<p>I used patch mode to add a file. It took a good while to add only the changes I wanted in this commit. But then I realized I had made a mistake. There was one block of code I don't want in this commit.</p>
<p>Is there a way I can edit the staged change set without changing ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,358 | git | # How do I edit my staged file?
I used patch mode to add a file. It took a good while to add only the changes I wanted in this commit. But then I realized I had made a mistake. There was one block of code I don't want in this commit.
Is there a way I can edit the staged change set without changing my working director... | Yes, just use `git reset -p` to selectively unstage patches. |
31921561 | How to clear git caches? | 23 | 2015-08-10 13:58:12 | <p>When I list my branches with <code>git branch -a</code>, git shows me remote branches I can't actually find on my remote(gitlab). I tried to checkout and track those branches, and to my big surprise, git did it. But when I do for example <code>git push origin :branch_name</code>, git says that the remote ref does no... | 44,160 | 3,852,459 | 2023-11-30 04:48:01 | 31,921,657 | 52 | 2015-08-10 14:02:29 | 2,452,553 | 2015-08-10 14:02:29 | https://stackoverflow.com/q/31921561 | https://stackoverflow.com/a/31921657 | <p>Use <code>git fetch -p</code> to prune your local caches</p>
| <p>Use <code>git fetch -p</code> to prune your local caches</p> | 119 | git | <h1>How to clear git caches?</h1>
<p>When I list my branches with <code>git branch -a</code>, git shows me remote branches I can't actually find on my remote(gitlab). I tried to checkout and track those branches, and to my big surprise, git did it. But when I do for example <code>git push origin :branch_name</code>, gi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,360 | git | # How to clear git caches?
When I list my branches with `git branch -a`, git shows me remote branches I can't actually find on my remote(gitlab). I tried to checkout and track those branches, and to my big surprise, git did it. But when I do for example `git push origin :branch_name`, git says that the remote ref does... | Use `git fetch -p` to prune your local caches |
40217494 | How to review a pull request in IntelliJ IDEA? | 119 | 2016-10-24 11:41:22 | <p>We are using git, Bitbucket, and IntelliJ IDEA. The project is mainly written in Java and Groovy.</p>
<p>Is there a good way to review pull requests right from IntelliJ?</p>
| 119,962 | 2,165,342 | 2025-05-12 12:42:48 | 40,217,881 | 51 | 2016-10-24 12:01:22 | 6,309 | 2021-02-15 04:50:28 | https://stackoverflow.com/q/40217494 | https://stackoverflow.com/a/40217881 | <p>The formal support for GitHub (or BitBucket for that matter) pull request review is still pending (<a href="https://youtrack.jetbrains.com/issue/IDEA-85079" rel="noreferrer">issue <code>IDEA-85079</code></a>, opened in 2012). It will be implemented in the 2020.2 release (see <a href="https://blog.jetbrains.com/ruby/... | <p>The formal support for GitHub (or BitBucket for that matter) pull request review is still pending (<a href="https://youtrack.jetbrains.com/issue/IDEA-85079" rel="noreferrer">issue <code>IDEA-85079</code></a>, opened in 2012). It will be implemented in the 2020.2 release (see <a href="https://blog.jetbrains.com/ruby/... | 119, 8337, 8945 | bitbucket, git, intellij-idea | <h1>How to review a pull request in IntelliJ IDEA?</h1>
<p>We are using git, Bitbucket, and IntelliJ IDEA. The project is mainly written in Java and Groovy.</p>
<p>Is there a good way to review pull requests right from IntelliJ?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,367 | git | # How to review a pull request in IntelliJ IDEA?
We are using git, Bitbucket, and IntelliJ IDEA. The project is mainly written in Java and Groovy.
Is there a good way to review pull requests right from IntelliJ? | The formal support for GitHub (or BitBucket for that matter) pull request review is still pending ([issue `IDEA-85079`](https://youtrack.jetbrains.com/issue/IDEA-85079), opened in 2012). It will be implemented in the 2020.2 release (see [here](https://blog.jetbrains.com/ruby/2020/05/rubymine-2020-2-eap-is-open/#more_ad... |
12613793 | Why is there a `remotes/origin/HEAD -> origin/master` entry in my `git branch -l -a` output? | 80 | 2012-09-27 03:48:24 | <p>I don't understand the second line in the output to <code>git branch -l -a</code>: <code>remotes/origin/HEAD -> origin/master</code>.</p>
<pre><code>git branch -l -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
</code></pre>
<p>Is that a leftover from another operation? Should I cl... | 44,603 | 456,042 | 2021-09-30 13:28:50 | 12,613,893 | 51 | 2012-09-27 04:02:28 | 6,309 | 2021-09-30 13:28:50 | https://stackoverflow.com/q/12613793 | https://stackoverflow.com/a/12613893 | <p>No, no need to clean up: it is the symbolic branch referenced by your remote repo.<br />
When you clone your repo, you will be by default on the branch referenced by <code>remotes/origin/HEAD</code>.</p>
<p>See also:</p>
<ul>
<li>"<a href="https://stackoverflow.com/questions/3301956/git-correct-way-to-change-ac... | <p>No, no need to clean up: it is the symbolic branch referenced by your remote repo.<br /> When you clone your repo, you will be by default on the branch referenced by <code>remotes/origin/HEAD</code>.</p> <p>See also:</p> <ul> <li>"<a href="https://stackoverflow.com/questions/3301956/git-correct-way-to-change-ac... | 119, 1879 | branch, git | <h1>Why is there a `remotes/origin/HEAD -> origin/master` entry in my `git branch -l -a` output?</h1>
<p>I don't understand the second line in the output to <code>git branch -l -a</code>: <code>remotes/origin/HEAD -> origin/master</code>.</p>
<pre><code>git branch -l -a
* master
remotes/origin/HEAD -> origin/m... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,370 | git | # Why is there a `remotes/origin/HEAD -> origin/master` entry in my `git branch -l -a` output?
I don't understand the second line in the output to `git branch -l -a`: `remotes/origin/HEAD -> origin/master`.
```
git branch -l -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
```
Is that a lef... | No, no need to clean up: it is the symbolic branch referenced by your remote repo.
When you clone your repo, you will be by default on the branch referenced by `remotes/origin/HEAD`.
See also:
- "[Git: Correct way to change Active Branch in a bare repository?](https://stackoverflow.com/questions/3301956/git-correct... |
18930103 | Git Ignore everything in a directory except subfolders | 61 | 2013-09-21 07:32:10 | <p>This is my folder structure:</p>
<pre><code>data/
.gitignore
uploads/
.gitignore
</code></pre>
<p>I would like to commit the folders but not the files inside them.</p>
<p>So I add a .gitignore files in every folder with the following content:</p>
<pre><code># Ignore everything in this directory
*... | 47,856 | 1,171,460 | 2016-04-17 21:59:05 | 18,930,104 | 51 | 2013-09-21 07:32:10 | 1,171,460 | 2013-09-21 07:32:10 | https://stackoverflow.com/q/18930103 | https://stackoverflow.com/a/18930104 | <p>The solution is quite easy, add <code>!*/</code> to the .gitignore files and only files in the current folder will be ignored</p>
<pre><code># Ignore everything in this directory
*
# Except this file
!.gitignore
# Except folders
!*/
</code></pre>
| <p>The solution is quite easy, add <code>!*/</code> to the .gitignore files and only files in the current folder will be ignored</p> <pre><code># Ignore everything in this directory * # Except this file !.gitignore # Except folders !*/ </code></pre> | 119, 25056, 34708 | git, gitignore, subdirectory | <h1>Git Ignore everything in a directory except subfolders</h1>
<p>This is my folder structure:</p>
<pre><code>data/
.gitignore
uploads/
.gitignore
</code></pre>
<p>I would like to commit the folders but not the files inside them.</p>
<p>So I add a .gitignore files in every folder with the following ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,372 | git | # Git Ignore everything in a directory except subfolders
This is my folder structure:
```
data/
.gitignore
uploads/
.gitignore
```
I would like to commit the folders but not the files inside them.
So I add a .gitignore files in every folder with the following content:
```
# Ignore everything in thi... | The solution is quite easy, add `!*/` to the .gitignore files and only files in the current folder will be ignored
```
# Ignore everything in this directory
*
# Except this file
!.gitignore
# Except folders
!*/
``` |
21671706 | Configure git to use IPv4 instead of IPv6 by default | 60 | 2014-02-10 07:55:27 | <p>Checking the environment variables and also HTTP configuration options does not reveal something. Is there a way to do this?</p>
| 47,412 | 248,082 | 2024-11-11 11:17:56 | 35,626,039 | 51 | 2016-02-25 11:29:57 | 6,309 | 2023-07-29 04:53:01 | https://stackoverflow.com/q/21671706 | https://stackoverflow.com/a/35626039 | <p>With git 2.8 (March 2016), you can force <code>git fetch</code>/<code>push</code>/<code>clone</code> to use IPV4 or IPV6.<br />
(for <code>git pull</code>, see below Git 2.16, Q1 2018)</p>
<p>See <a href="https://github.com/git/git/commit/c915f11eb4922e154e29cf62d3b549d65c06a170" rel="noreferrer">commit c915f11</a> ... | <p>With git 2.8 (March 2016), you can force <code>git fetch</code>/<code>push</code>/<code>clone</code> to use IPV4 or IPV6.<br /> (for <code>git pull</code>, see below Git 2.16, Q1 2018)</p> <p>See <a href="https://github.com/git/git/commit/c915f11eb4922e154e29cf62d3b549d65c06a170" rel="noreferrer">commit c915f11</a> ... | 119, 7904, 10485 | git, ipv4, ipv6 | <h1>Configure git to use IPv4 instead of IPv6 by default</h1>
<p>Checking the environment variables and also HTTP configuration options does not reveal something. Is there a way to do this?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,373 | git | # Configure git to use IPv4 instead of IPv6 by default
Checking the environment variables and also HTTP configuration options does not reveal something. Is there a way to do this? | With git 2.8 (March 2016), you can force `git fetch`/`push`/`clone` to use IPV4 or IPV6.
(for `git pull`, see below Git 2.16, Q1 2018)
See [commit c915f11](https://github.com/git/git/commit/c915f11eb4922e154e29cf62d3b549d65c06a170) (03 Feb 2016) by [Eric Wong (`ele828`)](https://github.com/ele828).
(Merged by [Jun... |
2786062 | How can I pull an existing heroku app to new location for development? | 60 | 2010-05-07 03:45:29 | <p>I currently have the latest version of my code on another computer that I want to develop from (Home computer and laptop for when I'm out and about) I set up heroku for my app on my laptop. Now I need to associate my code on my desktop so that I can push to heroku from there as well.</p>
<p>This is what I get from ... | 65,634 | 43,792 | 2015-08-10 14:42:30 | 12,374,073 | 51 | 2012-09-11 16:26:14 | 524,674 | 2013-08-29 22:09:48 | https://stackoverflow.com/q/2786062 | https://stackoverflow.com/a/12374073 | <p>First of all, you'll want to follow the Quick Start instructions for Heroku, which you can get straight from the horse's mouth, right here: <a href="https://devcenter.heroku.com/articles/quickstart" rel="noreferrer">https://devcenter.heroku.com/articles/quickstart</a></p>
<p>Once you've gotten through step 3, come ... | <p>First of all, you'll want to follow the Quick Start instructions for Heroku, which you can get straight from the horse's mouth, right here: <a href="https://devcenter.heroku.com/articles/quickstart" rel="noreferrer">https://devcenter.heroku.com/articles/quickstart</a></p> <p>Once you've gotten through step 3, come ... | 4860, 8279, 28896 | git-pull, heroku, pull | <h1>How can I pull an existing heroku app to new location for development?</h1>
<p>I currently have the latest version of my code on another computer that I want to develop from (Home computer and laptop for when I'm out and about) I set up heroku for my app on my laptop. Now I need to associate my code on my desktop s... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,374 | git | # How can I pull an existing heroku app to new location for development?
I currently have the latest version of my code on another computer that I want to develop from (Home computer and laptop for when I'm out and about) I set up heroku for my app on my laptop. Now I need to associate my code on my desktop so that I ... | First of all, you'll want to follow the Quick Start instructions for Heroku, which you can get straight from the horse's mouth, right here: <https://devcenter.heroku.com/articles/quickstart>
Once you've gotten through step 3, come back here.
Then, you can type this into the command line:
`heroku git:clone -a myapp`
... |
4359099 | Git branch named origin/HEAD -> origin/master | 56 | 2010-12-05 13:47:12 | <p>I'm fairly new to Git, and still getting the hang of it. I just recently started working with branches and am running into some questions.</p>
<p>I have two development systems, an Ubuntu desktop and an MacBookPro. I did a bunch of work in a new <code>organizations</code> branch on the Ubuntu system and performed c... | 51,160 | 220,599 | 2019-02-22 06:22:54 | 4,359,327 | 51 | 2010-12-05 14:50:41 | 12,471 | 2019-02-22 06:22:54 | https://stackoverflow.com/q/4359099 | https://stackoverflow.com/a/4359327 | <p><code>HEAD</code> usually points to the currently checked out branch. In hosted (bare) repositories, it designates the default branch, i.e. the branch that is checked out when you clone the repository. So, origin/HEAD tells you the default branch of origin.</p>
<p>I don't know why it's not present in your repositor... | <p><code>HEAD</code> usually points to the currently checked out branch. In hosted (bare) repositories, it designates the default branch, i.e. the branch that is checked out when you clone the repository. So, origin/HEAD tells you the default branch of origin.</p> <p>I don't know why it's not present in your repositor... | 119 | git | <h1>Git branch named origin/HEAD -> origin/master</h1>
<p>I'm fairly new to Git, and still getting the hang of it. I just recently started working with branches and am running into some questions.</p>
<p>I have two development systems, an Ubuntu desktop and an MacBookPro. I did a bunch of work in a new <code>organizat... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,376 | git | # Git branch named origin/HEAD -> origin/master
I'm fairly new to Git, and still getting the hang of it. I just recently started working with branches and am running into some questions.
I have two development systems, an Ubuntu desktop and an MacBookPro. I did a bunch of work in a new `organizations` branch on the U... | `HEAD` usually points to the currently checked out branch. In hosted (bare) repositories, it designates the default branch, i.e. the branch that is checked out when you clone the repository. So, origin/HEAD tells you the default branch of origin.
I don't know why it's not present in your repository on the Ubuntu syste... |
63256354 | VS Code 'git mv' to preserve file history? | 55 | 2020-08-04 23:23:26 | <p>Is there any way in VS Code to change a file's name so that the file history is preserved in git, and it doesn't think the tracked file's been deleted?</p>
<p>I'm hoping for a GUI implementation of the command:</p>
<pre><code>git mv oldName.abc newName.xyz
</code></pre>
<p>Thanks</p>
| 27,365 | 1,431,827 | 2025-10-20 09:06:40 | 63,256,392 | 51 | 2020-08-04 23:28:56 | 1,871,033 | 2024-01-02 12:03:05 | https://stackoverflow.com/q/63256354 | https://stackoverflow.com/a/63256392 | <p>There is no need for it. Just rename the file. Git will detect renames regardless of whether <code>git mv</code> was used or not.</p>
<p>Try it: rename it in the normal way and then do <code>git status</code>. You will see two unstaged changes, one delete (D) and one add (M) - but that's only temporary. Stage both c... | <p>There is no need for it. Just rename the file. Git will detect renames regardless of whether <code>git mv</code> was used or not.</p> <p>Try it: rename it in the normal way and then do <code>git status</code>. You will see two unstaged changes, one delete (D) and one add (M) - but that's only temporary. Stage both c... | 119, 111608 | git, visual-studio-code | <h1>VS Code 'git mv' to preserve file history?</h1>
<p>Is there any way in VS Code to change a file's name so that the file history is preserved in git, and it doesn't think the tracked file's been deleted?</p>
<p>I'm hoping for a GUI implementation of the command:</p>
<pre><code>git mv oldName.abc newName.xyz
</code><... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,377 | git | # VS Code 'git mv' to preserve file history?
Is there any way in VS Code to change a file's name so that the file history is preserved in git, and it doesn't think the tracked file's been deleted?
I'm hoping for a GUI implementation of the command:
```
git mv oldName.abc newName.xyz
```
Thanks | There is no need for it. Just rename the file. Git will detect renames regardless of whether `git mv` was used or not.
Try it: rename it in the normal way and then do `git status`. You will see two unstaged changes, one delete (D) and one add (M) - but that's only temporary. Stage both changes (using `git add old_name... |
21670747 | What user will Ansible run my commands as? | 48 | 2014-02-10 06:51:45 | <h2>Background</h2>
<p>My question seems simple, but it gets more complex really fast.</p>
<p>Basically, I got really tired of maintaining my servers manually <em>(screams in background)</em> and I decided it was time to find a way to make being a server admin much more liveable. That's when I found Ansible. Great hu... | 54,825 | 2,374,223 | 2022-07-05 22:36:29 | 21,680,256 | 51 | 2014-02-10 14:47:27 | 360,834 | 2014-02-10 14:47:27 | https://stackoverflow.com/q/21670747 | https://stackoverflow.com/a/21680256 | <p>You may find it useful to read the Hosts and Users section on Ansible's documentation site:</p>
<p><a href="http://docs.ansible.com/playbooks_intro.html#hosts-and-users" rel="noreferrer">http://docs.ansible.com/playbooks_intro.html#hosts-and-users</a></p>
<p>In summary, ansible will run all commands in a playbook ... | <p>You may find it useful to read the Hosts and Users section on Ansible's documentation site:</p> <p><a href="http://docs.ansible.com/playbooks_intro.html#hosts-and-users" rel="noreferrer">http://docs.ansible.com/playbooks_intro.html#hosts-and-users</a></p> <p>In summary, ansible will run all commands in a playbook ... | 58, 119, 46426, 86394 | ansible, git, linux, node.js | <h1>What user will Ansible run my commands as?</h1>
<h2>Background</h2>
<p>My question seems simple, but it gets more complex really fast.</p>
<p>Basically, I got really tired of maintaining my servers manually <em>(screams in background)</em> and I decided it was time to find a way to make being a server admin much ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,378 | git | # What user will Ansible run my commands as?
## Background
My question seems simple, but it gets more complex really fast.
Basically, I got really tired of maintaining my servers manually *(screams in background)* and I decided it was time to find a way to make being a server admin much more liveable. That's when I ... | You may find it useful to read the Hosts and Users section on Ansible's documentation site:
<http://docs.ansible.com/playbooks_intro.html#hosts-and-users>
In summary, ansible will run all commands in a playbook as the user specified in the `remote_user` variable (assuming you're using ansible >= 1.4, `user` before th... |
9984722 | git rename many files and folders | 47 | 2012-04-02 22:29:21 | <p>I am trying to rename many files in my application and need to be able to do a rename in all subdirectories from the app root through git (i.e. git mv %filenamematch% %replacement%) that only replaces the matching text. I'm no good with bash scripting though.</p>
<p>update: would be good it if also renamed director... | 26,894 | 1,090,438 | 2022-10-02 15:04:22 | 9,985,718 | 51 | 2012-04-03 00:42:55 | 565,827 | 2020-12-05 14:42:06 | https://stackoverflow.com/q/9984722 | https://stackoverflow.com/a/9985718 | <p>This should do the trick:</p>
<pre><code>for file in $(git ls-files | grep %filenamematch% | sed -e 's/\(%filenamematch%[^/]*\).*/\1/' | uniq); do git mv $file $(echo $file | sed -e 's/%filenamematch%/%replacement%/'); done
</code></pre>
<p>To follow what this is doing, you'll need to understand piping with "|&... | <p>This should do the trick:</p> <pre><code>for file in $(git ls-files | grep %filenamematch% | sed -e 's/\(%filenamematch%[^/]*\).*/\1/' | uniq); do git mv $file $(echo $file | sed -e 's/%filenamematch%/%replacement%/'); done </code></pre> <p>To follow what this is doing, you'll need to understand piping with "|&... | 119, 1271, 4510, 5310 | file, git, grep, rename | <h1>git rename many files and folders</h1>
<p>I am trying to rename many files in my application and need to be able to do a rename in all subdirectories from the app root through git (i.e. git mv %filenamematch% %replacement%) that only replaces the matching text. I'm no good with bash scripting though.</p>
<p>update... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,379 | git | # git rename many files and folders
I am trying to rename many files in my application and need to be able to do a rename in all subdirectories from the app root through git (i.e. git mv %filenamematch% %replacement%) that only replaces the matching text. I'm no good with bash scripting though.
update: would be good ... | This should do the trick:
```
for file in $(git ls-files | grep %filenamematch% | sed -e 's/\(%filenamematch%[^/]*\).*/\1/' | uniq); do git mv $file $(echo $file | sed -e 's/%filenamematch%/%replacement%/'); done
```
To follow what this is doing, you'll need to understand piping with "|" and command substitution with... |
12876350 | diff returning entire file for identical files | 44 | 2012-10-13 19:41:43 | <p>I've got a website that has a git repo. I cloned the repo so that I could develop in one directory and then push to the repo, and then pull in the live/prod directory (would be interested in suggestions for a better way to do this if there is one, but that's outside the scope of this question).</p>
<p>I did the fol... | 16,614 | 710,360 | 2022-06-19 13:18:53 | 12,876,379 | 51 | 2012-10-13 19:46:24 | 1,024,223 | 2018-05-28 10:45:34 | https://stackoverflow.com/q/12876350 | https://stackoverflow.com/a/12876379 | <p>This seems like a whitespace issue, in order to avoid them in the future, you can setup Git to normalize them.</p>
<p>Windows and UNIX system don't use same line-ending, to prevent conflict from happening based on these, you should setup you git config this way:</p>
<ul>
<li><strong>Windows</strong> : <code>git co... | <p>This seems like a whitespace issue, in order to avoid them in the future, you can setup Git to normalize them.</p> <p>Windows and UNIX system don't use same line-ending, to prevent conflict from happening based on these, you should setup you git config this way:</p> <ul> <li><strong>Windows</strong> : <code>git co... | 119, 606 | diff, git | <h1>diff returning entire file for identical files</h1>
<p>I've got a website that has a git repo. I cloned the repo so that I could develop in one directory and then push to the repo, and then pull in the live/prod directory (would be interested in suggestions for a better way to do this if there is one, but that's ou... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,381 | git | # diff returning entire file for identical files
I've got a website that has a git repo. I cloned the repo so that I could develop in one directory and then push to the repo, and then pull in the live/prod directory (would be interested in suggestions for a better way to do this if there is one, but that's outside the... | This seems like a whitespace issue, in order to avoid them in the future, you can setup Git to normalize them.
Windows and UNIX system don't use same line-ending, to prevent conflict from happening based on these, you should setup you git config this way:
- **Windows** : `git config --global core.autocrlf true`
- **U... |
7885075 | format-patch for a single file | 43 | 2011-10-25 05:32:26 | <p>I have a file called test_module.c that has some differences that I want to apply to my local working copy.</p>
<p>I tried to create patch file from the remote by doing the following. However, git didn't complain about any errors. And didn't create any patch file either.</p>
<pre><code>git format-patch master/dev_... | 38,171 | 70,942 | 2014-05-27 20:24:51 | 7,885,229 | 51 | 2011-10-25 05:56:50 | 223,092 | 2011-10-25 05:56:50 | https://stackoverflow.com/q/7885075 | https://stackoverflow.com/a/7885229 | <p>If you give <code>git format-patch</code> a single revision, it will produce patches for each commit <em>since</em> that revision. If you see no output from that command, then I suspect that there were no changes to that file between <code>origin/master</code> and your current <code>HEAD</code>. As an alternative,... | <p>If you give <code>git format-patch</code> a single revision, it will produce patches for each commit <em>since</em> that revision. If you see no output from that command, then I suspect that there were no changes to that file between <code>origin/master</code> and your current <code>HEAD</code>. As an alternative,... | 119 | git | <h1>format-patch for a single file</h1>
<p>I have a file called test_module.c that has some differences that I want to apply to my local working copy.</p>
<p>I tried to create patch file from the remote by doing the following. However, git didn't complain about any errors. And didn't create any patch file either.</p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,383 | git | # format-patch for a single file
I have a file called test_module.c that has some differences that I want to apply to my local working copy.
I tried to create patch file from the remote by doing the following. However, git didn't complain about any errors. And didn't create any patch file either.
```
git format-patc... | If you give `git format-patch` a single revision, it will produce patches for each commit *since* that revision. If you see no output from that command, then I suspect that there were no changes to that file between `origin/master` and your current `HEAD`. As an alternative, you can provide a revision range (e.g. `orig... |
3525341 | Can I use a scripted commit template for git? | 43 | 2010-08-19 19:11:39 | <p>We are working on tickets, and when we use the ticket number in the git commit message on the first line, then the ticket is updated with the commit message.</p>
<p>To make things simple we always work on a branch with the commit number.</p>
<p>Now I'd like to be presented with a commit message where the ticket nu... | 11,733 | 350,890 | 2014-03-18 08:01:19 | 3,525,532 | 51 | 2010-08-19 19:33:01 | 197,325 | 2010-08-19 21:30:00 | https://stackoverflow.com/q/3525341 | https://stackoverflow.com/a/3525532 | <p>You probably want to set up a <code>prepare-commit-msg</code> hook on your local repository. It might look like this (say the branches are named 'work-on-ticket-XXXX':</p>
<pre><code>#!/bin/sh
ORIG_MSG_FILE="$1"
TEMP=`mktemp /tmp/git-XXXXX`
TICKETNO=`git branch | grep '^\*' | cut -b3-`
(echo "Work on ticket #$TI... | <p>You probably want to set up a <code>prepare-commit-msg</code> hook on your local repository. It might look like this (say the branches are named 'work-on-ticket-XXXX':</p> <pre><code>#!/bin/sh ORIG_MSG_FILE="$1" TEMP=`mktemp /tmp/git-XXXXX` TICKETNO=`git branch | grep '^\*' | cut -b3-` (echo "Work on ticket #$TI... | 119, 25281, 53850 | git, git-commit, pre-commit-hook | <h1>Can I use a scripted commit template for git?</h1>
<p>We are working on tickets, and when we use the ticket number in the git commit message on the first line, then the ticket is updated with the commit message.</p>
<p>To make things simple we always work on a branch with the commit number.</p>
<p>Now I'd like to... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,384 | git | # Can I use a scripted commit template for git?
We are working on tickets, and when we use the ticket number in the git commit message on the first line, then the ticket is updated with the commit message.
To make things simple we always work on a branch with the commit number.
Now I'd like to be presented with a co... | You probably want to set up a `prepare-commit-msg` hook on your local repository. It might look like this (say the branches are named 'work-on-ticket-XXXX':
```
#!/bin/sh
ORIG_MSG_FILE="$1"
TEMP=`mktemp /tmp/git-XXXXX`
TICKETNO=`git branch | grep '^\*' | cut -b3-`
(echo "Work on ticket #$TICKETNO"; cat "$ORIG_MSG_FI... |
28774194 | Reset/revert a whole branch to another branches state? | 42 | 2015-02-27 21:01:50 | <p>I have a branch <em>A</em> and a branch <em>B</em> (and some other branches).</p>
<p>Lets say <em>A</em>'s commit history looks like:</p>
<ul>
<li>commit 5</li>
<li>commit 4</li>
<li>commit 3</li>
<li>...</li>
</ul>
<p>And <em>B</em>'s commit history:</p>
<ul>
<li>some other commit</li>
<li>commit 4</li>
<li>mer... | 59,650 | 3,314,143 | 2021-10-22 15:13:07 | 28,774,320 | 51 | 2015-02-27 21:10:02 | 2,986,905 | 2019-09-05 08:26:10 | https://stackoverflow.com/q/28774194 | https://stackoverflow.com/a/28774320 | <p>One way to achieve this is through <code>git reset</code>. While on branch <code>B</code> execute</p>
<pre class="lang-sh prettyprint-override"><code>git reset --hard A
</code></pre>
<p>Thereafter, branch <code>B</code> points to the head-commit of <code>A</code>. The <code>--hard</code> option resets the index an... | <p>One way to achieve this is through <code>git reset</code>. While on branch <code>B</code> execute</p> <pre class="lang-sh prettyprint-override"><code>git reset --hard A </code></pre> <p>Thereafter, branch <code>B</code> points to the head-commit of <code>A</code>. The <code>--hard</code> option resets the index an... | 119, 28897, 34403, 51381 | git, git-merge, git-reset, git-revert | <h1>Reset/revert a whole branch to another branches state?</h1>
<p>I have a branch <em>A</em> and a branch <em>B</em> (and some other branches).</p>
<p>Lets say <em>A</em>'s commit history looks like:</p>
<ul>
<li>commit 5</li>
<li>commit 4</li>
<li>commit 3</li>
<li>...</li>
</ul>
<p>And <em>B</em>'s commit history... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,385 | git | # Reset/revert a whole branch to another branches state?
I have a branch *A* and a branch *B* (and some other branches).
Lets say *A*'s commit history looks like:
- commit 5
- commit 4
- commit 3
- ...
And *B*'s commit history:
- some other commit
- commit 4
- merge of other stuff from branch *C* (into branch *B*)... | One way to achieve this is through `git reset`. While on branch `B` execute
```
git reset --hard A
```
Thereafter, branch `B` points to the head-commit of `A`. The `--hard` option resets the index and working tree so that all tracked files are reset to the version in branch `A`. The old HEAD commit-ID of `A` is store... |
4052854 | How do I check out what was in my git repository N days ago? | 42 | 2010-10-29 14:38:10 | <p>I have to check out my source code from two days ago. Whenever I have to do this, I have to look up the syntax. It's not in the git-checkout page. I'd like to have a convenient Stack Overflow question to refer to so I don't have to look it up every time. If this has already been asked, please point me to the dup... | 12,584 | 18,103 | 2018-11-07 23:05:30 | 4,052,884 | 51 | 2010-10-29 14:41:15 | 478,206 | 2010-10-29 14:41:15 | https://stackoverflow.com/q/4052854 | https://stackoverflow.com/a/4052884 | <pre><code>git checkout @{two.days.ago}
</code></pre>
| <pre><code>git checkout @{two.days.ago} </code></pre> | 119 | git | <h1>How do I check out what was in my git repository N days ago?</h1>
<p>I have to check out my source code from two days ago. Whenever I have to do this, I have to look up the syntax. It's not in the git-checkout page. I'd like to have a convenient Stack Overflow question to refer to so I don't have to look it up e... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,386 | git | # How do I check out what was in my git repository N days ago?
I have to check out my source code from two days ago. Whenever I have to do this, I have to look up the syntax. It's not in the git-checkout page. I'd like to have a convenient Stack Overflow question to refer to so I don't have to look it up every time. I... | ```
git checkout @{two.days.ago}
``` |
67953945 | Refname is ambiguous | 40 | 2021-06-13 00:31:58 | <p>Yesterday, I created a branch from a branch, pushed it to origin, and merged it back into master. You can see that here:</p>
<pre><code>$ history |less
8358 git co master
8359 commit # shortcut that adds all and commits
8360 push # shortcut that `git push`'s
8361 git lg # shortcut that logs my output
8362 ... | 12,127 | 61,624 | 2021-06-30 12:37:13 | 67,955,051 | 51 | 2021-06-13 05:07:31 | 1,290,731 | 2021-06-13 17:06:18 | https://stackoverflow.com/q/67953945 | https://stackoverflow.com/a/67955051 | <p>I can get this behavior by giving a branch a name that matches the SHA1 prefix of a commit.</p>
<pre><code>$ git rev-list @ | egrep '^[0-9]{4}'
7802d6937673dbff4d26dc906c714a054c9e883e
81070af68e1b254c7f36eccb1261050a5a4a133a
7537dac08fd165845b6300f32c19a52fc7fa7299
$ git branch 7802
$ git branch 9999
$ git checkout... | <p>I can get this behavior by giving a branch a name that matches the SHA1 prefix of a commit.</p> <pre><code>$ git rev-list @ | egrep '^[0-9]{4}' 7802d6937673dbff4d26dc906c714a054c9e883e 81070af68e1b254c7f36eccb1261050a5a4a133a 7537dac08fd165845b6300f32c19a52fc7fa7299 $ git branch 7802 $ git branch 9999 $ git checkout... | 119 | git | <h1>Refname is ambiguous</h1>
<p>Yesterday, I created a branch from a branch, pushed it to origin, and merged it back into master. You can see that here:</p>
<pre><code>$ history |less
8358 git co master
8359 commit # shortcut that adds all and commits
8360 push # shortcut that `git push`'s
8361 git lg # short... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,387 | git | # Refname is ambiguous
Yesterday, I created a branch from a branch, pushed it to origin, and merged it back into master. You can see that here:
```
$ history |less
8358 git co master
8359 commit # shortcut that adds all and commits
8360 push # shortcut that `git push`'s
8361 git lg # shortcut that logs my ou... | I can get this behavior by giving a branch a name that matches the SHA1 prefix of a commit.
```
$ git rev-list @ | egrep '^[0-9]{4}'
7802d6937673dbff4d26dc906c714a054c9e883e
81070af68e1b254c7f36eccb1261050a5a4a133a
7537dac08fd165845b6300f32c19a52fc7fa7299
$ git branch 7802
$ git branch 9999
$ git checkout 7802
warning... |
10058068 | In a Git cherry-pick or rebase merge conflict, how are BASE (aka "the ancestor"), LOCAL, and REMOTE determined? | 40 | 2012-04-07 20:26:49 | <p>In a normal Git merge conflict, the three versions of a file in play for the three-way merge are roughly as follows:</p>
<ul>
<li>LOCAL: the version from my branch</li>
<li>REMOTE: the version from the other branch</li>
<li>BASE: the version from the common ancestor of the two branches (in particular, the common an... | 10,818 | 64,257 | 2015-03-02 07:58:32 | 10,058,070 | 51 | 2012-04-07 20:27:10 | 64,257 | 2013-09-21 23:34:10 | https://stackoverflow.com/q/10058068 | https://stackoverflow.com/a/10058070 | <p><strong>cherry-pick</strong></p>
<p>Unless I have misled myself, then if you do "git cherry-pick <commit C>", then you get:</p>
<ul>
<li>LOCAL: the commit you're merging on top of (ie the HEAD of your branch)</li>
<li>REMOTE: the commit you're cherry picking (i.e. <commit C>)</li>
<li>BASE: the parent ... | <p><strong>cherry-pick</strong></p> <p>Unless I have misled myself, then if you do "git cherry-pick <commit C>", then you get:</p> <ul> <li>LOCAL: the commit you're merging on top of (ie the HEAD of your branch)</li> <li>REMOTE: the commit you're cherry picking (i.e. <commit C>)</li> <li>BASE: the parent ... | 119, 36489, 78810 | cherry-pick, git, git-cherry-pick | <h1>In a Git cherry-pick or rebase merge conflict, how are BASE (aka "the ancestor"), LOCAL, and REMOTE determined?</h1>
<p>In a normal Git merge conflict, the three versions of a file in play for the three-way merge are roughly as follows:</p>
<ul>
<li>LOCAL: the version from my branch</li>
<li>REMOTE: the version fr... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,388 | git | # In a Git cherry-pick or rebase merge conflict, how are BASE (aka "the ancestor"), LOCAL, and REMOTE determined?
In a normal Git merge conflict, the three versions of a file in play for the three-way merge are roughly as follows:
- LOCAL: the version from my branch
- REMOTE: the version from the other branch
- BASE:... | **cherry-pick**
Unless I have misled myself, then if you do "git cherry-pick <commit C>", then you get:
- LOCAL: the commit you're merging on top of (ie the HEAD of your branch)
- REMOTE: the commit you're cherry picking (i.e. <commit C>)
- BASE: the parent of the commit you're cherry-picking (ie C^, ie the parent of... |
21475844 | In Eclipse/EGit is there a way to edit commit message of unpushed/local commit? | 36 | 2014-01-31 08:56:17 | <p>Using Eclipse/EGit how do I edit a commit message of a commit I've made locally, but haven't pushed to the repository yet?</p>
| 40,340 | 118,587 | 2022-02-07 09:50:22 | 21,475,896 | 51 | 2014-01-31 08:59:02 | 6,309 | 2022-02-07 09:50:22 | https://stackoverflow.com/q/21475844 | https://stackoverflow.com/a/21475896 | <p>That would be the "<a href="http://wiki.eclipse.org/EGit/User_Guide#Amending_Commits" rel="noreferrer">Amending Commits</a>" section of the <a href="http://wiki.eclipse.org/EGit/User_Guide" rel="noreferrer">EGit User Guide</a>:</p>
<blockquote>
<p>open the Staging View or Commit Dialog again and select the... | <p>That would be the "<a href="http://wiki.eclipse.org/EGit/User_Guide#Amending_Commits" rel="noreferrer">Amending Commits</a>" section of the <a href="http://wiki.eclipse.org/EGit/User_Guide" rel="noreferrer">EGit User Guide</a>:</p> <blockquote> <p>open the Staging View or Commit Dialog again and select the... | 53, 119, 43702 | eclipse, egit, git | <h1>In Eclipse/EGit is there a way to edit commit message of unpushed/local commit?</h1>
<p>Using Eclipse/EGit how do I edit a commit message of a commit I've made locally, but haven't pushed to the repository yet?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,391 | git | # In Eclipse/EGit is there a way to edit commit message of unpushed/local commit?
Using Eclipse/EGit how do I edit a commit message of a commit I've made locally, but haven't pushed to the repository yet? | That would be the "[Amending Commits](http://wiki.eclipse.org/EGit/User_Guide#Amending_Commits)" section of the [EGit User Guide](http://wiki.eclipse.org/EGit/User_Guide):
> open the Staging View or Commit Dialog again and select the option Amend previous commit in the toolbar.
See also [this tutorial](http://www.vog... |
13257519 | How to Change the Default Editor for Git | 35 | 2012-11-06 18:58:13 | <p>I just started using git about a month ago. It was set up for me using TextMate as my default editor for commits. However, I'd like to switch the default to TextWrangler which I already have installed. I looked around online and found a line of code to type into the terminal to do this. So I opened the terminal an... | 36,373 | 1,697,845 | 2013-01-07 21:41:43 | 13,258,538 | 51 | 2012-11-06 20:05:16 | 1,697,845 | 2012-11-06 20:05:16 | https://stackoverflow.com/q/13257519 | https://stackoverflow.com/a/13258538 | <p>Just answered my own question with the help of the above comments... to switch to TextWrangler as the default for Git, you must open TextWrangler, click on TextWrangler in the tool bar and select "install command line tools" from the drop down. Then go into command line and type:</p>
<pre><code>git config --global ... | <p>Just answered my own question with the help of the above comments... to switch to TextWrangler as the default for Git, you must open TextWrangler, click on TextWrangler in the tool bar and select "install command line tools" from the drop down. Then go into command line and type:</p> <pre><code>git config --global ... | 119, 391 | git, terminal | <h1>How to Change the Default Editor for Git</h1>
<p>I just started using git about a month ago. It was set up for me using TextMate as my default editor for commits. However, I'd like to switch the default to TextWrangler which I already have installed. I looked around online and found a line of code to type into the... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,392 | git | # How to Change the Default Editor for Git
I just started using git about a month ago. It was set up for me using TextMate as my default editor for commits. However, I'd like to switch the default to TextWrangler which I already have installed. I looked around online and found a line of code to type into the terminal ... | Just answered my own question with the help of the above comments... to switch to TextWrangler as the default for Git, you must open TextWrangler, click on TextWrangler in the tool bar and select "install command line tools" from the drop down. Then go into command line and type:
```
git config --global core.editor "e... |
2965060 | .gitignore doesn't ignore files | 35 | 2010-06-03 10:30:02 | <p>My <strong>.gitignore</strong> file gets ignored and the files which should be ignored are still visible.</p>
<pre><code>user@host ~/workdir % git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to d... | 47,654 | 6,851 | 2017-04-26 16:28:09 | 11,120,151 | 51 | 2012-06-20 13:00:21 | 603,036 | 2016-11-25 05:40:36 | https://stackoverflow.com/q/2965060 | https://stackoverflow.com/a/11120151 | <p>after <a href="https://stackoverflow.com/a/7820627/603036">anybug's steps noted here</a> my git still kept track of .htaccess and this helped:</p>
<pre><code>git update-index --assume-unchanged .htaccess
</code></pre>
<p>To revert back:</p>
<pre><code>git update-index --no-assume-unchanged .htaccess
</code></pre>... | <p>after <a href="https://stackoverflow.com/a/7820627/603036">anybug's steps noted here</a> my git still kept track of .htaccess and this helped:</p> <pre><code>git update-index --assume-unchanged .htaccess </code></pre> <p>To revert back:</p> <pre><code>git update-index --no-assume-unchanged .htaccess </code></pre>... | 119, 456, 90056 | atlassian-sourcetree, git, version-control | <h1>.gitignore doesn't ignore files</h1>
<p>My <strong>.gitignore</strong> file gets ignored and the files which should be ignored are still visible.</p>
<pre><code>user@host ~/workdir % git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (u... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,393 | git | # .gitignore doesn't ignore files
My **.gitignore** file gets ignored and the files which should be ignored are still visible.
```
user@host ~/workdir % git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to disca... | after [anybug's steps noted here](https://stackoverflow.com/a/7820627/603036) my git still kept track of .htaccess and this helped:
```
git update-index --assume-unchanged .htaccess
```
To revert back:
```
git update-index --no-assume-unchanged .htaccess
``` |
7070178 | Heroku -- deployment from multiple computers? | 35 | 2011-08-15 20:09:05 | <p>I have two computers and I want both of them to be able to pull/push from the same repo on github as well as deploy to the same app on heroku. I know that Heroku allows you to clone its git repo on another computer so it can be linked up too, but I don't want the second to clone the heroku repo - i want it to clone... | 8,251 | 506,971 | 2014-07-17 21:37:18 | 8,638,391 | 51 | 2011-12-26 18:59:44 | 795,267 | 2014-07-17 21:37:18 | https://stackoverflow.com/q/7070178 | https://stackoverflow.com/a/8638391 | <p><code>git remote add heroku git@heroku.com:your_app_name.git</code></p>
| <p><code>git remote add heroku git@heroku.com:your_app_name.git</code></p> | 119, 8279, 64108 | git, heroku, ruby-on-rails-3 | <h1>Heroku -- deployment from multiple computers?</h1>
<p>I have two computers and I want both of them to be able to pull/push from the same repo on github as well as deploy to the same app on heroku. I know that Heroku allows you to clone its git repo on another computer so it can be linked up too, but I don't want t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,394 | git | # Heroku -- deployment from multiple computers?
I have two computers and I want both of them to be able to pull/push from the same repo on github as well as deploy to the same app on heroku. I know that Heroku allows you to clone its git repo on another computer so it can be linked up too, but I don't want the second ... | `git remote add heroku git@heroku.com:your_app_name.git` |
9004192 | the git clone is empty? why this happens | 34 | 2012-01-25 14:20:13 | <p>This always perplexes me.
I was cloning this </p>
<pre><code>git clone https://android.googlesource.com/kernel/msm.git
</code></pre>
<p>And It seemed to be cloning resolving and receiving objects etc for long .
Then when it is done...</p>
<pre><code>git clone https://android.googlesource.com/kernel/msm.git
Clon... | 53,620 | 1,150,230 | 2022-08-08 06:13:08 | 9,004,333 | 51 | 2012-01-25 14:30:03 | 92,542 | 2012-01-25 14:30:03 | https://stackoverflow.com/q/9004192 | https://stackoverflow.com/a/9004333 | <p>This particular git repository seems to not have any contents on its <code>master</code> branch, which is the branch git checks out by default. It does however have another branch:</p>
<pre><code>% git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/android-msm-2.6.35
remotes/origin/... | <p>This particular git repository seems to not have any contents on its <code>master</code> branch, which is the branch git checks out by default. It does however have another branch:</p> <pre><code>% git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/android-msm-2.6.35 remotes/origin/... | 119, 34099 | git, git-clone | <h1>the git clone is empty? why this happens</h1>
<p>This always perplexes me.
I was cloning this </p>
<pre><code>git clone https://android.googlesource.com/kernel/msm.git
</code></pre>
<p>And It seemed to be cloning resolving and receiving objects etc for long .
Then when it is done...</p>
<pre><code>git clone ht... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,396 | git | # the git clone is empty? why this happens
This always perplexes me.
I was cloning this
```
git clone https://android.googlesource.com/kernel/msm.git
```
And It seemed to be cloning resolving and receiving objects etc for long .
Then when it is done...
```
git clone https://android.googlesource.com/kernel/msm.git
C... | This particular git repository seems to not have any contents on its `master` branch, which is the branch git checks out by default. It does however have another branch:
```
% git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/android-msm-2.6.35
remotes/origin/master
```
So if you check ... |
8201765 | How to get list of branch heads in Git? | 34 | 2011-11-20 13:22:42 | <p>I am trying to get a list of branch heads in Git. So far I have found <code>git log --simplify-by-decoration</code> which seems to include all branches and show the heads, but it also shows one extra commit which is useless for me. Is there an even better way to do this or is that what I should use?</p>
<p>So to ma... | 62,460 | 283,055 | 2024-08-04 17:31:24 | 8,201,895 | 51 | 2011-11-20 13:42:18 | 785,065 | 2024-08-04 17:31:24 | https://stackoverflow.com/q/8201765 | https://stackoverflow.com/a/8201895 | <p>You should be able to use the <code>git show-ref</code> command. <a href="https://schacon.github.io/git/git-show-ref.html" rel="nofollow noreferrer">git-show-ref documentation</a></p>
<pre><code>git show-ref --heads -s
</code></pre>
<p>Starting <a href="https://stackoverflow.com/a/78831705/6309">Git 2.46 or the futu... | <p>You should be able to use the <code>git show-ref</code> command. <a href="https://schacon.github.io/git/git-show-ref.html" rel="nofollow noreferrer">git-show-ref documentation</a></p> <pre><code>git show-ref --heads -s </code></pre> <p>Starting <a href="https://stackoverflow.com/a/78831705/6309">Git 2.46 or the futu... | 119 | git | <h1>How to get list of branch heads in Git?</h1>
<p>I am trying to get a list of branch heads in Git. So far I have found <code>git log --simplify-by-decoration</code> which seems to include all branches and show the heads, but it also shows one extra commit which is useless for me. Is there an even better way to do th... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,398 | git | # How to get list of branch heads in Git?
I am trying to get a list of branch heads in Git. So far I have found `git log --simplify-by-decoration` which seems to include all branches and show the heads, but it also shows one extra commit which is useless for me. Is there an even better way to do this or is that what I... | You should be able to use the `git show-ref` command. [git-show-ref documentation](https://schacon.github.io/git/git-show-ref.html)
```
git show-ref --heads -s
```
Starting [Git 2.46 or the future Git 3.0](https://stackoverflow.com/a/78831705/6309):
```
git show-ref --branches -s
``` |
4820039 | Creating a copy of local git repository on a remote server | 34 | 2011-01-27 18:01:31 | <p>I have cloned a project from a server using <code>git clone</code> and I now want to copy it (all branches) to another server so other people can start using it. I guess I could simply copy the entire repository manually and then issue <code>git config --bool core.bare true</code> and delete everything but the <cod... | 20,682 | 9,236 | 2013-05-02 10:48:22 | 4,820,130 | 51 | 2011-01-27 18:10:24 | 110,081 | 2013-05-02 10:48:22 | https://stackoverflow.com/q/4820039 | https://stackoverflow.com/a/4820130 | <ol>
<li>Create a fresh bare repository on the server:<br>
<code>git init --bare newrepo.git</code></li>
<li>Add it as a remote in your local repo:<br>
<code>git remote add newrepo git://user@server.com/newrepo.git</code></li>
<li><code>git push newrepo master</code> to push a particular branch, or<br>
<code>git push -... | <ol> <li>Create a fresh bare repository on the server:<br> <code>git init --bare newrepo.git</code></li> <li>Add it as a remote in your local repo:<br> <code>git remote add newrepo git://user@server.com/newrepo.git</code></li> <li><code>git push newrepo master</code> to push a particular branch, or<br> <code>git push -... | 119 | git | <h1>Creating a copy of local git repository on a remote server</h1>
<p>I have cloned a project from a server using <code>git clone</code> and I now want to copy it (all branches) to another server so other people can start using it. I guess I could simply copy the entire repository manually and then issue <code>git co... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,399 | git | # Creating a copy of local git repository on a remote server
I have cloned a project from a server using `git clone` and I now want to copy it (all branches) to another server so other people can start using it. I guess I could simply copy the entire repository manually and then issue `git config --bool core.bare true... | 1. Create a fresh bare repository on the server:
`git init --bare newrepo.git`
2. Add it as a remote in your local repo:
`git remote add newrepo git://user@server.com/newrepo.git`
3. `git push newrepo master` to push a particular branch, or
`git push --all newrepo` to push all branches |
19397888 | How to undo misoperation of Reinitialized existing Git repository | 32 | 2013-10-16 07:50:14 | <p>I just ran <code>git init</code> on an already existing git repo.<br>
The result is <strong>Reinitialized existing Git repository</strong></p>
<p>How can I undo this?<br>
Thanks!</p>
| 11,258 | 974,526 | 2021-02-20 07:16:34 | 19,397,980 | 51 | 2013-10-16 07:55:47 | 2,596,375 | 2014-03-05 18:55:33 | https://stackoverflow.com/q/19397888 | https://stackoverflow.com/a/19397980 | <p>No need - it is quite safe to do. <a href="http://git-scm.com/docs/git-init" rel="noreferrer">From the documentation</a>:</p>
<pre><code>Running git init in an existing repository is safe.
It will not overwrite things that are already there.
The primary reason for rerunning git init is to pick up newly added temp... | <p>No need - it is quite safe to do. <a href="http://git-scm.com/docs/git-init" rel="noreferrer">From the documentation</a>:</p> <pre><code>Running git init in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunning git init is to pick up newly added temp... | 119 | git | <h1>How to undo misoperation of Reinitialized existing Git repository</h1>
<p>I just ran <code>git init</code> on an already existing git repo.<br>
The result is <strong>Reinitialized existing Git repository</strong></p>
<p>How can I undo this?<br>
Thanks!</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,402 | git | # How to undo misoperation of Reinitialized existing Git repository
I just ran `git init` on an already existing git repo.
The result is **Reinitialized existing Git repository**
How can I undo this?
Thanks! | No need - it is quite safe to do. [From the documentation](http://git-scm.com/docs/git-init):
```
Running git init in an existing repository is safe.
It will not overwrite things that are already there.
The primary reason for rerunning git init is to pick up newly added templates.
```
The templates are files such a... |
47959659 | How to change fetch URL of a git repository. | 30 | 2017-12-24 10:01:54 | <p>I have a github profile and I forked someone's repository into mine.
and locally I have cloned this repository using </p>
<pre><code>git clone https://github.com/my-github-page/repo-name
</code></pre>
<p>Now, since some time has passed the original repo owner has update his repo, but mine is behind. So, if I woul... | 28,894 | 8,182,674 | 2024-11-10 07:49:18 | 47,959,803 | 51 | 2017-12-24 10:29:02 | 6,309 | 2017-12-24 11:19:21 | https://stackoverflow.com/q/47959659 | https://stackoverflow.com/a/47959803 | <p>You can try:</p>
<pre><code>git remote set-url origin /original/repo
git remote set-url --push origin /your/fork
</code></pre>
<p>That way, only fetch references the original repo URL.</p>
<p>The other more traditional approach, of course, is to declare another remote, as I detailed in <a href="https://stackoverf... | <p>You can try:</p> <pre><code>git remote set-url origin /original/repo git remote set-url --push origin /your/fork </code></pre> <p>That way, only fetch references the original repo URL.</p> <p>The other more traditional approach, of course, is to declare another remote, as I detailed in <a href="https://stackoverf... | 119, 4860, 79324 | git, git-fork, pull | <h1>How to change fetch URL of a git repository.</h1>
<p>I have a github profile and I forked someone's repository into mine.
and locally I have cloned this repository using </p>
<pre><code>git clone https://github.com/my-github-page/repo-name
</code></pre>
<p>Now, since some time has passed the original repo owner ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,405 | git | # How to change fetch URL of a git repository.
I have a github profile and I forked someone's repository into mine.
and locally I have cloned this repository using
```
git clone https://github.com/my-github-page/repo-name
```
Now, since some time has passed the original repo owner has update his repo, but mine is be... | You can try:
```
git remote set-url origin /original/repo
git remote set-url --push origin /your/fork
```
That way, only fetch references the original repo URL.
The other more traditional approach, of course, is to declare another remote, as I detailed in ["What is the difference between origin and upstream on GitHu... |
44727750 | How do I restore a previous version as a new commit in Git? | 30 | 2017-06-23 18:22:08 | <p>First, I have seen the answer to this question here before, but it is buried by so many "answers" which don't answer my question properly, that I cannot find it again.</p>
<p>So here it goes: How do I restore in Git to a previous version in my history, so that it becomes the new commit on top of my current... | 56,907 | 553,496 | 2023-09-23 13:52:00 | 44,727,815 | 51 | 2017-06-23 18:27:12 | 159,145 | 2023-09-23 13:48:31 | https://stackoverflow.com/q/44727750 | https://stackoverflow.com/a/44727815 | <p>Simply "<code>checkout</code> the commit". This will overwrite your current working directory with the specified snapshot (commit) of your repo from history and make that your new working-set which you can stage and commit as you wish.</p>
<pre><code>cd ~/git/your-repo-root
git log
# find the commit id you... | <p>Simply "<code>checkout</code> the commit". This will overwrite your current working directory with the specified snapshot (commit) of your repo from history and make that your new working-set which you can stage and commit as you wish.</p> <pre><code>cd ~/git/your-repo-root git log # find the commit id you... | 119, 5766 | git, undo | <h1>How do I restore a previous version as a new commit in Git?</h1>
<p>First, I have seen the answer to this question here before, but it is buried by so many "answers" which don't answer my question properly, that I cannot find it again.</p>
<p>So here it goes: How do I restore in Git to a previous version ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,406 | git | # How do I restore a previous version as a new commit in Git?
First, I have seen the answer to this question here before, but it is buried by so many "answers" which don't answer my question properly, that I cannot find it again.
So here it goes: How do I restore in Git to a previous version in my history, so that it... | Simply "`checkout` the commit". This will overwrite your current working directory with the specified snapshot (commit) of your repo from history and make that your new working-set which you can stage and commit as you wish.
```
cd ~/git/your-repo-root
git log
# find the commit id you want
git checkout <commitId> .
``... |
13490684 | Difference between Git and Nexus? | 27 | 2012-11-21 10:01:26 | <p>I can't seem to find what the difference is between Git and <a href="http://www.sonatype.org/nexus/" rel="noreferrer">Nexus</a>. Are the two comparable?</p>
| 47,099 | 669,331 | 2016-03-19 03:07:14 | 13,490,800 | 51 | 2012-11-21 10:07:49 | 6,309 | 2013-09-25 04:48:14 | https://stackoverflow.com/q/13490684 | https://stackoverflow.com/a/13490800 | <p>There are both referential:</p>
<ul>
<li>one (<a href="http://git-scm.com/" rel="noreferrer">Git</a>) is a source referential for version control (with features like merging, branching, tags)</li>
<li>the other (<a href="http://www.sonatype.com/" rel="noreferrer">Nexus</a>) is an artifact referential for any delive... | <p>There are both referential:</p> <ul> <li>one (<a href="http://git-scm.com/" rel="noreferrer">Git</a>) is a source referential for version control (with features like merging, branching, tags)</li> <li>the other (<a href="http://www.sonatype.com/" rel="noreferrer">Nexus</a>) is an artifact referential for any delive... | 119, 7330, 15574 | git, nexus, repository | <h1>Difference between Git and Nexus?</h1>
<p>I can't seem to find what the difference is between Git and <a href="http://www.sonatype.org/nexus/" rel="noreferrer">Nexus</a>. Are the two comparable?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,408 | git | # Difference between Git and Nexus?
I can't seem to find what the difference is between Git and [Nexus](http://www.sonatype.org/nexus/). Are the two comparable? | There are both referential:
- one ([Git](http://git-scm.com/)) is a source referential for version control (with features like merging, branching, tags)
- the other ([Nexus](http://www.sonatype.com/)) is an artifact referential for any delivery (binaries or not)
The referential database differs also:
- Git has its o... |
10330678 | gitolite: PTY allocation request failed on channel 0 | 26 | 2012-04-26 09:28:28 | <p>Both jenkins (the ci-server) and my git repository are hosted on the same server. The git repo is controlled by gitolite. If I access the repository from outside, for instance from my workstation I get</p>
<pre><code>ssh git@arrakis
PTY allocation request failed on channel 0
hello simou, this is git@arrakis runnin... | 51,796 | 666,906 | 2013-03-19 16:12:31 | 10,346,575 | 51 | 2012-04-27 07:33:21 | 193,688 | 2012-04-27 09:15:08 | https://stackoverflow.com/q/10330678 | https://stackoverflow.com/a/10346575 | <p>The difference in behavior between your workstation and your server is likely due to using different versions of the OpenSSH client (<code>ssh</code>) on each system (not remote versus local). The client will request a pty from the server unless <code>-T</code> is given, or the <code>RequestTTY</code> configuration ... | <p>The difference in behavior between your workstation and your server is likely due to using different versions of the OpenSSH client (<code>ssh</code>) on each system (not remote versus local). The client will request a pty from the server unless <code>-T</code> is given, or the <code>RequestTTY</code> configuration ... | 39151 | gitolite | <h1>gitolite: PTY allocation request failed on channel 0</h1>
<p>Both jenkins (the ci-server) and my git repository are hosted on the same server. The git repo is controlled by gitolite. If I access the repository from outside, for instance from my workstation I get</p>
<pre><code>ssh git@arrakis
PTY allocation reque... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,409 | git | # gitolite: PTY allocation request failed on channel 0
Both jenkins (the ci-server) and my git repository are hosted on the same server. The git repo is controlled by gitolite. If I access the repository from outside, for instance from my workstation I get
```
ssh git@arrakis
PTY allocation request failed on channel... | The difference in behavior between your workstation and your server is likely due to using different versions of the OpenSSH client (`ssh`) on each system (not remote versus local). The client will request a pty from the server unless `-T` is given, or the `RequestTTY` configuration option is set to `no` (the latter wa... |
27032850 | What is the difference between git reset and git revert? | 22 | 2014-11-20 06:05:01 | <p>Hi I am a newbie to git and I don't understand what is the basic difference between <code>git reset</code> and <code>git revert</code>. Does <code>git revert</code> reverts the merge being pushed ? </p>
| 24,566 | 4,273,019 | 2021-03-09 09:38:04 | 27,032,988 | 51 | 2014-11-20 06:15:26 | 395,202 | 2014-11-20 06:15:26 | https://stackoverflow.com/q/27032850 | https://stackoverflow.com/a/27032988 | <p>As far as I know, they are doing totally different thing.</p>
<p><code>git revert</code> aimed to revert effects of previous commit. For example, </p>
<pre><code>A <- B <- C
^ HEAD
</code></pre>
<p>If I found B I committed before is wrong, and I want to "undo" its change, <code>git-revert</code>... | <p>As far as I know, they are doing totally different thing.</p> <p><code>git revert</code> aimed to revert effects of previous commit. For example, </p> <pre><code>A <- B <- C ^ HEAD </code></pre> <p>If I found B I committed before is wrong, and I want to "undo" its change, <code>git-revert</code>... | 119 | git | <h1>What is the difference between git reset and git revert?</h1>
<p>Hi I am a newbie to git and I don't understand what is the basic difference between <code>git reset</code> and <code>git revert</code>. Does <code>git revert</code> reverts the merge being pushed ? </p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,412 | git | # What is the difference between git reset and git revert?
Hi I am a newbie to git and I don't understand what is the basic difference between `git reset` and `git revert`. Does `git revert` reverts the merge being pushed ? | As far as I know, they are doing totally different thing.
`git revert` aimed to revert effects of previous commit. For example,
```
A <- B <- C
^ HEAD
```
If I found B I committed before is wrong, and I want to "undo" its change, `git-revert`-ing B will cause:
```
A <- B <- C <- B'
^ HEAD
... |
3402599 | How do you merge two git branches that are in different local repos/folders? | 20 | 2010-08-04 04:36:30 | <p>I have:</p>
<pre><code>folder_a/app_1.0
folder_b/app_1.1
</code></pre>
<p>And let's just say I'm working off of the master branch in both folders/repos. </p>
<p>How can I merge the branches together?</p>
| 21,703 | 207,187 | 2018-03-20 06:19:47 | 3,402,873 | 51 | 2010-08-04 05:34:31 | 19,818 | 2010-08-04 14:59:24 | https://stackoverflow.com/q/3402599 | https://stackoverflow.com/a/3402873 | <p>You must pull the commits from one repository into the other, do the merge, then pull back into the first (if you want both repositories to contain all the commits).</p>
<pre><code># switch to repo A
cd folder_a
# Add repo B as a remote repository
git remote add folderb /path/to/folder_b
# Pull B's master branch ... | <p>You must pull the commits from one repository into the other, do the merge, then pull back into the first (if you want both repositories to contain all the commits).</p> <pre><code># switch to repo A cd folder_a # Add repo B as a remote repository git remote add folderb /path/to/folder_b # Pull B's master branch ... | 119 | git | <h1>How do you merge two git branches that are in different local repos/folders?</h1>
<p>I have:</p>
<pre><code>folder_a/app_1.0
folder_b/app_1.1
</code></pre>
<p>And let's just say I'm working off of the master branch in both folders/repos. </p>
<p>How can I merge the branches together?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,413 | git | # How do you merge two git branches that are in different local repos/folders?
I have:
```
folder_a/app_1.0
folder_b/app_1.1
```
And let's just say I'm working off of the master branch in both folders/repos.
How can I merge the branches together? | You must pull the commits from one repository into the other, do the merge, then pull back into the first (if you want both repositories to contain all the commits).
```
# switch to repo A
cd folder_a
# Add repo B as a remote repository
git remote add folderb /path/to/folder_b
# Pull B's master branch into a local b... |
19978063 | Git core.safecrlf different behavior on files with same line endings | 17 | 2013-11-14 12:48:17 | <p>I have Windows machine with VS project and I use both Visual Studio and tools from Cygwin environment including Git. Sometimes I get different line endings in files after editing. I want simple solution to check files' line ending consistency before they go to the repo. Git's <code>core.safecrlf</code> is the right ... | 24,092 | 1,788,106 | 2024-10-26 05:30:09 | 21,046,682 | 51 | 2014-01-10 14:22:28 | 172,406 | 2014-06-23 01:53:58 | https://stackoverflow.com/q/19978063 | https://stackoverflow.com/a/21046682 | <p>According to your later edit <code>core.autocrlf = input</code> was the original setting. With this setting <code>CRLF</code> is converted to <code>LF</code> when checked in to the repository and <strong>is kept that way</strong> when checked out. This means a non Unix line endings aware editor like Notepad would me... | <p>According to your later edit <code>core.autocrlf = input</code> was the original setting. With this setting <code>CRLF</code> is converted to <code>LF</code> when checked in to the repository and <strong>is kept that way</strong> when checked out. This means a non Unix line endings aware editor like Notepad would me... | 64, 119, 1731, 3705, 59139 | core.autocrlf, cygwin, git, newline, windows | <h1>Git core.safecrlf different behavior on files with same line endings</h1>
<p>I have Windows machine with VS project and I use both Visual Studio and tools from Cygwin environment including Git. Sometimes I get different line endings in files after editing. I want simple solution to check files' line ending consiste... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,414 | git | # Git core.safecrlf different behavior on files with same line endings
I have Windows machine with VS project and I use both Visual Studio and tools from Cygwin environment including Git. Sometimes I get different line endings in files after editing. I want simple solution to check files' line ending consistency befor... | According to your later edit `core.autocrlf = input` was the original setting. With this setting `CRLF` is converted to `LF` when checked in to the repository and **is kept that way** when checked out. This means a non Unix line endings aware editor like Notepad would mess up the appearance of a checked out version of ... |
2044574 | Determine if directory is under git control | 75 | 2010-01-11 20:07:43 | <p>How can I tell if a given directory is part of a git respository?</p>
<p>(The following is in python, but bash or something would be fine.)</p>
<pre><code>os.path.isdir('.svn')
</code></pre>
<p>will tell you if the current directory is controlled by Subversion. Mercurial and Git just have a .hg/.git at the top of... | 43,511 | 167,531 | 2023-11-24 19:39:36 | 2,044,677 | 50 | 2010-01-11 20:27:25 | 90,685 | 2010-01-11 20:32:42 | https://stackoverflow.com/q/2044574 | https://stackoverflow.com/a/2044677 | <p>In ruby, <code>system('git rev-parse')</code> will return true if the current directory is in a git repo, and false otherwise. I imagine the pythonic equivalent should work similarly.</p>
<p><strong>EDIT:</strong> Sure enough:</p>
<pre><code># in a git repo, running ipython
>>> system('git rev-parse')
0
... | <p>In ruby, <code>system('git rev-parse')</code> will return true if the current directory is in a git repo, and false otherwise. I imagine the pythonic equivalent should work similarly.</p> <p><strong>EDIT:</strong> Sure enough:</p> <pre><code># in a git repo, running ipython >>> system('git rev-parse') 0 ... | 16, 119 | git, python | <h1>Determine if directory is under git control</h1>
<p>How can I tell if a given directory is part of a git respository?</p>
<p>(The following is in python, but bash or something would be fine.)</p>
<pre><code>os.path.isdir('.svn')
</code></pre>
<p>will tell you if the current directory is controlled by Subversion.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,417 | git | # Determine if directory is under git control
How can I tell if a given directory is part of a git respository?
(The following is in python, but bash or something would be fine.)
```
os.path.isdir('.svn')
```
will tell you if the current directory is controlled by Subversion. Mercurial and Git just have a .hg/.git ... | In ruby, `system('git rev-parse')` will return true if the current directory is in a git repo, and false otherwise. I imagine the pythonic equivalent should work similarly.
**EDIT:** Sure enough:
```
# in a git repo, running ipython
>>> system('git rev-parse')
0
# not in a git repo
>>> system('git rev-parse')
32768
... |
821895 | Exclude .svn folders within git | 69 | 2009-05-04 20:27:36 | <p>I'm trying to exclude subversion's folders from being tracked by git. I tried a couple different setups for .git/info/exclude, but it doesn't seem to work. I would use git-svn, but it's a pain to request access to get that to work, so I'd rather just work around this by excluding the folders.</p>
<p>I want to exclu... | 41,936 | 101,126 | 2013-10-22 14:55:20 | 821,918 | 50 | 2009-05-04 20:31:56 | 3,737 | 2009-05-04 20:42:02 | https://stackoverflow.com/q/821895 | https://stackoverflow.com/a/821918 | <p>I think you want to use a .gitignore file in your top-level directory. This will work if you put ".svn/entries" on a line in that file. You might just put ".svn" instead of ".svn/entries" as well.</p>
<p>EDIT: See comments. If they files are already being tracked by git, they'll always show up in <code>git status</... | <p>I think you want to use a .gitignore file in your top-level directory. This will work if you put ".svn/entries" on a line in that file. You might just put ".svn" instead of ".svn/entries" as well.</p> <p>EDIT: See comments. If they files are already being tracked by git, they'll always show up in <code>git status</... | 63, 119 | git, svn | <h1>Exclude .svn folders within git</h1>
<p>I'm trying to exclude subversion's folders from being tracked by git. I tried a couple different setups for .git/info/exclude, but it doesn't seem to work. I would use git-svn, but it's a pain to request access to get that to work, so I'd rather just work around this by exclu... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,418 | git | # Exclude .svn folders within git
I'm trying to exclude subversion's folders from being tracked by git. I tried a couple different setups for .git/info/exclude, but it doesn't seem to work. I would use git-svn, but it's a pain to request access to get that to work, so I'd rather just work around this by excluding the ... | I think you want to use a .gitignore file in your top-level directory. This will work if you put ".svn/entries" on a line in that file. You might just put ".svn" instead of ".svn/entries" as well.
EDIT: See comments. If they files are already being tracked by git, they'll always show up in `git status`. |
1251713 | Backup a GitHub repository | 63 | 2009-08-09 16:42:05 | <p><strong>What is the best way to create a local backup of a git repository hosted on GitHub, given the following requirements?:</strong></p>
<ol>
<li><p>The local backup should be a bare repo.</p></li>
<li><p>The backup should include all branches.</p></li>
<li><p>It should be easy to (incrementally) update the back... | 59,826 | 152,544 | 2025-09-22 13:29:58 | 4,172,977 | 50 | 2010-11-13 14:26:33 | 376,366 | 2012-04-15 23:48:42 | https://stackoverflow.com/q/1251713 | https://stackoverflow.com/a/4172977 | <p>To create the mirror:</p>
<pre><code>git clone --mirror git://github.com/user/project.git
</code></pre>
<p>To update:</p>
<pre><code>cd project.git
git remote update
</code></pre>
<p>To update without changing the current directory:</p>
<pre><code>git --git-dir project.git remote update
</code></pre>
| <p>To create the mirror:</p> <pre><code>git clone --mirror git://github.com/user/project.git </code></pre> <p>To update:</p> <pre><code>cd project.git git remote update </code></pre> <p>To update without changing the current directory:</p> <pre><code>git --git-dir project.git remote update </code></pre> | 119, 493 | backup, git | <h1>Backup a GitHub repository</h1>
<p><strong>What is the best way to create a local backup of a git repository hosted on GitHub, given the following requirements?:</strong></p>
<ol>
<li><p>The local backup should be a bare repo.</p></li>
<li><p>The backup should include all branches.</p></li>
<li><p>It should be eas... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,419 | git | # Backup a GitHub repository
**What is the best way to create a local backup of a git repository hosted on GitHub, given the following requirements?:**
1. The local backup should be a bare repo.
2. The backup should include all branches.
3. It should be easy to (incrementally) update the backup.
Basically, I want a ... | To create the mirror:
```
git clone --mirror git://github.com/user/project.git
```
To update:
```
cd project.git
git remote update
```
To update without changing the current directory:
```
git --git-dir project.git remote update
``` |
24625411 | Amend the second to last commit | 49 | 2014-07-08 06:52:21 | <p>If you found a bug in your last commit, you can simply recommit the last commit with</p>
<pre><code>git commit --amend
</code></pre>
<p>But if you already committed another commit, how do you resubmit the commit before that one?</p>
<hr>
<p><strong>Note:</strong> I assume, you are aware, that you should only use... | 45,905 | 1,069,083 | 2023-11-16 12:58:07 | 24,625,412 | 50 | 2014-07-08 06:52:21 | 1,069,083 | 2014-07-08 18:27:25 | https://stackoverflow.com/q/24625411 | https://stackoverflow.com/a/24625412 | <ol>
<li><p><strong>commit your fixup with</strong> </p>
<pre>git commit -a -m "fix commit (this one will be shifted up one line)"</pre>
<p>(the commit message is not important, it will be obsolete once you are finished)</p></li>
<li><p><strong>Now the magic:</strong><br>
rebase the HEAD to the second last commit b... | <ol> <li><p><strong>commit your fixup with</strong> </p> <pre>git commit -a -m "fix commit (this one will be shifted up one line)"</pre> <p>(the commit message is not important, it will be obsolete once you are finished)</p></li> <li><p><strong>Now the magic:</strong><br> rebase the HEAD to the second last commit b... | 119 | git | <h1>Amend the second to last commit</h1>
<p>If you found a bug in your last commit, you can simply recommit the last commit with</p>
<pre><code>git commit --amend
</code></pre>
<p>But if you already committed another commit, how do you resubmit the commit before that one?</p>
<hr>
<p><strong>Note:</strong> I assume... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,422 | git | # Amend the second to last commit
If you found a bug in your last commit, you can simply recommit the last commit with
```
git commit --amend
```
But if you already committed another commit, how do you resubmit the commit before that one?
---
**Note:** I assume, you are aware, that you should only use `--amend` if... | 1. **commit your fixup with**
```
git commit -a -m "fix commit (this one will be shifted up one line)"
```
(the commit message is not important, it will be obsolete once you are finished)
2. **Now the magic:**
rebase the HEAD to the second last commit but edit the commit message before in that way, t... |
4027584 | how to undo all whitespace changes with git | 48 | 2010-10-26 20:11:53 | <p>I have a git repo, where I replaced a lot of files locally.</p>
<p>git status now shows many many modified files.</p>
<p>Some are "really modified", others only differ by line endings.</p>
<p>I want the ones that differ only by line endings to go away (git reset them), but
I cannot seem to find the linux-piping-f... | 14,017 | 47,901 | 2024-07-09 14:37:58 | 4,028,018 | 50 | 2010-10-26 21:03:13 | 9,410 | 2015-08-26 11:59:14 | https://stackoverflow.com/q/4027584 | https://stackoverflow.com/a/4028018 | <p>This will do it:</p>
<pre><code> git diff -b --numstat \
| egrep $'^0\t0\t' \
| cut -d$'\t' -f3- \
| xargs git checkout HEAD --
</code></pre>
<ol>
<li>Run a diff of the working copy against the index and give a machine-readable summary for each file, ignoring changes in whitespace.</li>
<li>Find the files that ha... | <p>This will do it:</p> <pre><code> git diff -b --numstat \ | egrep $'^0\t0\t' \ | cut -d$'\t' -f3- \ | xargs git checkout HEAD -- </code></pre> <ol> <li>Run a diff of the working copy against the index and give a machine-readable summary for each file, ignoring changes in whitespace.</li> <li>Find the files that ha... | 119 | git | <h1>how to undo all whitespace changes with git</h1>
<p>I have a git repo, where I replaced a lot of files locally.</p>
<p>git status now shows many many modified files.</p>
<p>Some are "really modified", others only differ by line endings.</p>
<p>I want the ones that differ only by line endings to go away (git rese... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,423 | git | # how to undo all whitespace changes with git
I have a git repo, where I replaced a lot of files locally.
git status now shows many many modified files.
Some are "really modified", others only differ by line endings.
I want the ones that differ only by line endings to go away (git reset them), but
I cannot seem to ... | This will do it:
```
git diff -b --numstat \
| egrep $'^0\t0\t' \
| cut -d$'\t' -f3- \
| xargs git checkout HEAD --
```
1. Run a diff of the working copy against the index and give a machine-readable summary for each file, ignoring changes in whitespace.
2. Find the files that had no changes according to `diff -b`.... |
22936252 | Escape comment character (#) in git commit message | 47 | 2014-04-08 11:55:09 | <p>I have set mcedit as my editor for git commit messages. By default it ignores any lines starting with the <code>#</code> character. However odd this may seem, I need to be able to have the my commit message looking like this:</p>
<pre><code>#FOO-123: Implement bar foo
Committing work in progress
</code></pre>
<p>... | 31,371 | 774,183 | 2019-07-14 17:47:40 | 22,936,439 | 50 | 2014-04-08 12:02:48 | 6,309 | 2019-07-14 17:47:40 | https://stackoverflow.com/q/22936252 | https://stackoverflow.com/a/22936439 | <p>You can try and define a different character for comments in commit message:</p>
<pre><code>git config core.commentchar <another char>
</code></pre>
<p>As I mention in "<a href="https://stackoverflow.com/a/14931661/6309">Start a git commit message with a hashmark (<code>#</code>)</a>", this setting is availa... | <p>You can try and define a different character for comments in commit message:</p> <pre><code>git config core.commentchar <another char> </code></pre> <p>As I mention in "<a href="https://stackoverflow.com/a/14931661/6309">Start a git commit message with a hashmark (<code>#</code>)</a>", this setting is availa... | 119, 4804 | escaping, git | <h1>Escape comment character (#) in git commit message</h1>
<p>I have set mcedit as my editor for git commit messages. By default it ignores any lines starting with the <code>#</code> character. However odd this may seem, I need to be able to have the my commit message looking like this:</p>
<pre><code>#FOO-123: Imple... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,424 | git | # Escape comment character (#) in git commit message
I have set mcedit as my editor for git commit messages. By default it ignores any lines starting with the `#` character. However odd this may seem, I need to be able to have the my commit message looking like this:
```
#FOO-123: Implement bar foo
Committing work i... | You can try and define a different character for comments in commit message:
```
git config core.commentchar <another char>
```
As I mention in "[Start a git commit message with a hashmark (`#`)](https://stackoverflow.com/a/14931661/6309)", this setting is available since git 1.8.2 (February 2013).
In your case:
``... |
51696931 | List all local git branches without an asterisk | 44 | 2018-08-05 17:59:13 | <p>If I run <code>git branch</code>, I get something like:</p>
<pre><code>* master
dev
foo
</code></pre>
<p>if I do <code>git branch -r</code>, it will show all branches on the remote, without an asterisk (where the asterisk shows my current checked-out branch).</p>
<p>How can I list all the local branches, with... | 13,202 | null | 2021-03-26 19:17:34 | 51,697,007 | 50 | 2018-08-05 18:09:48 | 112,968 | 2021-03-26 19:17:34 | https://stackoverflow.com/q/51696931 | https://stackoverflow.com/a/51697007 | <p>You can use <a href="https://git-scm.com/docs/git-for-each-ref" rel="noreferrer"><code>for-each-ref</code></a>:</p>
<pre><code>git for-each-ref --format='%(refname:short)' refs/heads/
</code></pre>
| <p>You can use <a href="https://git-scm.com/docs/git-for-each-ref" rel="noreferrer"><code>for-each-ref</code></a>:</p> <pre><code>git for-each-ref --format='%(refname:short)' refs/heads/ </code></pre> | 119, 76220 | git, git-branch | <h1>List all local git branches without an asterisk</h1>
<p>If I run <code>git branch</code>, I get something like:</p>
<pre><code>* master
dev
foo
</code></pre>
<p>if I do <code>git branch -r</code>, it will show all branches on the remote, without an asterisk (where the asterisk shows my current checked-out bra... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,426 | git | # List all local git branches without an asterisk
If I run `git branch`, I get something like:
```
* master
dev
foo
```
if I do `git branch -r`, it will show all branches on the remote, without an asterisk (where the asterisk shows my current checked-out branch).
How can I list all the local branches, without a... | You can use [`for-each-ref`](https://git-scm.com/docs/git-for-each-ref):
```
git for-each-ref --format='%(refname:short)' refs/heads/
``` |
6104072 | git update-index --assume-unchanged and git reset | 43 | 2011-05-23 23:11:22 | <p>Here is the scenario:</p>
<p>In my working directory, I have a number of files (let's call them A,B,C) that I've edited. I then ran <code>git update-index --assume-unchanged</code> on those files. Now <code>git status</code> returns blank. Good.</p>
<p>Now, if I do a <code>git reset --hard</code>, the contents ... | 12,548 | 615,315 | 2017-04-12 12:09:08 | 6,105,906 | 50 | 2011-05-24 05:07:30 | 526,535 | 2011-05-24 05:07:30 | https://stackoverflow.com/q/6104072 | https://stackoverflow.com/a/6105906 | <p>You can do:</p>
<pre><code>git update-index --skip-worktree A
</code></pre>
| <p>You can do:</p> <pre><code>git update-index --skip-worktree A </code></pre> | 119, 12626 | git, reset | <h1>git update-index --assume-unchanged and git reset</h1>
<p>Here is the scenario:</p>
<p>In my working directory, I have a number of files (let's call them A,B,C) that I've edited. I then ran <code>git update-index --assume-unchanged</code> on those files. Now <code>git status</code> returns blank. Good.</p>
<p>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,427 | git | # git update-index --assume-unchanged and git reset
Here is the scenario:
In my working directory, I have a number of files (let's call them A,B,C) that I've edited. I then ran `git update-index --assume-unchanged` on those files. Now `git status` returns blank. Good.
Now, if I do a `git reset --hard`, the contents ... | You can do:
```
git update-index --skip-worktree A
``` |
19442616 | How to preserve all ignored files in git clean -fd? | 41 | 2013-10-18 05:59:50 | <p>When I have .gitignore <code>data/*</code> and run <code>git clean -fd</code>, the data folder and all its content files are deleted.</p>
<p>What I want is to delete all unrevisioned files in a git repo while excluding all ignored files (i.e. DON'T delete gitignored files). What could I do?</p>
| 12,747 | 1,667,884 | 2019-08-20 22:42:56 | 19,442,789 | 50 | 2013-10-18 06:13:48 | 1,316,620 | 2019-02-24 21:45:09 | https://stackoverflow.com/q/19442616 | https://stackoverflow.com/a/19442789 | <p>Git normally doesn't clean ignored files unless the <code>-x</code> flag is specified, but strangely it cleans out when configured as you did (<code>folder/*</code>).</p>
<p>As @VonC pointed out, you should change your <code>.gitignore</code>-file to ignore the directory (<code>data/</code>) rather than its content... | <p>Git normally doesn't clean ignored files unless the <code>-x</code> flag is specified, but strangely it cleans out when configured as you did (<code>folder/*</code>).</p> <p>As @VonC pointed out, you should change your <code>.gitignore</code>-file to ignore the directory (<code>data/</code>) rather than its content... | 119, 68596 | git, git-clean | <h1>How to preserve all ignored files in git clean -fd?</h1>
<p>When I have .gitignore <code>data/*</code> and run <code>git clean -fd</code>, the data folder and all its content files are deleted.</p>
<p>What I want is to delete all unrevisioned files in a git repo while excluding all ignored files (i.e. DON'T delete... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,428 | git | # How to preserve all ignored files in git clean -fd?
When I have .gitignore `data/*` and run `git clean -fd`, the data folder and all its content files are deleted.
What I want is to delete all unrevisioned files in a git repo while excluding all ignored files (i.e. DON'T delete gitignored files). What could I do? | Git normally doesn't clean ignored files unless the `-x` flag is specified, but strangely it cleans out when configured as you did (`folder/*`).
As @VonC pointed out, you should change your `.gitignore`-file to ignore the directory (`data/`) rather than its contents (`data/*`).
It's a subtle difference, but it matter... |
4936778 | Git merge commits | 41 | 2011-02-08 17:45:27 | <p>I'm new to git (and enjoying it a lot!). While developing in a new branch, I kept committing the various development 'states' of my application. Now I have to check it in for review but didn't want everything to go in different commits (different comments and ids).</p>
<p>How can I do a push of all changes as if it... | 17,341 | 258,817 | 2018-10-05 18:12:40 | 4,936,779 | 50 | 2011-02-08 18:09:38 | 128,384 | 2011-02-08 20:44:39 | https://stackoverflow.com/q/4936778 | https://stackoverflow.com/a/4936779 | <pre><code>git rebase -i HEAD~5
</code></pre>
<p>allows you to interactively select which of the 5 last commits to join into one; off the top of my head it opens the editor with something like this</p>
<pre><code>pick xxxx commit1
pick xxxx commit2
pick xxxx commit3
pick xxxx commit4
pick xxxx commit5
</code></pre>
... | <pre><code>git rebase -i HEAD~5 </code></pre> <p>allows you to interactively select which of the 5 last commits to join into one; off the top of my head it opens the editor with something like this</p> <pre><code>pick xxxx commit1 pick xxxx commit2 pick xxxx commit3 pick xxxx commit4 pick xxxx commit5 </code></pre> ... | 119, 28897 | git, git-merge | <h1>Git merge commits</h1>
<p>I'm new to git (and enjoying it a lot!). While developing in a new branch, I kept committing the various development 'states' of my application. Now I have to check it in for review but didn't want everything to go in different commits (different comments and ids).</p>
<p>How can I do a p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,429 | git | # Git merge commits
I'm new to git (and enjoying it a lot!). While developing in a new branch, I kept committing the various development 'states' of my application. Now I have to check it in for review but didn't want everything to go in different commits (different comments and ids).
How can I do a push of all chang... | ```
git rebase -i HEAD~5
```
allows you to interactively select which of the 5 last commits to join into one; off the top of my head it opens the editor with something like this
```
pick xxxx commit1
pick xxxx commit2
pick xxxx commit3
pick xxxx commit4
pick xxxx commit5
```
you change this into
```
pick xxxx commi... |
6520905 | Git octopus merge order of multiple branches | 40 | 2011-06-29 12:50:58 | <p>I had an interesting thing happen using git, wondering if anyone could explain it to me so I can understand better. </p>
<p>When doing a merge of multiple branches (A,B), </p>
<pre><code>git merge A B
</code></pre>
<p>fails as non-fast-forward, while </p>
<pre><code>git merge B A
</code></pre>
<p>worked well. W... | 26,680 | 199,787 | 2022-10-08 21:44:19 | 6,521,223 | 50 | 2011-06-29 13:15:03 | 47,978 | 2022-10-08 21:44:19 | https://stackoverflow.com/q/6520905 | https://stackoverflow.com/a/6521223 | <p>Let's assume that A is a strict, <a href="http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging" rel="nofollow noreferrer">direct child</a> of the current branch. Then assume that B is a strict, direct child <strong>of A</strong>.</p>
<p>The octopus merge, which <a href="https://git.kernel.org/cgit/gi... | <p>Let's assume that A is a strict, <a href="http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging" rel="nofollow noreferrer">direct child</a> of the current branch. Then assume that B is a strict, direct child <strong>of A</strong>.</p> <p>The octopus merge, which <a href="https://git.kernel.org/cgit/gi... | 119, 53847 | branching-and-merging, git | <h1>Git octopus merge order of multiple branches</h1>
<p>I had an interesting thing happen using git, wondering if anyone could explain it to me so I can understand better. </p>
<p>When doing a merge of multiple branches (A,B), </p>
<pre><code>git merge A B
</code></pre>
<p>fails as non-fast-forward, while </p>
<pr... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,431 | git | # Git octopus merge order of multiple branches
I had an interesting thing happen using git, wondering if anyone could explain it to me so I can understand better.
When doing a merge of multiple branches (A,B),
```
git merge A B
```
fails as non-fast-forward, while
```
git merge B A
```
worked well. Why would that... | Let's assume that A is a strict, [direct child](http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging) of the current branch. Then assume that B is a strict, direct child **of A**.
The octopus merge, which [processes heads given as arguments from left to right](https://git.kernel.org/cgit/git/git.git/tr... |
2431493 | Recover from inadvertent skip during rebase | 40 | 2010-03-12 09:05:42 | <p>I just tried to rebase a very old branch with a minor modification onto my master.
There was a problem with merging just one of the three files involved, so I did an unthinking --skip, thinking that it would just skip that file, but as it happened, it seems to have skipped all my changes, and rolled forwards. So now... | 10,184 | 11,410 | 2017-05-22 13:11:29 | 2,433,000 | 50 | 2010-03-12 13:29:40 | 102,200 | 2010-03-12 13:29:40 | https://stackoverflow.com/q/2431493 | https://stackoverflow.com/a/2433000 | <p>First, make a tarball of your git working folder. This makes it easier to try it several times.</p>
<p>Lets assume the following happened</p>
<ul>
<li>git checkout another-old-branch</li>
<li>git rebase master</li>
<li>some problems (which you skipped)</li>
</ul>
<p>at this point you are now still in another-old-... | <p>First, make a tarball of your git working folder. This makes it easier to try it several times.</p> <p>Lets assume the following happened</p> <ul> <li>git checkout another-old-branch</li> <li>git rebase master</li> <li>some problems (which you skipped)</li> </ul> <p>at this point you are now still in another-old-... | 119, 8974 | git, rebase | <h1>Recover from inadvertent skip during rebase</h1>
<p>I just tried to rebase a very old branch with a minor modification onto my master.
There was a problem with merging just one of the three files involved, so I did an unthinking --skip, thinking that it would just skip that file, but as it happened, it seems to hav... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,432 | git | # Recover from inadvertent skip during rebase
I just tried to rebase a very old branch with a minor modification onto my master.
There was a problem with merging just one of the three files involved, so I did an unthinking --skip, thinking that it would just skip that file, but as it happened, it seems to have skipped... | First, make a tarball of your git working folder. This makes it easier to try it several times.
Lets assume the following happened
- git checkout another-old-branch
- git rebase master
- some problems (which you skipped)
at this point you are now still in another-old-branch and your reflog shows you:
```
6f8348f HE... |
26125162 | difference between origin/branch_name and branch_name? | 38 | 2014-09-30 15:59:14 | <p>for pushing to bitbucket.</p>
<p>If I do: <code>git push origin origin/branch_name</code> my commits are not pushed.</p>
<pre><code>Total 0 (delta 0), reused 0 (delta 0)
</code></pre>
<p>If I do <code>git push origin branch_name</code> my commits are pushed:</p>
<pre><code>Counting objects: 160, done.
Delta comp... | 35,420 | 1,459,782 | 2024-03-20 14:24:36 | 26,125,339 | 50 | 2014-09-30 16:09:24 | 2,541,573 | 2024-03-20 14:24:36 | https://stackoverflow.com/q/26125162 | https://stackoverflow.com/a/26125339 | <p>You have to keep in mind that there are different types of branches:</p>
<ul>
<li>(Purely) <em>local</em> branches, i.e. branches you commit to,</li>
<li><em>Branches that live in a remote repository</em>, for lack of a better term. You may know the remote repository in question under a remote name, such as <code>or... | <p>You have to keep in mind that there are different types of branches:</p> <ul> <li>(Purely) <em>local</em> branches, i.e. branches you commit to,</li> <li><em>Branches that live in a remote repository</em>, for lack of a better term. You may know the remote repository in question under a remote name, such as <code>or... | 119, 8337 | bitbucket, git | <h1>difference between origin/branch_name and branch_name?</h1>
<p>for pushing to bitbucket.</p>
<p>If I do: <code>git push origin origin/branch_name</code> my commits are not pushed.</p>
<pre><code>Total 0 (delta 0), reused 0 (delta 0)
</code></pre>
<p>If I do <code>git push origin branch_name</code> my commits are... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,434 | git | # difference between origin/branch_name and branch_name?
for pushing to bitbucket.
If I do: `git push origin origin/branch_name` my commits are not pushed.
```
Total 0 (delta 0), reused 0 (delta 0)
```
If I do `git push origin branch_name` my commits are pushed:
```
Counting objects: 160, done.
Delta compression u... | You have to keep in mind that there are different types of branches:
- (Purely) *local* branches, i.e. branches you commit to,
- *Branches that live in a remote repository*, for lack of a better term. You may know the remote repository in question under a remote name, such as `origin`. From that repository's point of ... |
19475387 | How to handle/fix git add/add conflicts? | 38 | 2013-10-20 08:29:14 | <p>I'm not sure when this error occurs, I haven't found any descriptions in google.</p>
<p>So my colleagues commited some new files and changed files on branch1. I then got these changes and merged them into my branch(branch2) but NOT using git merge but manually using beyond compare (I know it's a bad practice mergin... | 45,380 | 840,488 | 2018-10-25 16:27:21 | 19,475,535 | 50 | 2013-10-20 08:49:29 | 641,955 | 2018-10-25 16:27:21 | https://stackoverflow.com/q/19475387 | https://stackoverflow.com/a/19475535 | <p>You get <strong>CONFLICT (add/add): Merge conflict in ...</strong> conflicts because the files are in fact not the same. You can see the difference using the <code>diff</code> command, for example:</p>
<pre><code>git diff branch1 branch2 -- path/to/file
</code></pre>
<p>where <code>branch1</code> and <code>branch2... | <p>You get <strong>CONFLICT (add/add): Merge conflict in ...</strong> conflicts because the files are in fact not the same. You can see the difference using the <code>diff</code> command, for example:</p> <pre><code>git diff branch1 branch2 -- path/to/file </code></pre> <p>where <code>branch1</code> and <code>branch2... | 119 | git | <h1>How to handle/fix git add/add conflicts?</h1>
<p>I'm not sure when this error occurs, I haven't found any descriptions in google.</p>
<p>So my colleagues commited some new files and changed files on branch1. I then got these changes and merged them into my branch(branch2) but NOT using git merge but manually using... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,435 | git | # How to handle/fix git add/add conflicts?
I'm not sure when this error occurs, I haven't found any descriptions in google.
So my colleagues commited some new files and changed files on branch1. I then got these changes and merged them into my branch(branch2) but NOT using git merge but manually using beyond compare ... | You get **CONFLICT (add/add): Merge conflict in ...** conflicts because the files are in fact not the same. You can see the difference using the `diff` command, for example:
```
git diff branch1 branch2 -- path/to/file
```
where `branch1` and `branch2` are the names of the branches you want to compare.
Or, an easier... |
19413537 | Invalid SSL certificate when pushing to Git server | 37 | 2013-10-16 20:46:34 | <p>I am running Gitblit on a Windows Server and am trying to push data to a repository from another machine on the network. I have used a SSL certificate (not self signed, but I think signed by my company? Not really sure how that works but Chrome, IE, etc. see it is identity verified).</p>
<p>The server that runs Git... | 92,302 | 888,617 | 2024-10-17 12:36:48 | 26,128,676 | 50 | 2014-09-30 19:33:49 | 3,906,760 | 2021-05-26 09:40:56 | https://stackoverflow.com/q/19413537 | https://stackoverflow.com/a/26128676 | <p>Git for Windows has its own trust store of trusted certificates which is normally located in the file</p>
<ul>
<li>Git for Windows <=1.9: <code>[Git installdir]\bin\curl-ca-bundle.crt</code> (e.g., <code>C:\Program Files (x86)\Git\bin\curl-ca-bundle.crt</code>; configured by the key <code>http.sslCAinfo</code> in... | <p>Git for Windows has its own trust store of trusted certificates which is normally located in the file</p> <ul> <li>Git for Windows <=1.9: <code>[Git installdir]\bin\curl-ca-bundle.crt</code> (e.g., <code>C:\Program Files (x86)\Git\bin\curl-ca-bundle.crt</code>; configured by the key <code>http.sslCAinfo</code> in... | 119, 641, 5357, 31409, 94340 | credentials, git, gitblit, ssl, tortoisegit | <h1>Invalid SSL certificate when pushing to Git server</h1>
<p>I am running Gitblit on a Windows Server and am trying to push data to a repository from another machine on the network. I have used a SSL certificate (not self signed, but I think signed by my company? Not really sure how that works but Chrome, IE, etc. se... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,437 | git | # Invalid SSL certificate when pushing to Git server
I am running Gitblit on a Windows Server and am trying to push data to a repository from another machine on the network. I have used a SSL certificate (not self signed, but I think signed by my company? Not really sure how that works but Chrome, IE, etc. see it is i... | Git for Windows has its own trust store of trusted certificates which is normally located in the file
- Git for Windows <=1.9: `[Git installdir]\bin\curl-ca-bundle.crt` (e.g., `C:\Program Files (x86)\Git\bin\curl-ca-bundle.crt`; configured by the key `http.sslCAinfo` in `[Git installdir]\etc\gitconfig`).
- Git for Win... |
5245223 | How can I 'grep' files in a Git repository? | 37 | 2011-03-09 11:37:35 | <p>I love <a href="https://git-scm.com/docs/git-grep" rel="nofollow noreferrer"><code>git grep</code></a> to search in all files checked in to a repository. It's great. But is it possible to use it (or some other Git command) to just use to find files (independent of content)?</p>
<p>At the moment I do this:</p>
<pre><... | 51,950 | 205,832 | 2024-02-02 20:41:15 | 5,245,252 | 50 | 2011-03-09 11:39:53 | 85,134 | 2024-01-28 05:17:32 | https://stackoverflow.com/q/5245223 | https://stackoverflow.com/a/5245252 | <p>You may want <code>git ls-files</code> which lists the files in the index (and automatically adjusts for your current directory inside the Git work directory).</p>
| <p>You may want <code>git ls-files</code> which lists the files in the index (and automatically adjusts for your current directory inside the Git work directory).</p> | 119, 1271 | git, grep | <h1>How can I 'grep' files in a Git repository?</h1>
<p>I love <a href="https://git-scm.com/docs/git-grep" rel="nofollow noreferrer"><code>git grep</code></a> to search in all files checked in to a repository. It's great. But is it possible to use it (or some other Git command) to just use to find files (independent of... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,439 | git | # How can I 'grep' files in a Git repository?
I love [`git grep`](https://git-scm.com/docs/git-grep) to search in all files checked in to a repository. It's great. But is it possible to use it (or some other Git command) to just use to find files (independent of content)?
At the moment I do this:
```
find . | grep m... | You may want `git ls-files` which lists the files in the index (and automatically adjusts for your current directory inside the Git work directory). |
11260981 | What is a stash? | 36 | 2012-06-29 11:28:48 | <p>I have googled and searched in various places for a while, but have not found a good answer. What is a stash, and what is it used for?</p>
<p>(Source of confusion: using beautiful Fuel with Fossil, clicked the "Stash changes" button, see files in there with question marks, and don't know what to do with them ...)</... | 57,591 | 1,341,569 | 2024-04-11 01:09:56 | 42,457,202 | 50 | 2017-02-25 14:18:14 | 1,755,598 | 2023-09-13 05:54:24 | https://stackoverflow.com/q/11260981 | https://stackoverflow.com/a/42457202 | <h1><code>First of all: let us understand why do we need to use stash?</code></h1>
<p>In order to understand what stash is, we first need to understand the <code>3-states</code>. Git has a built-in model named <code>3-states</code> which is the internal git structure for working with local repository.</p>
<p><a href="h... | <h1><code>First of all: let us understand why do we need to use stash?</code></h1> <p>In order to understand what stash is, we first need to understand the <code>3-states</code>. Git has a built-in model named <code>3-states</code> which is the internal git structure for working with local repository.</p> <p><a href="h... | 119, 11746, 13091 | fossil, git, git-stash | <h1>What is a stash?</h1>
<p>I have googled and searched in various places for a while, but have not found a good answer. What is a stash, and what is it used for?</p>
<p>(Source of confusion: using beautiful Fuel with Fossil, clicked the "Stash changes" button, see files in there with question marks, and don't know w... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,440 | git | # What is a stash?
I have googled and searched in various places for a while, but have not found a good answer. What is a stash, and what is it used for?
(Source of confusion: using beautiful Fuel with Fossil, clicked the "Stash changes" button, see files in there with question marks, and don't know what to do with t... | # `First of all: let us understand why do we need to use stash?`
In order to understand what stash is, we first need to understand the `3-states`. Git has a built-in model named `3-states` which is the internal git structure for working with local repository.
[](htt... |
27489189 | git-add only whitespace changes? | 36 | 2014-12-15 17:02:16 | <p>The style of my project does say to trim trailing whitespace, but this makes diffs very, very messy. I like to consolidate them to one commit before I commit the actual fix.</p>
<p>This is closely related to <a href="https://stackoverflow.com/q/3515597/1443496">Add only non-whitespace changes</a>, but it is asking ... | 13,620 | 1,443,496 | 2016-07-21 17:22:13 | 27,489,273 | 50 | 2014-12-15 17:07:08 | 1,204,143 | 2014-12-15 17:07:08 | https://stackoverflow.com/q/27489189 | https://stackoverflow.com/a/27489273 | <p>You can try the following "trick":</p>
<pre><code>git add -A
git diff --cached -w | git apply --cached -R
</code></pre>
<p>This basically adds everything to the index, then unstages all changes which affect more than whitespace.</p>
| <p>You can try the following "trick":</p> <pre><code>git add -A git diff --cached -w | git apply --cached -R </code></pre> <p>This basically adds everything to the index, then unstages all changes which affect more than whitespace.</p> | 119, 1084 | git, whitespace | <h1>git-add only whitespace changes?</h1>
<p>The style of my project does say to trim trailing whitespace, but this makes diffs very, very messy. I like to consolidate them to one commit before I commit the actual fix.</p>
<p>This is closely related to <a href="https://stackoverflow.com/q/3515597/1443496">Add only non... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,441 | git | # git-add only whitespace changes?
The style of my project does say to trim trailing whitespace, but this makes diffs very, very messy. I like to consolidate them to one commit before I commit the actual fix.
This is closely related to [Add only non-whitespace changes](https://stackoverflow.com/q/3515597/1443496), bu... | You can try the following "trick":
```
git add -A
git diff --cached -w | git apply --cached -R
```
This basically adds everything to the index, then unstages all changes which affect more than whitespace. |
5998987 | Splitting a set of files within a git repo into their own repository, preserving relevant history | 36 | 2011-05-14 00:13:07 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/2797191/how-to-split-a-git-repository-while-preserving-subdirectories">How to split a git repository while preserving subdirectories?</a> </p>
</blockquote>
<p>At one point I added my code to an existing git re... | 9,521 | 691,627 | 2014-09-05 14:17:42 | 6,006,679 | 50 | 2011-05-15 05:30:24 | 691,627 | 2014-09-05 14:17:35 | https://stackoverflow.com/q/5998987 | https://stackoverflow.com/a/6006679 | <p>Just to close the loop on this so it appears as answered.</p>
<p>By using <code>index-filter</code> or <code>tree-filter</code> and then applying reverse logic like <code>git ls-tree</code> piped into (multiple) <code>grep -v</code>'s piped into <code>xargs</code> for <code>git rm</code> you can indeed remove every... | <p>Just to close the loop on this so it appears as answered.</p> <p>By using <code>index-filter</code> or <code>tree-filter</code> and then applying reverse logic like <code>git ls-tree</code> piped into (multiple) <code>grep -v</code>'s piped into <code>xargs</code> for <code>git rm</code> you can indeed remove every... | 119, 46509 | git, git-filter-branch | <h1>Splitting a set of files within a git repo into their own repository, preserving relevant history</h1>
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/2797191/how-to-split-a-git-repository-while-preserving-subdirectories">How to split a git repository while ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,442 | git | # Splitting a set of files within a git repo into their own repository, preserving relevant history
> **Possible Duplicate:**
> [How to split a git repository while preserving subdirectories?](https://stackoverflow.com/questions/2797191/how-to-split-a-git-repository-while-preserving-subdirectories)
At one point I a... | Just to close the loop on this so it appears as answered.
By using `index-filter` or `tree-filter` and then applying reverse logic like `git ls-tree` piped into (multiple) `grep -v`'s piped into `xargs` for `git rm` you can indeed remove everything that doesn't match a narrow set of file names/directories. Here is the... |
3473935 | Git Merge Recursive Ours - Command Syntax Example | 36 | 2010-08-13 04:40:30 | <p>What is the right format for a git merge with a strategy of recursive ours? (not to be confused with the git merge ours strategy)</p>
<p><a href="http://www.kernel.org/pub/software/scm/git/docs/git-merge.html" rel="noreferrer">http://www.kernel.org/pub/software/scm/git/docs/git-merge.html</a></p>
<p>I tried a bun... | 6,688 | 400,836 | 2012-05-07 21:52:48 | 3,570,586 | 50 | 2010-08-25 22:03:26 | 13,356 | 2010-08-25 22:03:26 | https://stackoverflow.com/q/3473935 | https://stackoverflow.com/a/3570586 | <p><code>git merge -s recursive -X ours foo</code></p>
| <p><code>git merge -s recursive -X ours foo</code></p> | 119, 717, 28897 | git, git-merge, merge | <h1>Git Merge Recursive Ours - Command Syntax Example</h1>
<p>What is the right format for a git merge with a strategy of recursive ours? (not to be confused with the git merge ours strategy)</p>
<p><a href="http://www.kernel.org/pub/software/scm/git/docs/git-merge.html" rel="noreferrer">http://www.kernel.org/pub/sof... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,443 | git | # Git Merge Recursive Ours - Command Syntax Example
What is the right format for a git merge with a strategy of recursive ours? (not to be confused with the git merge ours strategy)
<http://www.kernel.org/pub/software/scm/git/docs/git-merge.html>
I tried a bunch of ways and it doesn't seem to work.
```
git merge fo... | `git merge -s recursive -X ours foo` |
16453941 | How to set no "fast forward" as default when using git merge | 32 | 2013-05-09 03:39:08 | <p>From the <a href="https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging" rel="nofollow noreferrer">git book</a>:</p>
<blockquote>
<p>You’ll notice the phrase "Fast forward" in that merge. Because the commit pointed to by the branch you merged in was directly upstream of the commit you’re... | 12,000 | 1,270,219 | 2024-10-03 17:03:23 | 16,454,038 | 50 | 2013-05-09 03:51:46 | 770,830 | 2013-05-09 03:51:46 | https://stackoverflow.com/q/16453941 | https://stackoverflow.com/a/16454038 | <p>Set the config variable <code>merge.ff</code> to <code>false</code>:</p>
<pre><code>git config --global merge.ff false
</code></pre>
<p>(Without <code>--global</code> to limit the effect to the current project)</p>
| <p>Set the config variable <code>merge.ff</code> to <code>false</code>:</p> <pre><code>git config --global merge.ff false </code></pre> <p>(Without <code>--global</code> to limit the effect to the current project)</p> | 119, 28897 | git, git-merge | <h1>How to set no "fast forward" as default when using git merge</h1>
<p>From the <a href="https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging" rel="nofollow noreferrer">git book</a>:</p>
<blockquote>
<p>You’ll notice the phrase "Fast forward" in that merge. Because the commit pointed to ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,447 | git | # How to set no "fast forward" as default when using git merge
From the [git book](https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging):
> You’ll notice the phrase "Fast forward" in that merge. Because the commit pointed to by the branch you merged in was directly upstream of the commit you’re on... | Set the config variable `merge.ff` to `false`:
```
git config --global merge.ff false
```
(Without `--global` to limit the effect to the current project) |
4225350 | Turning off the pager in Git for the stash command only | 32 | 2010-11-19 13:17:11 | <p>I generally like the use of the pager in Git, but for <code>git stash</code> the pager annoys me. When calling <code>git stash list</code>, I don't want to be shown the three lines of output in the pager. It forces me to press <kbd>Q</kbd> just to make the output unavailable again when typing the follow-up <code>gi... | 5,440 | 279,627 | 2025-05-03 22:41:15 | 8,172,857 | 50 | 2011-11-17 19:10:59 | 774 | 2011-11-17 19:10:59 | https://stackoverflow.com/q/4225350 | https://stackoverflow.com/a/8172857 | <p>As of 1.7.7.3, <code>git config --global pager.stash false</code> accomplishes this.</p>
| <p>As of 1.7.7.3, <code>git config --global pager.stash false</code> accomplishes this.</p> | 119, 13091, 33345 | git, git-stash, pager | <h1>Turning off the pager in Git for the stash command only</h1>
<p>I generally like the use of the pager in Git, but for <code>git stash</code> the pager annoys me. When calling <code>git stash list</code>, I don't want to be shown the three lines of output in the pager. It forces me to press <kbd>Q</kbd> just to mak... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,448 | git | # Turning off the pager in Git for the stash command only
I generally like the use of the pager in Git, but for `git stash` the pager annoys me. When calling `git stash list`, I don't want to be shown the three lines of output in the pager. It forces me to press `Q` just to make the output unavailable again when typin... | As of 1.7.7.3, `git config --global pager.stash false` accomplishes this. |
5595355 | Git ignore particular files | 30 | 2011-04-08 12:56:41 | <p>I've been playing around with it for a while and I like it very much.
Let me describe my case.</p>
<p>I have two computers where I have my repositories and a remote repository.</p>
<p>in my files I have one configuration file which differs on both computers. so when I do pull on my computers I don't need that conf... | 23,721 | 433,879 | 2020-08-25 15:45:48 | 5,595,502 | 50 | 2011-04-08 13:08:28 | 561,186 | 2013-02-08 11:01:29 | https://stackoverflow.com/q/5595355 | https://stackoverflow.com/a/5595502 | <p><strong>.gitignore is for files/folders that you haven't checked in already</strong>. It's essentially a text file that you create in the repository and has a list of paths relative to the directory it was placed in, which Git will ignore. You can check-in the .gitignore file as part of the repository. you can find ... | <p><strong>.gitignore is for files/folders that you haven't checked in already</strong>. It's essentially a text file that you create in the repository and has a list of paths relative to the directory it was placed in, which Git will ignore. You can check-in the .gitignore file as part of the repository. you can find ... | 119, 456, 21628 | git, msysgit, version-control | <h1>Git ignore particular files</h1>
<p>I've been playing around with it for a while and I like it very much.
Let me describe my case.</p>
<p>I have two computers where I have my repositories and a remote repository.</p>
<p>in my files I have one configuration file which differs on both computers. so when I do pull o... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,449 | git | # Git ignore particular files
I've been playing around with it for a while and I like it very much.
Let me describe my case.
I have two computers where I have my repositories and a remote repository.
in my files I have one configuration file which differs on both computers. so when I do pull on my computers I don't ... | **.gitignore is for files/folders that you haven't checked in already**. It's essentially a text file that you create in the repository and has a list of paths relative to the directory it was placed in, which Git will ignore. You can check-in the .gitignore file as part of the repository. you can find examples - [at t... |
2538015 | Why won't git-daemon serve my repository? | 29 | 2010-03-29 13:03:15 | <p>I set up <code>.git</code> in a directory on my local machine. I then run:</p>
<pre>mkdir a
cd a
git init
git daemon</pre>
<p>When I attempt to clone the repository in <code>a</code>, I get the following error:</p>
<pre>mkdir b
cd b
git clone git://127.0.0.1
Initialized empty Git repository in /b/127.0.0.1/.git/
... | 25,394 | 190,822 | 2014-01-06 22:35:25 | 2,539,138 | 50 | 2010-03-29 15:28:51 | 123,109 | 2010-03-29 15:28:51 | https://stackoverflow.com/q/2538015 | https://stackoverflow.com/a/2539138 | <p>You need to let <code>git-daemon</code> know it may export your repository:</p>
<pre>$ git init --bare /tmp/my-repo.git
Initialized empty Git repository in /tmp/my-repo.git/
$ git daemon --verbose --base-path=/tmp --export-all /tmp/my-repo.git &
$ git clone git://`hostname`/my-repo.git
Initialized empty Git repos... | <p>You need to let <code>git-daemon</code> know it may export your repository:</p> <pre>$ git init --bare /tmp/my-repo.git Initialized empty Git repository in /tmp/my-repo.git/ $ git daemon --verbose --base-path=/tmp --export-all /tmp/my-repo.git & $ git clone git://`hostname`/my-repo.git Initialized empty Git repos... | 119, 53251 | git, git-daemon | <h1>Why won't git-daemon serve my repository?</h1>
<p>I set up <code>.git</code> in a directory on my local machine. I then run:</p>
<pre>mkdir a
cd a
git init
git daemon</pre>
<p>When I attempt to clone the repository in <code>a</code>, I get the following error:</p>
<pre>mkdir b
cd b
git clone git://127.0.0.1
Init... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,450 | git | # Why won't git-daemon serve my repository?
I set up `.git` in a directory on my local machine. I then run:
```
mkdir a
cd a
git init
git daemon
```
When I attempt to clone the repository in `a`, I get the following error:
```
mkdir b
cd b
git clone git://127.0.0.1
Initialized empty Git repository in /b/127.0.0.1/.... | You need to let `git-daemon` know it may export your repository:
```
$ git init --bare /tmp/my-repo.git
Initialized empty Git repository in /tmp/my-repo.git/
$ git daemon --verbose --base-path=/tmp --export-all /tmp/my-repo.git &
$ git clone git://`hostname`/my-repo.git
Initialized empty Git repository in /tmp/my-re... |
10521628 | Git: Push to a remote repository with a message | 26 | 2012-05-09 18:04:27 | <p>My company is incorporating iRise for prototyping and it lacks any kind of versioning (unless making copies of your files with different file names = versioning). Anyway, we're using Git for our version control and since the typical iRise user here will be a graphic/web designer I want to automate the process as muc... | 104,835 | 468,455 | 2013-03-13 20:53:42 | 10,521,668 | 50 | 2012-05-09 18:06:36 | 526,535 | 2012-05-09 18:06:36 | https://stackoverflow.com/q/10521628 | https://stackoverflow.com/a/10521668 | <p>You will have to do a commit ( after adding files)</p>
<pre><code>git commit -m 'message'
</code></pre>
<p>and then push:</p>
<pre><code>git push TestProject master
</code></pre>
<p>You cannot associate a message to the push.</p>
| <p>You will have to do a commit ( after adding files)</p> <pre><code>git commit -m 'message' </code></pre> <p>and then push:</p> <pre><code>git push TestProject master </code></pre> <p>You cannot associate a message to the push.</p> | 119, 1863 | git, message | <h1>Git: Push to a remote repository with a message</h1>
<p>My company is incorporating iRise for prototyping and it lacks any kind of versioning (unless making copies of your files with different file names = versioning). Anyway, we're using Git for our version control and since the typical iRise user here will be a g... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,452 | git | # Git: Push to a remote repository with a message
My company is incorporating iRise for prototyping and it lacks any kind of versioning (unless making copies of your files with different file names = versioning). Anyway, we're using Git for our version control and since the typical iRise user here will be a graphic/we... | You will have to do a commit ( after adding files)
```
git commit -m 'message'
```
and then push:
```
git push TestProject master
```
You cannot associate a message to the push. |
8751497 | Latitude Longitude Coordinates to State Code in R | 24 | 2012-01-05 23:36:14 | <p>Is there a fast way to convert latitude and longitude coordinates to State codes in R? I've been using the zipcode package as a look up table but it's too slow when I'm querying lots of lat/long values</p>
<p>If not in R is there any way to do this using google geocoder or any other type of fast querying service?</... | 37,442 | 851,530 | 2023-06-20 17:53:46 | 8,751,965 | 50 | 2012-01-06 00:39:24 | 980,833 | 2020-06-18 00:50:36 | https://stackoverflow.com/q/8751497 | https://stackoverflow.com/a/8751965 | <p>Here are two options, one using <strong>sf</strong> and one using <strong>sp</strong> package functions. <strong>sf</strong> is the more modern (and, here in 2020, recommended) package for analyzing spatial data, but in case it's still useful, I am leaving my original 2012 answer showing how to do this with <strong>... | <p>Here are two options, one using <strong>sf</strong> and one using <strong>sp</strong> package functions. <strong>sf</strong> is the more modern (and, here in 2020, recommended) package for analyzing spatial data, but in case it's still useful, I am leaving my original 2012 answer showing how to do this with <strong>... | 4452, 20301, 58350 | google-geocoder, latitude-longitude, r | <h1>Latitude Longitude Coordinates to State Code in R</h1>
<p>Is there a fast way to convert latitude and longitude coordinates to State codes in R? I've been using the zipcode package as a look up table but it's too slow when I'm querying lots of lat/long values</p>
<p>If not in R is there any way to do this using go... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,454 | git | # Latitude Longitude Coordinates to State Code in R
Is there a fast way to convert latitude and longitude coordinates to State codes in R? I've been using the zipcode package as a look up table but it's too slow when I'm querying lots of lat/long values
If not in R is there any way to do this using google geocoder or... | Here are two options, one using **sf** and one using **sp** package functions. **sf** is the more modern (and, here in 2020, recommended) package for analyzing spatial data, but in case it's still useful, I am leaving my original 2012 answer showing how to do this with **sp**-related functions.
---
## Method 1 (using... |
32355523 | How to install GitFlow for Windows | 23 | 2015-09-02 14:11:43 | <p>Is there a way to install Git Flow on Windows? I tried <a href="https://github.com/nvie/gitflow/wiki/Windows" rel="noreferrer">this tutorial</a> but I'm unable to understand it.</p>
<p>I already have Git Installed on my PC, can I use GitFlow from my current Git installation?</p>
| 50,418 | 5,279,545 | 2025-12-24 04:21:34 | 32,660,337 | 50 | 2015-09-18 20:16:05 | 1,127,485 | 2016-03-26 07:23:23 | https://stackoverflow.com/q/32355523 | https://stackoverflow.com/a/32660337 | <p>Use the recently released <a href="https://github.com/git-for-windows/git/releases/tag/v2.5.3.windows.1" rel="noreferrer">Git for Windows 2.5.3</a> which now ships with <code>git-flow</code> (the <a href="https://github.com/petervanderdoes/gitflow-avh" rel="noreferrer">AVH edition</a> of it).</p>
| <p>Use the recently released <a href="https://github.com/git-for-windows/git/releases/tag/v2.5.3.windows.1" rel="noreferrer">Git for Windows 2.5.3</a> which now ships with <code>git-flow</code> (the <a href="https://github.com/petervanderdoes/gitflow-avh" rel="noreferrer">AVH edition</a> of it).</p> | 64, 119, 64339 | git, git-flow, windows | <h1>How to install GitFlow for Windows</h1>
<p>Is there a way to install Git Flow on Windows? I tried <a href="https://github.com/nvie/gitflow/wiki/Windows" rel="noreferrer">this tutorial</a> but I'm unable to understand it.</p>
<p>I already have Git Installed on my PC, can I use GitFlow from my current Git installati... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,455 | git | # How to install GitFlow for Windows
Is there a way to install Git Flow on Windows? I tried [this tutorial](https://github.com/nvie/gitflow/wiki/Windows) but I'm unable to understand it.
I already have Git Installed on my PC, can I use GitFlow from my current Git installation? | Use the recently released [Git for Windows 2.5.3](https://github.com/git-for-windows/git/releases/tag/v2.5.3.windows.1) which now ships with `git-flow` (the [AVH edition](https://github.com/petervanderdoes/gitflow-avh) of it). |
6320686 | django-taggit: make the tags not required in the admin | 23 | 2011-06-12 07:18:57 | <p>I've started using django-taggit and it seems to fit the bill. But for me there is still an issue with the admin site: </p>
<p>I included the <code>tags</code> attribute in the ModelAdmin like this:</p>
<pre><code>class MyModel(db.models.Model):
name = models.CharField(max_length=200)
tags = TaggableManag... | 6,189 | 526,169 | 2023-04-13 18:40:55 | 6,321,078 | 50 | 2011-06-12 08:59:54 | 630,877 | 2011-06-12 08:59:54 | https://stackoverflow.com/q/6320686 | https://stackoverflow.com/a/6321078 | <p>Did you try <code>tags = TaggableManager(blank=True)</code>?</p>
<blockquote>
<p>blank – Controls whether this field is
required</p>
</blockquote>
<p>... at least that's what <a href="http://django-taggit.readthedocs.org/en/latest/api.html#TaggableManager">the docs</a> say.</p>
| <p>Did you try <code>tags = TaggableManager(blank=True)</code>?</p> <blockquote> <p>blank – Controls whether this field is required</p> </blockquote> <p>... at least that's what <a href="http://django-taggit.readthedocs.org/en/latest/api.html#TaggableManager">the docs</a> say.</p> | 16, 243, 67475 | django, django-taggit, python | <h1>django-taggit: make the tags not required in the admin</h1>
<p>I've started using django-taggit and it seems to fit the bill. But for me there is still an issue with the admin site: </p>
<p>I included the <code>tags</code> attribute in the ModelAdmin like this:</p>
<pre><code>class MyModel(db.models.Model):
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,456 | git | # django-taggit: make the tags not required in the admin
I've started using django-taggit and it seems to fit the bill. But for me there is still an issue with the admin site:
I included the `tags` attribute in the ModelAdmin like this:
```
class MyModel(db.models.Model):
name = models.CharField(max_length=200)
... | Did you try `tags = TaggableManager(blank=True)`?
> blank – Controls whether this field is
> required
... at least that's what [the docs](http://django-taggit.readthedocs.org/en/latest/api.html#TaggableManager) say. |
28543596 | Git - Commit file in .gitignore | 18 | 2015-02-16 14:26:51 | <p>I want to commit and push two new files that are inside a folder that is listed in the project's .gitignore. I figure I can just change the .gitignore file, but then I would require two commits: one commit to push the two new files, and a second commit to reset the .gitignore. I'd like to do this in one commit if po... | 19,825 | 2,052,564 | 2015-02-16 15:18:20 | 28,543,654 | 50 | 2015-02-16 14:30:32 | 6,309 | 2015-02-16 15:18:20 | https://stackoverflow.com/q/28543596 | https://stackoverflow.com/a/28543654 | <p>You don't have to modify the <code>.gitignore:</code> you can force the addition of those files:</p>
<pre><code>git add --force -- file1 file2
git commit -m "add previously ignored files"
git push
</code></pre>
<p>From <a href="http://git-scm.com/docs/git-add" rel="noreferrer"><code>git add</code> man page</a>:</p... | <p>You don't have to modify the <code>.gitignore:</code> you can force the addition of those files:</p> <pre><code>git add --force -- file1 file2 git commit -m "add previously ignored files" git push </code></pre> <p>From <a href="http://git-scm.com/docs/git-add" rel="noreferrer"><code>git add</code> man page</a>:</p... | 119, 25056, 53850 | git, git-commit, gitignore | <h1>Git - Commit file in .gitignore</h1>
<p>I want to commit and push two new files that are inside a folder that is listed in the project's .gitignore. I figure I can just change the .gitignore file, but then I would require two commits: one commit to push the two new files, and a second commit to reset the .gitignore... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,457 | git | # Git - Commit file in .gitignore
I want to commit and push two new files that are inside a folder that is listed in the project's .gitignore. I figure I can just change the .gitignore file, but then I would require two commits: one commit to push the two new files, and a second commit to reset the .gitignore. I'd lik... | You don't have to modify the `.gitignore:` you can force the addition of those files:
```
git add --force -- file1 file2
git commit -m "add previously ignored files"
git push
```
From [`git add` man page](http://git-scm.com/docs/git-add):
```
-f
--force
```
> Allow adding otherwise ignored files.
As [Jakub Narębsk... |
15908811 | Git on windows : "I don't handle protocol 'git clone http'" | 17 | 2013-04-09 17:42:17 | <p>I'm trying to install git and tortoisegit on a windows 7 machine (a VM inside windows 8's Hyper V).</p>
<p>I followed the instruction, but now when I try to clone something I get the error <em>"I don't handle protocol 'git clone http'"</em></p>
<p>Any clues as to what is going on ?</p>
| 20,816 | 113,305 | 2017-11-09 18:14:31 | 15,908,936 | 50 | 2013-04-09 17:47:40 | 526,535 | 2013-04-09 17:47:40 | https://stackoverflow.com/q/15908811 | https://stackoverflow.com/a/15908936 | <p>You are probably entering the command <code>git clone http://repo/url</code> in the place where it expects only the url, i.e <code>http://repo/url</code></p>
| <p>You are probably entering the command <code>git clone http://repo/url</code> in the place where it expects only the url, i.e <code>http://repo/url</code></p> | 119, 31409, 34595 | git, tortoisegit, windows-7 | <h1>Git on windows : "I don't handle protocol 'git clone http'"</h1>
<p>I'm trying to install git and tortoisegit on a windows 7 machine (a VM inside windows 8's Hyper V).</p>
<p>I followed the instruction, but now when I try to clone something I get the error <em>"I don't handle protocol 'git clone http'"</em></p>
<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,458 | git | # Git on windows : "I don't handle protocol 'git clone http'"
I'm trying to install git and tortoisegit on a windows 7 machine (a VM inside windows 8's Hyper V).
I followed the instruction, but now when I try to clone something I get the error *"I don't handle protocol 'git clone http'"*
Any clues as to what is goin... | You are probably entering the command `git clone http://repo/url` in the place where it expects only the url, i.e `http://repo/url` |
6426247 | Merge git repository in subdirectory | 110 | 2011-06-21 13:41:12 | <p>I'd like to merge a remote git repository in my working git repository as a subdirectory of it. I'd like the resulting repository to contain the merged history of the two repositories and also that each file of the merged-in repository retain its history as it was in the remote repository. I tried using the subtree ... | 45,998 | 375,842 | 2020-12-16 09:05:01 | 6,442,034 | 49 | 2011-06-22 15:01:41 | 719,673 | 2019-05-15 01:56:17 | https://stackoverflow.com/q/6426247 | https://stackoverflow.com/a/6442034 | <p>After getting the fuller explanation of what is going on, I think I understand it and in any case at the bottom I have a workaround. Specifically, I believe what is happening is rename detection is being fooled by the subtree merge with --prefix. Here is my test case:</p>
<pre><code>mkdir -p z/a z/b
cd z/a
git in... | <p>After getting the fuller explanation of what is going on, I think I understand it and in any case at the bottom I have a workaround. Specifically, I believe what is happening is rename detection is being fooled by the subtree merge with --prefix. Here is my test case:</p> <pre><code>mkdir -p z/a z/b cd z/a git in... | 119 | git | <h1>Merge git repository in subdirectory</h1>
<p>I'd like to merge a remote git repository in my working git repository as a subdirectory of it. I'd like the resulting repository to contain the merged history of the two repositories and also that each file of the merged-in repository retain its history as it was in the... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,459 | git | # Merge git repository in subdirectory
I'd like to merge a remote git repository in my working git repository as a subdirectory of it. I'd like the resulting repository to contain the merged history of the two repositories and also that each file of the merged-in repository retain its history as it was in the remote r... | After getting the fuller explanation of what is going on, I think I understand it and in any case at the bottom I have a workaround. Specifically, I believe what is happening is rename detection is being fooled by the subtree merge with --prefix. Here is my test case:
```
mkdir -p z/a z/b
cd z/a
git init
echo A>A
git ... |
14509950 | My diff contains trailing whitespace - how to get rid of it? | 75 | 2013-01-24 20:16:38 | <p>I've tried editing a php file in TextWrangler with line endings set to Unix, in NetBeans, and in vim. When I save the diff to a patch and then try to apply it, it gives whitespace errors. When I type <code>git diff</code> I can see <code>^M</code> at the ends of my lines, but if I manually remove these in vim, it sa... | 151,226 | 1,370,106 | 2025-08-08 07:14:04 | 14,513,670 | 49 | 2013-01-25 01:00:43 | 582 | 2017-01-20 18:49:17 | https://stackoverflow.com/q/14509950 | https://stackoverflow.com/a/14513670 | <p>Are you sure those are hard errors? By default, git will warn about whitespace errors, but will still accept them. If they are hard errors then you must have changed some settings. You can use the <code>--whitespace=</code> flag to <code>git apply</code> to control this on a per-invocation basis. Try</p>
<pre><code... | <p>Are you sure those are hard errors? By default, git will warn about whitespace errors, but will still accept them. If they are hard errors then you must have changed some settings. You can use the <code>--whitespace=</code> flag to <code>git apply</code> to control this on a per-invocation basis. Try</p> <pre><code... | 119, 496, 1084, 2176, 57198 | git, netbeans, removing-whitespace, textwrangler, whitespace | <h1>My diff contains trailing whitespace - how to get rid of it?</h1>
<p>I've tried editing a php file in TextWrangler with line endings set to Unix, in NetBeans, and in vim. When I save the diff to a patch and then try to apply it, it gives whitespace errors. When I type <code>git diff</code> I can see <code>^M</code>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,460 | git | # My diff contains trailing whitespace - how to get rid of it?
I've tried editing a php file in TextWrangler with line endings set to Unix, in NetBeans, and in vim. When I save the diff to a patch and then try to apply it, it gives whitespace errors. When I type `git diff` I can see `^M` at the ends of my lines, but i... | Are you sure those are hard errors? By default, git will warn about whitespace errors, but will still accept them. If they are hard errors then you must have changed some settings. You can use the `--whitespace=` flag to `git apply` to control this on a per-invocation basis. Try
```
git apply --whitespace=warn patchna... |
7714326 | Git submodule URL not including username? | 71 | 2011-10-10 14:33:29 | <p>I have a git repository set up with several submodules, which creates a <code>.gitmodules</code> file that is a tracked file in the parent repository. However, there are other developers wanting to work on this repository, and check out the submodules. But currently the URLs for the remote submodule repositories con... | 69,834 | 144,756 | 2025-06-25 07:20:50 | 7,714,592 | 49 | 2011-10-10 14:51:12 | 223,092 | 2011-10-10 16:25:22 | https://stackoverflow.com/q/7714326 | https://stackoverflow.com/a/7714592 | <p>If I understand correctly, you're using HTTP basic authentication over HTTPS to allow only particular developers to access the repository. In that case, you can commit a <code>.gitmodules</code> that looks like:</p>
<pre><code>[submodule foo]
path = sub/foo
url = https://example.com/git/foo.git
</code></pre>
... | <p>If I understand correctly, you're using HTTP basic authentication over HTTPS to allow only particular developers to access the repository. In that case, you can commit a <code>.gitmodules</code> that looks like:</p> <pre><code>[submodule foo] path = sub/foo url = https://example.com/git/foo.git </code></pre> ... | 119, 41612 | git, git-submodules | <h1>Git submodule URL not including username?</h1>
<p>I have a git repository set up with several submodules, which creates a <code>.gitmodules</code> file that is a tracked file in the parent repository. However, there are other developers wanting to work on this repository, and check out the submodules. But currently... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,461 | git | # Git submodule URL not including username?
I have a git repository set up with several submodules, which creates a `.gitmodules` file that is a tracked file in the parent repository. However, there are other developers wanting to work on this repository, and check out the submodules. But currently the URLs for the re... | If I understand correctly, you're using HTTP basic authentication over HTTPS to allow only particular developers to access the repository. In that case, you can commit a `.gitmodules` that looks like:
```
[submodule foo]
path = sub/foo
url = https://example.com/git/foo.git
```
... i.e. without a user name, and th... |
4075528 | What algorithm does git use to detect changes on your working tree? | 69 | 2010-11-02 06:58:28 | <p>This is about the internals of <code>git</code>.</p>
<p>I've been reading the great <a href="https://git-scm.com/book/en/v2" rel="noreferrer">'Pro Git'</a> book and learning a little about how git is working internally (all about the SHA1, blobs, references, trees, commits, etc, etc). Pretty clever architecture, by... | 22,120 | 205,083 | 2022-02-04 14:25:52 | 4,075,667 | 49 | 2010-11-02 07:25:42 | 19,750 | 2010-11-02 15:32:20 | https://stackoverflow.com/q/4075528 | https://stackoverflow.com/a/4075667 | <p>Git’s index maintains timestamps of when git last wrote each file into the working tree (and updates these whenever files are cached from the working tree or from a commit). You can see the metadata with <code>git ls-files --debug</code>. In addition to the timestamp, it records the size, inode, and other informatio... | <p>Git’s index maintains timestamps of when git last wrote each file into the working tree (and updates these whenever files are cached from the working tree or from a commit). You can see the metadata with <code>git ls-files --debug</code>. In addition to the timestamp, it records the size, inode, and other informatio... | 119 | git | <h1>What algorithm does git use to detect changes on your working tree?</h1>
<p>This is about the internals of <code>git</code>.</p>
<p>I've been reading the great <a href="https://git-scm.com/book/en/v2" rel="noreferrer">'Pro Git'</a> book and learning a little about how git is working internally (all about the SHA1,... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,462 | git | # What algorithm does git use to detect changes on your working tree?
This is about the internals of `git`.
I've been reading the great ['Pro Git'](https://git-scm.com/book/en/v2) book and learning a little about how git is working internally (all about the SHA1, blobs, references, trees, commits, etc, etc). Pretty c... | Git’s index maintains timestamps of when git last wrote each file into the working tree (and updates these whenever files are cached from the working tree or from a commit). You can see the metadata with `git ls-files --debug`. In addition to the timestamp, it records the size, inode, and other information from [lstat]... |
11628074 | How to make GIT ignore my changes | 64 | 2012-07-24 09:37:03 | <p>Although the title seems similar to previous questions, I could not find the solution to to my Simple case:</p>
<ul>
<li>I committed to my branch 'ABCD' : <code>git commit -a .....</code></li>
<li>Then decided to visit a previous commit so : <code>git checkout 2387687326487</code></li>
<li>Here I made some change... | 136,923 | 805,896 | 2021-09-28 23:09:59 | 11,628,209 | 49 | 2012-07-24 09:46:06 | 1,453,719 | 2012-07-24 09:46:06 | https://stackoverflow.com/q/11628074 | https://stackoverflow.com/a/11628209 | <p>If you are sure that you don't want to keep your changes, the following line will do :</p>
<pre><code>git checkout -f 'ABCD'
</code></pre>
<p>Option '-f' stands for force.</p>
| <p>If you are sure that you don't want to keep your changes, the following line will do :</p> <pre><code>git checkout -f 'ABCD' </code></pre> <p>Option '-f' stands for force.</p> | 119 | git | <h1>How to make GIT ignore my changes</h1>
<p>Although the title seems similar to previous questions, I could not find the solution to to my Simple case:</p>
<ul>
<li>I committed to my branch 'ABCD' : <code>git commit -a .....</code></li>
<li>Then decided to visit a previous commit so : <code>git checkout 2387687326... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,463 | git | # How to make GIT ignore my changes
Although the title seems similar to previous questions, I could not find the solution to to my Simple case:
- I committed to my branch 'ABCD' : `git commit -a .....`
- Then decided to visit a previous commit so : `git checkout 2387687326487`
- Here I made some changes which was for... | If you are sure that you don't want to keep your changes, the following line will do :
```
git checkout -f 'ABCD'
```
Option '-f' stands for force. |
24852116 | What exactly is a merge conflict? | 63 | 2014-07-20 15:40:48 | <p>I have made a git repository and added a text file to it. This is 100% for learning purpose. </p>
<ol>
<li><p>I added "1" to the text file and committed it to master. </p></li>
<li><p>Created a new branch from master and appended "2". </p></li>
<li><p>Finally, created a branch from master and appended "3". </p></li... | 42,295 | 3,693,167 | 2022-07-24 16:10:53 | 24,852,167 | 49 | 2014-07-20 15:45:41 | 6,309 | 2022-07-24 16:10:53 | https://stackoverflow.com/q/24852116 | https://stackoverflow.com/a/24852167 | <p>You will have a conflict if you merge:</p>
<ul>
<li><code>branch2</code> to <code>master</code> (no conflict)</li>
<li><code>branch3</code> to <code>master</code> (conflict):</li>
</ul>
<p>That is because:</p>
<ul>
<li>The common ancestor would be <code>master</code> (with a second line empty)</li>
<li>the source co... | <p>You will have a conflict if you merge:</p> <ul> <li><code>branch2</code> to <code>master</code> (no conflict)</li> <li><code>branch3</code> to <code>master</code> (conflict):</li> </ul> <p>That is because:</p> <ul> <li>The common ancestor would be <code>master</code> (with a second line empty)</li> <li>the source co... | 119, 28897 | git, git-merge | <h1>What exactly is a merge conflict?</h1>
<p>I have made a git repository and added a text file to it. This is 100% for learning purpose. </p>
<ol>
<li><p>I added "1" to the text file and committed it to master. </p></li>
<li><p>Created a new branch from master and appended "2". </p></li>
<li><p>Finally, created a br... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,464 | git | # What exactly is a merge conflict?
I have made a git repository and added a text file to it. This is 100% for learning purpose.
1. I added "1" to the text file and committed it to master.
2. Created a new branch from master and appended "2".
3. Finally, created a branch from master and appended "3".
Could you pleas... | You will have a conflict if you merge:
- `branch2` to `master` (no conflict)
- `branch3` to `master` (conflict):
That is because:
- The common ancestor would be `master` (with a second line empty)
- the source content is `branch3` (with a second line including "3")
- the destination content is on latest of `master` ... |
8824863 | Show full Git commit message in console without having to resize the window | 61 | 2012-01-11 18:45:54 | <p>I'm trying to output the full commit message in the console and I am able to get the message, however in order to see the full message I have to keep resizing the console window in order to reveal more. I am on Windows using Cygwin.</p>
<p>The command I'm using is <code>git log --pretty=full</code>.</p>
| 57,738 | 2,332,633 | 2024-09-16 15:31:23 | 8,824,935 | 49 | 2012-01-11 18:51:03 | 85,371 | 2012-01-11 22:18:30 | https://stackoverflow.com/q/8824863 | https://stackoverflow.com/a/8824935 | <p>pagers to the rescue </p>
<pre><code>git log | less
</code></pre>
<p>Make sure you don't have -S on an alias for less</p>
<p>Also, it is generally considered good practice to limit the width for commit messages. I believe a common standard is 78 chars (IIRC), and most texteditors do a good job of ensuring such st... | <p>pagers to the rescue </p> <pre><code>git log | less </code></pre> <p>Make sure you don't have -S on an alias for less</p> <p>Also, it is generally considered good practice to limit the width for commit messages. I believe a common standard is 78 chars (IIRC), and most texteditors do a good job of ensuring such st... | 119, 391, 47913 | git, git-log, terminal | <h1>Show full Git commit message in console without having to resize the window</h1>
<p>I'm trying to output the full commit message in the console and I am able to get the message, however in order to see the full message I have to keep resizing the console window in order to reveal more. I am on Windows using Cygwin.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,466 | git | # Show full Git commit message in console without having to resize the window
I'm trying to output the full commit message in the console and I am able to get the message, however in order to see the full message I have to keep resizing the console window in order to reveal more. I am on Windows using Cygwin.
The com... | pagers to the rescue
```
git log | less
```
Make sure you don't have -S on an alias for less
Also, it is generally considered good practice to limit the width for commit messages. I believe a common standard is 78 chars (IIRC), and most texteditors do a good job of ensuring such style rules (auto formatting your mes... |
21705323 | Undoing a git rebase --skip - reapply a commit during a rebase | 57 | 2014-02-11 14:58:18 | <p>I'm doing a long <code>git rebase</code> with a lot of commits. I accidentally <code>--skipped</code> a commit where there were some conflicts which I resolved. I should have done <code>git rebase --continue</code>.</p>
<p>Is there are way to re-apply this previous commit during this rebase phase and then continue ... | 22,947 | 880,584 | 2023-10-10 05:58:36 | 21,707,128 | 49 | 2014-02-11 16:14:40 | 880,584 | 2018-06-07 15:28:48 | https://stackoverflow.com/q/21705323 | https://stackoverflow.com/a/21707128 | <p>I found a way which "worked for me":</p>
<p>During a rebase lots of things are happening in the <code>.git/rebase-apply</code> directory. Amongst others there is a file called <code>next</code>. <code>next</code> is containing a number which corresponds to a file which is residing in the <code>.git/rebase-apply</co... | <p>I found a way which "worked for me":</p> <p>During a rebase lots of things are happening in the <code>.git/rebase-apply</code> directory. Amongst others there is a file called <code>next</code>. <code>next</code> is containing a number which corresponds to a file which is residing in the <code>.git/rebase-apply</co... | 119, 29934 | git, git-rebase | <h1>Undoing a git rebase --skip - reapply a commit during a rebase</h1>
<p>I'm doing a long <code>git rebase</code> with a lot of commits. I accidentally <code>--skipped</code> a commit where there were some conflicts which I resolved. I should have done <code>git rebase --continue</code>.</p>
<p>Is there are way to r... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,467 | git | # Undoing a git rebase --skip - reapply a commit during a rebase
I'm doing a long `git rebase` with a lot of commits. I accidentally `--skipped` a commit where there were some conflicts which I resolved. I should have done `git rebase --continue`.
Is there are way to re-apply this previous commit during this rebase p... | I found a way which "worked for me":
During a rebase lots of things are happening in the `.git/rebase-apply` directory. Amongst others there is a file called `next`. `next` is containing a number which corresponds to a file which is residing in the `.git/rebase-apply` as well. This file contains information about the ... |
11410017 | Git Submodule update over https | 57 | 2012-07-10 09:07:01 | <p>I am sitting on a proxy which only allows http/https traffic only, I am able to clone a repository from Github, but I have to fetch/push using the https URL and username/password. </p>
<p>Now my issues is a repository with submodules, when I execute <code>git submodule update</code> it times out, and I can only ass... | 50,786 | 509,663 | 2023-02-26 16:18:27 | 11,410,074 | 49 | 2012-07-10 09:09:55 | 415,313 | 2012-07-10 09:16:57 | https://stackoverflow.com/q/11410017 | https://stackoverflow.com/a/11410074 | <p>In your <code>.gitmodules</code> file in the root of your repo, and in the <code>.git/config</code> file, you should find a section for your submodule. You can edit the url there so it is accessed via https request rather ssh.</p>
<p>Of course it may already be an ssh url, in which case the problem may be something... | <p>In your <code>.gitmodules</code> file in the root of your repo, and in the <code>.git/config</code> file, you should find a section for your submodule. You can edit the url there so it is accessed via https request rather ssh.</p> <p>Of course it may already be an ssh url, in which case the problem may be something... | 119, 760, 41612 | git, git-submodules, proxy | <h1>Git Submodule update over https</h1>
<p>I am sitting on a proxy which only allows http/https traffic only, I am able to clone a repository from Github, but I have to fetch/push using the https URL and username/password. </p>
<p>Now my issues is a repository with submodules, when I execute <code>git submodule updat... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,468 | git | # Git Submodule update over https
I am sitting on a proxy which only allows http/https traffic only, I am able to clone a repository from Github, but I have to fetch/push using the https URL and username/password.
Now my issues is a repository with submodules, when I execute `git submodule update` it times out, and I... | In your `.gitmodules` file in the root of your repo, and in the `.git/config` file, you should find a section for your submodule. You can edit the url there so it is accessed via https request rather ssh.
Of course it may already be an ssh url, in which case the problem may be something else, but this is the first pla... |
24329051 | What does git add --intent-to-add or -N do and when should it be used? | 49 | 2014-06-20 13:59:18 | <p>On <code>git add -h</code> I can see the following option:</p>
<pre><code>-N, --intent-to-add record only the fact that the path will be added later
</code></pre>
<p>But I don't understand when should this option be used. What does this option really do, and how it should be used?</p>
| 11,967 | 413,494 | 2018-03-04 18:58:07 | 24,347,875 | 49 | 2014-06-22 03:27:59 | null | 2014-06-22 05:51:54 | https://stackoverflow.com/q/24329051 | https://stackoverflow.com/a/24347875 | <h2>Enable diffing of untracked files</h2>
<p><a href="https://stackoverflow.com/a/24329124/456814">Blue112's answer</a> is <em>partially</em> correct. <code>git add --intent-to-add</code> does indeed add an empty file to the staging area/index for each specified untracked file in your working copy, <strong>but one of... | <h2>Enable diffing of untracked files</h2> <p><a href="https://stackoverflow.com/a/24329124/456814">Blue112's answer</a> is <em>partially</em> correct. <code>git add --intent-to-add</code> does indeed add an empty file to the staging area/index for each specified untracked file in your working copy, <strong>but one of... | 119 | git | <h1>What does git add --intent-to-add or -N do and when should it be used?</h1>
<p>On <code>git add -h</code> I can see the following option:</p>
<pre><code>-N, --intent-to-add record only the fact that the path will be added later
</code></pre>
<p>But I don't understand when should this option be used. What does t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,469 | git | # What does git add --intent-to-add or -N do and when should it be used?
On `git add -h` I can see the following option:
```
-N, --intent-to-add record only the fact that the path will be added later
```
But I don't understand when should this option be used. What does this option really do, and how it should be u... | ## Enable diffing of untracked files
[Blue112's answer](https://stackoverflow.com/a/24329124/456814) is *partially* correct. `git add --intent-to-add` does indeed add an empty file to the staging area/index for each specified untracked file in your working copy, **but one of the main purposes of this is to enable you ... |
1440181 | How do I backport a commit in git? | 49 | 2009-09-17 17:18:13 | <p>So, I have a maintenance branch and a master branch in my project. If I make a commit in the maintenance branch and want to merge it forward to the master branch, that's easy:</p>
<pre><code>git checkout master; git merge maintenance
</code></pre>
<p>But if I want to go the other way around, i.e. apply a commit ma... | 38,141 | 3,757 | 2016-07-06 08:17:00 | 1,440,192 | 49 | 2009-09-17 17:21:37 | 53,354 | 2009-09-17 17:21:37 | https://stackoverflow.com/q/1440181 | https://stackoverflow.com/a/1440192 | <p>This is exactly the use case for <a href="http://www.kernel.org/pub/software/scm/git/docs/git-cherry-pick.html" rel="noreferrer">git-cherry-pick</a></p>
<pre><code>git checkout maintenance
git cherry-pick <commit from master>
</code></pre>
| <p>This is exactly the use case for <a href="http://www.kernel.org/pub/software/scm/git/docs/git-cherry-pick.html" rel="noreferrer">git-cherry-pick</a></p> <pre><code>git checkout maintenance git cherry-pick <commit from master> </code></pre> | 119 | git | <h1>How do I backport a commit in git?</h1>
<p>So, I have a maintenance branch and a master branch in my project. If I make a commit in the maintenance branch and want to merge it forward to the master branch, that's easy:</p>
<pre><code>git checkout master; git merge maintenance
</code></pre>
<p>But if I want to go ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,470 | git | # How do I backport a commit in git?
So, I have a maintenance branch and a master branch in my project. If I make a commit in the maintenance branch and want to merge it forward to the master branch, that's easy:
```
git checkout master; git merge maintenance
```
But if I want to go the other way around, i.e. apply ... | This is exactly the use case for [git-cherry-pick](http://www.kernel.org/pub/software/scm/git/docs/git-cherry-pick.html)
```
git checkout maintenance
git cherry-pick <commit from master>
``` |
8855880 | Where is the local repository located? | 47 | 2012-01-13 19:10:38 | <p>From <a href="https://commons.wikimedia.org/wiki/File:Git_data_flow_simplified.svg">Wikipedia</a>:</p>
<p><img src="https://i.sstatic.net/r6NBW.png" alt="enter image description here"></p>
<p>Where is said "Local repository" located <strong>physically</strong> (in the file system)?</p>
| 93,822 | 586,707 | 2020-06-27 14:08:14 | 8,855,906 | 49 | 2012-01-13 19:12:21 | 893 | 2012-01-13 19:12:21 | https://stackoverflow.com/q/8855880 | https://stackoverflow.com/a/8855906 | <p>The Working Directory is wherever your files are on your local machine. The Local Repository is the <code>.git/</code> subdirectory inside the Working Directory. The Index is a conceptual place that also physically resides in the <code>.git/</code> subdirectory.</p>
| <p>The Working Directory is wherever your files are on your local machine. The Local Repository is the <code>.git/</code> subdirectory inside the Working Directory. The Index is a conceptual place that also physically resides in the <code>.git/</code> subdirectory.</p> | 119 | git | <h1>Where is the local repository located?</h1>
<p>From <a href="https://commons.wikimedia.org/wiki/File:Git_data_flow_simplified.svg">Wikipedia</a>:</p>
<p><img src="https://i.sstatic.net/r6NBW.png" alt="enter image description here"></p>
<p>Where is said "Local repository" located <strong>physically</strong> (in th... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,472 | git | # Where is the local repository located?
From [Wikipedia](https://commons.wikimedia.org/wiki/File:Git_data_flow_simplified.svg):

Where is said "Local repository" located **physically** (in the file system)? | The Working Directory is wherever your files are on your local machine. The Local Repository is the `.git/` subdirectory inside the Working Directory. The Index is a conceptual place that also physically resides in the `.git/` subdirectory. |
15507264 | Can I specify in .git/config to fetch multiple refspecs? | 45 | 2013-03-19 18:10:26 | <p>I do not want to fetch every branch from origin because there are many. I just want to track a few (e.g., <code>master</code>) and my branches (organized under <code>my_name</code> sub-directory). I can do the following:</p>
<pre><code>$ git fetch origin refs/heads/my_name/*:refs/remotes/origin/my_name/* refs/heads... | 24,027 | 716,468 | 2020-05-16 22:36:17 | 15,508,750 | 49 | 2013-03-19 19:31:20 | 380,757 | 2015-09-06 11:20:57 | https://stackoverflow.com/q/15507264 | https://stackoverflow.com/a/15508750 | <p>You can add the following lines in your <code>.git/config</code> to specify multiple refspecs for fetch:</p>
<pre><code>[remote "origin"]
fetch = refs/heads/my_name/*:refs/remotes/origin/my_name/*
fetch = refs/heads/master:refs/remotes/origin/master
fetch = refs/heads/some_branch:refs/remotes/o... | <p>You can add the following lines in your <code>.git/config</code> to specify multiple refspecs for fetch:</p> <pre><code>[remote "origin"] fetch = refs/heads/my_name/*:refs/remotes/origin/my_name/* fetch = refs/heads/master:refs/remotes/origin/master fetch = refs/heads/some_branch:refs/remotes/o... | 119 | git | <h1>Can I specify in .git/config to fetch multiple refspecs?</h1>
<p>I do not want to fetch every branch from origin because there are many. I just want to track a few (e.g., <code>master</code>) and my branches (organized under <code>my_name</code> sub-directory). I can do the following:</p>
<pre><code>$ git fetch or... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,473 | git | # Can I specify in .git/config to fetch multiple refspecs?
I do not want to fetch every branch from origin because there are many. I just want to track a few (e.g., `master`) and my branches (organized under `my_name` sub-directory). I can do the following:
```
$ git fetch origin refs/heads/my_name/*:refs/remotes/ori... | You can add the following lines in your `.git/config` to specify multiple refspecs for fetch:
```
[remote "origin"]
fetch = refs/heads/my_name/*:refs/remotes/origin/my_name/*
fetch = refs/heads/master:refs/remotes/origin/master
fetch = refs/heads/some_branch:refs/remotes/origin/some_branch
```
Yo... |
2096509 | git recover single file that was deleted during a merge | 44 | 2010-01-19 19:42:09 | <p>I'm currently in branch 'foo'. I just ran <code>git merge master</code>. Only problem is there was a certain file in foo that I wanted to keep. Is there a way to get it back but keep all the other changes from merge master?</p>
| 18,142 | 202,875 | 2013-11-28 07:57:40 | 2,096,577 | 49 | 2010-01-19 19:52:22 | 95,509 | 2012-12-03 02:16:42 | https://stackoverflow.com/q/2096509 | https://stackoverflow.com/a/2096577 | <p>Try something like this:</p>
<pre><code>git checkout HEAD -- filename
</code></pre>
<p>This will roll your fileback one commit. If you want to go back further to a specific commit, you can use a commit hash or append ^N to the end of the HEAD keyword, e.g. <code>HEAD^2</code>.</p>
| <p>Try something like this:</p> <pre><code>git checkout HEAD -- filename </code></pre> <p>This will roll your fileback one commit. If you want to go back further to a specific commit, you can use a commit hash or append ^N to the end of the HEAD keyword, e.g. <code>HEAD^2</code>.</p> | 119, 1879, 7330 | branch, git, repository | <h1>git recover single file that was deleted during a merge</h1>
<p>I'm currently in branch 'foo'. I just ran <code>git merge master</code>. Only problem is there was a certain file in foo that I wanted to keep. Is there a way to get it back but keep all the other changes from merge master?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,474 | git | # git recover single file that was deleted during a merge
I'm currently in branch 'foo'. I just ran `git merge master`. Only problem is there was a certain file in foo that I wanted to keep. Is there a way to get it back but keep all the other changes from merge master? | Try something like this:
```
git checkout HEAD -- filename
```
This will roll your fileback one commit. If you want to go back further to a specific commit, you can use a commit hash or append ^N to the end of the HEAD keyword, e.g. `HEAD^2`. |
4262150 | Is it possible to git grep for tabs? | 43 | 2010-11-23 23:35:35 | <p><a href="https://stackoverflow.com/questions/1825552/grep-a-tab-in-unix">This question</a> specifies that <code>-P</code> allows GNU grep to grep for a tab</p>
<pre><code>grep -P '\t' config/file.txt
</code></pre>
<p>However, using <code>git grep</code>, I can't work out how to grep for a tab:</p>
<pre><code>git ... | 4,803 | 38,765 | 2018-10-15 20:01:53 | 4,262,207 | 49 | 2010-11-23 23:44:48 | 119,963 | 2010-11-23 23:44:48 | https://stackoverflow.com/q/4262150 | https://stackoverflow.com/a/4262207 | <p>You can work around this by typing a literal tab into your command:</p>
<pre><code># type it with ^V then tab
git grep ' '
</code></pre>
| <p>You can work around this by typing a literal tab into your command:</p> <pre><code># type it with ^V then tab git grep ' ' </code></pre> | 119, 1271 | git, grep | <h1>Is it possible to git grep for tabs?</h1>
<p><a href="https://stackoverflow.com/questions/1825552/grep-a-tab-in-unix">This question</a> specifies that <code>-P</code> allows GNU grep to grep for a tab</p>
<pre><code>grep -P '\t' config/file.txt
</code></pre>
<p>However, using <code>git grep</code>, I can't work o... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,475 | git | # Is it possible to git grep for tabs?
[This question](https://stackoverflow.com/questions/1825552/grep-a-tab-in-unix) specifies that `-P` allows GNU grep to grep for a tab
```
grep -P '\t' config/file.txt
```
However, using `git grep`, I can't work out how to grep for a tab:
```
git grep '\t' # Looks for files wit... | You can work around this by typing a literal tab into your command:
```
# type it with ^V then tab
git grep ' '
``` |
53900839 | git repo gives contradictory info from WSL than from Windows | 41 | 2018-12-23 02:47:15 | <p>When I run <code>git status</code> on a git repository through WSL (Windows Subsystem for Linux) that's on the Window's directory (<code>/mnt/c/Users/....</code>), I get that every file in the directory has been modified. Each modification is just delete and re-write of the original file. See below:
<a href="https:/... | 16,926 | 7,564,988 | 2024-08-27 23:56:08 | 53,900,940 | 49 | 2018-12-23 03:13:58 | 4,991,468 | 2021-11-03 07:27:43 | https://stackoverflow.com/q/53900839 | https://stackoverflow.com/a/53900940 | <p>The two git installations (native windows and WSL) are using a different setting for the <code>core.autocrlf</code> configuration, because these two installations are not using the same global config file.</p>
<p>Put simply, the native windows client is converting LF to CRLF upon checkout, and hence the presence of ... | <p>The two git installations (native windows and WSL) are using a different setting for the <code>core.autocrlf</code> configuration, because these two installations are not using the same global config file.</p> <p>Put simply, the native windows client is converting LF to CRLF upon checkout, and hence the presence of ... | 119, 119526 | git, windows-subsystem-for-linux | <h1>git repo gives contradictory info from WSL than from Windows</h1>
<p>When I run <code>git status</code> on a git repository through WSL (Windows Subsystem for Linux) that's on the Window's directory (<code>/mnt/c/Users/....</code>), I get that every file in the directory has been modified. Each modification is just... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,476 | git | # git repo gives contradictory info from WSL than from Windows
When I run `git status` on a git repository through WSL (Windows Subsystem for Linux) that's on the Window's directory (`/mnt/c/Users/....`), I get that every file in the directory has been modified. Each modification is just delete and re-write of the ori... | The two git installations (native windows and WSL) are using a different setting for the `core.autocrlf` configuration, because these two installations are not using the same global config file.
Put simply, the native windows client is converting LF to CRLF upon checkout, and hence the presence of CRLF is not "seen" a... |
18860696 | Syntax for Git aliases with multiple commands | 41 | 2013-09-17 22:06:31 | <p>I want to create a Git alias to perform multiple commands, but I cant find documentation on how this is done.</p>
<ol>
<li>What is the syntax for Git aliases with multiple commands? </li>
<li>Where is this documented?</li>
</ol>
<p><strong><em>From 'man git-config'</em></strong></p>
<blockquote>
<pre><code> ali... | 19,532 | 444,639 | 2025-02-18 10:56:10 | 18,860,775 | 49 | 2013-09-17 22:14:00 | 85,371 | 2017-01-11 14:16:02 | https://stackoverflow.com/q/18860696 | https://stackoverflow.com/a/18860775 | <pre><code>$ git config alias.q '!echo a; echo b'
$ git q
</code></pre>
<p>Output:</p>
<pre><code>a
b
</code></pre>
<p>I think this is (rudimentarily) documented in <code>man git-config</code> under <code>alias.*</code></p>
<p>Note that git commands should include git, unlike in normal aliases. It is caused by fac... | <pre><code>$ git config alias.q '!echo a; echo b' $ git q </code></pre> <p>Output:</p> <pre><code>a b </code></pre> <p>I think this is (rudimentarily) documented in <code>man git-config</code> under <code>alias.*</code></p> <p>Note that git commands should include git, unlike in normal aliases. It is caused by fac... | 119 | git | <h1>Syntax for Git aliases with multiple commands</h1>
<p>I want to create a Git alias to perform multiple commands, but I cant find documentation on how this is done.</p>
<ol>
<li>What is the syntax for Git aliases with multiple commands? </li>
<li>Where is this documented?</li>
</ol>
<p><strong><em>From 'man git-co... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,477 | git | # Syntax for Git aliases with multiple commands
I want to create a Git alias to perform multiple commands, but I cant find documentation on how this is done.
1. What is the syntax for Git aliases with multiple commands?
2. Where is this documented?
***From 'man git-config'***
> ```
> alias.*
> ```
>
> Command al... | ```
$ git config alias.q '!echo a; echo b'
$ git q
```
Output:
```
a
b
```
I think this is (rudimentarily) documented in `man git-config` under `alias.*`
Note that git commands should include git, unlike in normal aliases. It is caused by fact that it is treated as a shell command, not as a git command (see manpag... |
9841433 | git fetch doesn't update my local repository | 41 | 2012-03-23 14:57:46 | <p>What I want:</p>
<p><strong>Update all new commits from server with my local repository in all branches but do not merge any branch (just join the history lines).</strong></p>
<p>I am trying this command:</p>
<pre><code>git fetch --force --progress --verbose name@host:/path/to/repository.git
</code></pre>
<p>I thou... | 110,153 | 632,472 | 2025-02-20 01:16:31 | 9,841,468 | 49 | 2012-03-23 15:00:04 | 1,257,977 | 2012-03-23 15:00:04 | https://stackoverflow.com/q/9841433 | https://stackoverflow.com/a/9841468 | <p>When you fetch you get the remote branches, but you still need to merge the changes from the remote branch into your local branch to see those changes.</p>
<p>After fetching, try this:</p>
<pre><code>git log origin/yourbranchname | head
git log yourbranchname | head
</code></pre>
<p>Do you see the difference?</p>... | <p>When you fetch you get the remote branches, but you still need to merge the changes from the remote branch into your local branch to see those changes.</p> <p>After fetching, try this:</p> <pre><code>git log origin/yourbranchname | head git log yourbranchname | head </code></pre> <p>Do you see the difference?</p>... | 119, 33720 | git, git-fetch | <h1>git fetch doesn't update my local repository</h1>
<p>What I want:</p>
<p><strong>Update all new commits from server with my local repository in all branches but do not merge any branch (just join the history lines).</strong></p>
<p>I am trying this command:</p>
<pre><code>git fetch --force --progress --verbose name... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,478 | git | # git fetch doesn't update my local repository
What I want:
**Update all new commits from server with my local repository in all branches but do not merge any branch (just join the history lines).**
I am trying this command:
```
git fetch --force --progress --verbose name@host:/path/to/repository.git
```
I thought... | When you fetch you get the remote branches, but you still need to merge the changes from the remote branch into your local branch to see those changes.
After fetching, try this:
```
git log origin/yourbranchname | head
git log yourbranchname | head
```
Do you see the difference?
Now do:
```
git checkout origin/you... |
21105315 | Git: Move head one commit ahead | 38 | 2014-01-14 02:59:28 | <p>I did a <code>git reset HEAD~1</code> to go back one commit. I did this a number of times.</p>
<p>I now want to go back to where <code>HEAD</code> was originally but am not sure how to move my <code>HEAD</code> forward. </p>
<p>Does anyone know what command I need to use?</p>
<p>1-2-3-4-5-6</p>
<p>Originally I w... | 34,064 | 2,020,869 | 2014-09-24 05:46:38 | 21,105,355 | 49 | 2014-01-14 03:03:25 | 3,159,253 | 2014-01-14 03:03:25 | https://stackoverflow.com/q/21105315 | https://stackoverflow.com/a/21105355 | <p>use <code>git reflog</code> to see SHA-1 of last operations and then do <code>git reset --hard <sha1></code>.</p>
<p>Git keeps objects (and their SHA-1 respectively) even they go "out of scope" until next <code>git gc</code> invocation. So if you think, you've lost something in the project history, use <code>... | <p>use <code>git reflog</code> to see SHA-1 of last operations and then do <code>git reset --hard <sha1></code>.</p> <p>Git keeps objects (and their SHA-1 respectively) even they go "out of scope" until next <code>git gc</code> invocation. So if you think, you've lost something in the project history, use <code>... | 119 | git | <h1>Git: Move head one commit ahead</h1>
<p>I did a <code>git reset HEAD~1</code> to go back one commit. I did this a number of times.</p>
<p>I now want to go back to where <code>HEAD</code> was originally but am not sure how to move my <code>HEAD</code> forward. </p>
<p>Does anyone know what command I need to use?</... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,481 | git | # Git: Move head one commit ahead
I did a `git reset HEAD~1` to go back one commit. I did this a number of times.
I now want to go back to where `HEAD` was originally but am not sure how to move my `HEAD` forward.
Does anyone know what command I need to use?
1-2-3-4-5-6
Originally I was at 6 and I reset back to 3.... | use `git reflog` to see SHA-1 of last operations and then do `git reset --hard <sha1>`.
Git keeps objects (and their SHA-1 respectively) even they go "out of scope" until next `git gc` invocation. So if you think, you've lost something in the project history, use `git reflog` to see if that smth is there. |
16452415 | How to find a url for a local GIT repo | 38 | 2013-05-09 00:27:53 | <p>In our Development environment, I can see that the GIT repository was cloned from TEST,</p>
<p>In the config file, </p>
<pre><code>[remote "origin"]
url = //foo/test-foo-project
fetch = +refs/heads/master:refs/remotes/origin/master
</code></pre>
<p>I now want to pull the repository in Development, to my loc... | 78,485 | 183,424 | 2020-03-12 06:54:03 | 16,452,730 | 49 | 2013-05-09 01:07:22 | 1,218,809 | 2013-05-09 01:07:22 | https://stackoverflow.com/q/16452415 | https://stackoverflow.com/a/16452730 | <p>Git command that could get you the <code>url</code> from <code>origin</code></p>
<blockquote>
<p>$git config --get remote.origin.url</p>
</blockquote>
<p>But you would not be able to set a new path</p>
<blockquote>
<p>$git config remote.origin.url "newPath"</p>
</blockquote>
<p>This would fail with the messa... | <p>Git command that could get you the <code>url</code> from <code>origin</code></p> <blockquote> <p>$git config --get remote.origin.url</p> </blockquote> <p>But you would not be able to set a new path</p> <blockquote> <p>$git config remote.origin.url "newPath"</p> </blockquote> <p>This would fail with the messa... | 119 | git | <h1>How to find a url for a local GIT repo</h1>
<p>In our Development environment, I can see that the GIT repository was cloned from TEST,</p>
<p>In the config file, </p>
<pre><code>[remote "origin"]
url = //foo/test-foo-project
fetch = +refs/heads/master:refs/remotes/origin/master
</code></pre>
<p>I now want ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,482 | git | # How to find a url for a local GIT repo
In our Development environment, I can see that the GIT repository was cloned from TEST,
In the config file,
```
[remote "origin"]
url = //foo/test-foo-project
fetch = +refs/heads/master:refs/remotes/origin/master
```
I now want to pull the repository in Development, to... | Git command that could get you the `url` from `origin`
> $git config --get remote.origin.url
But you would not be able to set a new path
> $git config remote.origin.url "newPath"
This would fail with the message error: `could not lock config file ./config: File exists` |
43569757 | How to use USB drive as remote | 34 | 2017-04-23 10:07:36 | <p>I have local copies of a GitHub repo on Laptop and Desktop. The Desktop is ahead of the Laptop and the remote GitHub <code>origin</code>. I want to pull changes onto the Laptop, but don't want to push to the public <code>origin</code>. How do I set up a USB stick/external HDD as a remote?</p>
| 24,833 | 3,217,306 | 2017-08-18 17:54:30 | 43,569,840 | 49 | 2017-04-23 10:16:12 | 3,217,306 | 2017-08-18 17:54:30 | https://stackoverflow.com/q/43569757 | https://stackoverflow.com/a/43569840 | <p>Plug the USB drive into Desktop, and assuming it's showing up as <code>J:</code></p>
<ol>
<li><p>Initialise a bare repo that will act as the remote:</p>
<pre><code>git init --bare J:\repo_name
</code></pre></li>
<li><p><code>cd</code> to the local repo and:</p>
<pre><code>git remote add usb J:\repo_name
git check... | <p>Plug the USB drive into Desktop, and assuming it's showing up as <code>J:</code></p> <ol> <li><p>Initialise a bare repo that will act as the remote:</p> <pre><code>git init --bare J:\repo_name </code></pre></li> <li><p><code>cd</code> to the local repo and:</p> <pre><code>git remote add usb J:\repo_name git check... | 119, 7084 | git, usb-drive | <h1>How to use USB drive as remote</h1>
<p>I have local copies of a GitHub repo on Laptop and Desktop. The Desktop is ahead of the Laptop and the remote GitHub <code>origin</code>. I want to pull changes onto the Laptop, but don't want to push to the public <code>origin</code>. How do I set up a USB stick/external HDD ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,484 | git | # How to use USB drive as remote
I have local copies of a GitHub repo on Laptop and Desktop. The Desktop is ahead of the Laptop and the remote GitHub `origin`. I want to pull changes onto the Laptop, but don't want to push to the public `origin`. How do I set up a USB stick/external HDD as a remote? | Plug the USB drive into Desktop, and assuming it's showing up as `J:`
1. Initialise a bare repo that will act as the remote:
```
git init --bare J:\repo_name
```
2. `cd` to the local repo and:
```
git remote add usb J:\repo_name
git checkout master
git push usb master
```
The `master` branch... |
8265493 | Replace remote git repo (Heroku) | 34 | 2011-11-25 06:30:39 | <p>i'm new to git and heroku.</p>
<p>I've created an app on heroku, pushed some files to the repo.</p>
<p>Now I want fully replace this app's repo with new content from another folder (and have a .git repo in that folder). What is the right way to do this?</p>
| 10,412 | 733,596 | 2011-11-25 06:47:31 | 8,265,606 | 49 | 2011-11-25 06:47:31 | 6,309 | 2011-11-25 06:47:31 | https://stackoverflow.com/q/8265493 | https://stackoverflow.com/a/8265606 | <p>If you want to completely replace the history of the commits you already pushed by the history of that new second repo, all you should need to do would be:</p>
<pre><code>git remote show heroku in the first repo
cd /path/to/seconf/git/repo
git remote add heroku <heroku_repo_address_from_previous_command>
# fo... | <p>If you want to completely replace the history of the commits you already pushed by the history of that new second repo, all you should need to do would be:</p> <pre><code>git remote show heroku in the first repo cd /path/to/seconf/git/repo git remote add heroku <heroku_repo_address_from_previous_command> # fo... | 119, 8279 | git, heroku | <h1>Replace remote git repo (Heroku)</h1>
<p>i'm new to git and heroku.</p>
<p>I've created an app on heroku, pushed some files to the repo.</p>
<p>Now I want fully replace this app's repo with new content from another folder (and have a .git repo in that folder). What is the right way to do this?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,485 | git | # Replace remote git repo (Heroku)
i'm new to git and heroku.
I've created an app on heroku, pushed some files to the repo.
Now I want fully replace this app's repo with new content from another folder (and have a .git repo in that folder). What is the right way to do this? | If you want to completely replace the history of the commits you already pushed by the history of that new second repo, all you should need to do would be:
```
git remote show heroku in the first repo
cd /path/to/seconf/git/repo
git remote add heroku <heroku_repo_address_from_previous_command>
# for instance: git remo... |
2807899 | What is the effect of git commit without the -a option? | 33 | 2010-05-11 03:28:07 | <p>What is the difference between these two commands?</p>
<pre><code>git commit -m "added a new page"
</code></pre>
<p>and</p>
<pre><code>git commit -a -m "added a new page"
</code></pre>
<p>I know that the -a option will stage files that have been modified and deleted, but then what does running it without the -a ... | 15,646 | 173,634 | 2017-08-02 16:42:21 | 2,807,902 | 49 | 2010-05-11 03:31:15 | 102,371 | 2017-08-02 16:42:21 | https://stackoverflow.com/q/2807899 | https://stackoverflow.com/a/2807902 | <p>You have to explicitly stage changes for commitment by using <code>git add</code> or <code>git rm</code>.</p>
<p>If you use the <code>-a</code> flag when doing a commit, git will automatically stage any modified and removed files without you having to explicitly stage them using <code>add</code> or <code>rm</code>,... | <p>You have to explicitly stage changes for commitment by using <code>git add</code> or <code>git rm</code>.</p> <p>If you use the <code>-a</code> flag when doing a commit, git will automatically stage any modified and removed files without you having to explicitly stage them using <code>add</code> or <code>rm</code>,... | 119, 5597 | commit, git | <h1>What is the effect of git commit without the -a option?</h1>
<p>What is the difference between these two commands?</p>
<pre><code>git commit -m "added a new page"
</code></pre>
<p>and</p>
<pre><code>git commit -a -m "added a new page"
</code></pre>
<p>I know that the -a option will stage files that have been mo... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,489 | git | # What is the effect of git commit without the -a option?
What is the difference between these two commands?
```
git commit -m "added a new page"
```
and
```
git commit -a -m "added a new page"
```
I know that the -a option will stage files that have been modified and deleted, but then what does running it without... | You have to explicitly stage changes for commitment by using `git add` or `git rm`.
If you use the `-a` flag when doing a commit, git will automatically stage any modified and removed files without you having to explicitly stage them using `add` or `rm`, etc.
If you *don't* specify `-a`, any files that have been modi... |
42571067 | How can I get a unified git diff in Visual Studio Code? | 32 | 2017-03-03 05:04:39 | <p>VS Code has a nice built-in Git interface, but it defaults to side-by-side file comparison/diff. Is there a way to switch to unified colored mode?</p>
| 8,287 | 102,675 | 2025-11-13 06:22:00 | 42,571,470 | 49 | 2017-03-03 05:41:01 | 6,309 | 2025-11-13 06:22:00 | https://stackoverflow.com/q/42571067 | https://stackoverflow.com/a/42571470 | <p>The <a href="https://code.visualstudio.com/Docs/editor/versioncontrol#_viewing-diffs" rel="nofollow noreferrer">official view is a side by side one</a></p>
<p><a href="https://i.sstatic.net/CwyvX.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CwyvX.png" alt="enter image description here" /></a></p>
<... | <p>The <a href="https://code.visualstudio.com/Docs/editor/versioncontrol#_viewing-diffs" rel="nofollow noreferrer">official view is a side by side one</a></p> <p><a href="https://i.sstatic.net/CwyvX.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CwyvX.png" alt="enter image description here" /></a></p> <... | 119, 606, 111608 | diff, git, visual-studio-code | <h1>How can I get a unified git diff in Visual Studio Code?</h1>
<p>VS Code has a nice built-in Git interface, but it defaults to side-by-side file comparison/diff. Is there a way to switch to unified colored mode?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,490 | git | # How can I get a unified git diff in Visual Studio Code?
VS Code has a nice built-in Git interface, but it defaults to side-by-side file comparison/diff. Is there a way to switch to unified colored mode? | The [official view is a side by side one](https://code.visualstudio.com/Docs/editor/versioncontrol#_viewing-diffs)
[](https://i.sstatic.net/CwyvX.png)
But the [VSCode Tips page](https://github.com/Microsoft/vscode-tips-and-tricks#git-integration) mention... |
29557635 | Stash everything in Git including all submodules? | 32 | 2015-04-10 09:15:00 | <p>When a project contains submodules you need to stash/unstash all of them separately. Is there a way to do it using less actions?</p>
<p>This link maybe helpful:</p>
<p><a href="https://stackoverflow.com/questions/1030169/easy-way-pull-latest-of-all-submodules">Easy way pull latest of all submodules</a></p>
<p>It ... | 23,779 | 4,575,764 | 2022-12-23 16:24:37 | 29,558,330 | 49 | 2015-04-10 09:50:16 | 2,931,427 | 2017-03-27 11:53:52 | https://stackoverflow.com/q/29557635 | https://stackoverflow.com/a/29558330 | <p>You can use <code>foreach</code> to run a specific git command on each sub-module. For example to apply 'git stash' to every modules use this: </p>
<pre><code>git submodule foreach 'git stash'
</code></pre>
<p>Similarly, the following command will checkout <code>master</code> branch and then pull any updates from ... | <p>You can use <code>foreach</code> to run a specific git command on each sub-module. For example to apply 'git stash' to every modules use this: </p> <pre><code>git submodule foreach 'git stash' </code></pre> <p>Similarly, the following command will checkout <code>master</code> branch and then pull any updates from ... | 119, 41612 | git, git-submodules | <h1>Stash everything in Git including all submodules?</h1>
<p>When a project contains submodules you need to stash/unstash all of them separately. Is there a way to do it using less actions?</p>
<p>This link maybe helpful:</p>
<p><a href="https://stackoverflow.com/questions/1030169/easy-way-pull-latest-of-all-submodu... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,491 | git | # Stash everything in Git including all submodules?
When a project contains submodules you need to stash/unstash all of them separately. Is there a way to do it using less actions?
This link maybe helpful:
[Easy way pull latest of all submodules](https://stackoverflow.com/questions/1030169/easy-way-pull-latest-of-al... | You can use `foreach` to run a specific git command on each sub-module. For example to apply 'git stash' to every modules use this:
```
git submodule foreach 'git stash'
```
Similarly, the following command will checkout `master` branch and then pull any updates from the remote source for each submodule.
```
git sub... |
738154 | What does git "updating currently checked out branch" warning mean? | 32 | 2009-04-10 16:25:07 | <p>When I do a git push, I see the following:</p>
<pre><code>warning: updating the currently checked out branch; this may cause confusion,
as the index and working tree do not reflect changes that are now in HEAD.
</code></pre>
<p>I Googled for this message, and all I can find is a <a href="http://article.gmane.org/g... | 16,997 | 18,103 | 2010-11-07 15:15:34 | 738,256 | 49 | 2009-04-10 17:09:25 | 69,755 | 2009-04-11 04:52:17 | https://stackoverflow.com/q/738154 | https://stackoverflow.com/a/738256 | <p>This happens when you are pushing to a non-bare repo. A bare repo is one that consists solely of a <code>.git</code> directory; a non-bare repo also includes a checkout. In general, you should not push to a non-bare repo; in fact, in future version of git, that will be forbidden. If you push to a non-bare repo, then... | <p>This happens when you are pushing to a non-bare repo. A bare repo is one that consists solely of a <code>.git</code> directory; a non-bare repo also includes a checkout. In general, you should not push to a non-bare repo; in fact, in future version of git, that will be forbidden. If you push to a non-bare repo, then... | 119 | git | <h1>What does git "updating currently checked out branch" warning mean?</h1>
<p>When I do a git push, I see the following:</p>
<pre><code>warning: updating the currently checked out branch; this may cause confusion,
as the index and working tree do not reflect changes that are now in HEAD.
</code></pre>
<p>I Googled ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,492 | git | # What does git "updating currently checked out branch" warning mean?
When I do a git push, I see the following:
```
warning: updating the currently checked out branch; this may cause confusion,
as the index and working tree do not reflect changes that are now in HEAD.
```
I Googled for this message, and all I can f... | This happens when you are pushing to a non-bare repo. A bare repo is one that consists solely of a `.git` directory; a non-bare repo also includes a checkout. In general, you should not push to a non-bare repo; in fact, in future version of git, that will be forbidden. If you push to a non-bare repo, then the HEAD of t... |
2187657 | Calculate second point knowing the starting point and distance | 29 | 2010-02-02 20:58:30 | <p>using a Latitude and Longitude value (Point A), I am trying to calculate another Point B, X meters away bearing 0 radians from point A. Then display the point B Latitude and Longitude values.</p>
<p>Example (Pseudo code):</p>
<pre><code>PointA_Lat = x.xxxx;
PointA_Lng = x.xxxx;
Distance = 3; //Meters
bearing = 0; ... | 42,389 | 156,665 | 2015-08-25 15:20:47 | 2,188,606 | 49 | 2010-02-02 23:41:23 | 153,430 | 2014-01-30 17:00:21 | https://stackoverflow.com/q/2187657 | https://stackoverflow.com/a/2188606 | <p>It seems you are measuring distance (R) in meters, and bearing (theta) counterclockwise from due east. And for your purposes (hundereds of meters), plane geometry should be accurate enough. In that case,</p>
<pre><code>dx = R*cos(theta) ; theta measured counterclockwise from due east
dy = R*sin(theta) ; dx, dy sa... | <p>It seems you are measuring distance (R) in meters, and bearing (theta) counterclockwise from due east. And for your purposes (hundereds of meters), plane geometry should be accurate enough. In that case,</p> <pre><code>dx = R*cos(theta) ; theta measured counterclockwise from due east dy = R*sin(theta) ; dx, dy sa... | 259, 3235, 6238, 20301 | distance, latitude-longitude, math, trigonometry | <h1>Calculate second point knowing the starting point and distance</h1>
<p>using a Latitude and Longitude value (Point A), I am trying to calculate another Point B, X meters away bearing 0 radians from point A. Then display the point B Latitude and Longitude values.</p>
<p>Example (Pseudo code):</p>
<pre><code>PointA... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,497 | git | # Calculate second point knowing the starting point and distance
using a Latitude and Longitude value (Point A), I am trying to calculate another Point B, X meters away bearing 0 radians from point A. Then display the point B Latitude and Longitude values.
Example (Pseudo code):
```
PointA_Lat = x.xxxx;
PointA_Lng =... | It seems you are measuring distance (R) in meters, and bearing (theta) counterclockwise from due east. And for your purposes (hundereds of meters), plane geometry should be accurate enough. In that case,
```
dx = R*cos(theta) ; theta measured counterclockwise from due east
dy = R*sin(theta) ; dx, dy same units as R
``... |
37801342 | Using git log to display files changed during merge | 26 | 2016-06-14 00:55:28 | <p>I’m executing the following command:</p>
<pre><code>git log --name-only –pretty="format:%H %s" -- *.sql --grep="JIRA-154"
</code></pre>
<p>which returns results in the format:</p>
<pre><code>[commitid1] [comment]
path/to/file1/file1.sql
path/to/file2/file2.sql
path/to/file3/file3.sql
[commitid2] [comment]
path/t... | 15,793 | 6,462,105 | 2017-05-04 23:16:00 | 37,802,111 | 49 | 2016-06-14 02:41:39 | 1,256,452 | 2017-05-04 16:50:36 | https://stackoverflow.com/q/37801342 | https://stackoverflow.com/a/37802111 | <h3>TL;DR</h3>
<p>Try adding the <code>-m</code> option to the <code>git log</code> options. This makes Git "split" each merge, so that it will diff the merge <em>twice</em>, once against each parent. Without this or some other similar option, <code>git log</code> finds the merges but then does not even look inside ... | <h3>TL;DR</h3> <p>Try adding the <code>-m</code> option to the <code>git log</code> options. This makes Git "split" each merge, so that it will diff the merge <em>twice</em>, once against each parent. Without this or some other similar option, <code>git log</code> finds the merges but then does not even look inside ... | 119, 717, 47913 | git, git-log, merge | <h1>Using git log to display files changed during merge</h1>
<p>I’m executing the following command:</p>
<pre><code>git log --name-only –pretty="format:%H %s" -- *.sql --grep="JIRA-154"
</code></pre>
<p>which returns results in the format:</p>
<pre><code>[commitid1] [comment]
path/to/file1/file1.sql
path/to/file2/fi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,499 | git | # Using git log to display files changed during merge
I’m executing the following command:
```
git log --name-only –pretty="format:%H %s" -- *.sql --grep="JIRA-154"
```
which returns results in the format:
```
[commitid1] [comment]
path/to/file1/file1.sql
path/to/file2/file2.sql
path/to/file3/file3.sql
[commitid2]... | ### TL;DR
Try adding the `-m` option to the `git log` options. This makes Git "split" each merge, so that it will diff the merge *twice*, once against each parent. Without this or some other similar option, `git log` finds the merges but then does not even look inside them at all.
Also, as [ElpieKay commented](https:... |
44006070 | Jenkins: GitSCM finishes the clone in a detached head state, how can I make sure that the correct branch name is checked out? | 25 | 2017-05-16 15:49:04 | <p>I wrote a Jenkins pipeline which clones a git repository and runs a MSBUILD build.</p>
<p>I use GitSCM to clone the repository into the workspace like so:</p>
<pre><code>stage ('Checkout SCM & Merge master to feature branch') {
checkout([$class: 'GitSCM', branches: [[name: '*/feature/*']], doGenerateSubmod... | 11,706 | 1,702,942 | 2023-01-28 01:57:03 | 44,023,516 | 49 | 2017-05-17 11:26:12 | 1,702,942 | 2019-12-02 10:19:58 | https://stackoverflow.com/q/44006070 | https://stackoverflow.com/a/44023516 | <p>After lots of researching and even contacting Jenkins professionals and many tries from my side, I found how to solve this issue.</p>
<p>The following code fixes the issue:</p>
<pre><code>checkout([$class: 'GitSCM', branches: [[name: '*/feature/*']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: ... | <p>After lots of researching and even contacting Jenkins professionals and many tries from my side, I found how to solve this issue.</p> <p>The following code fixes the issue:</p> <pre><code>checkout([$class: 'GitSCM', branches: [[name: '*/feature/*']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: ... | 119, 64999 | git, jenkins | <h1>Jenkins: GitSCM finishes the clone in a detached head state, how can I make sure that the correct branch name is checked out?</h1>
<p>I wrote a Jenkins pipeline which clones a git repository and runs a MSBUILD build.</p>
<p>I use GitSCM to clone the repository into the workspace like so:</p>
<pre><code>stage ('Ch... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,500 | git | # Jenkins: GitSCM finishes the clone in a detached head state, how can I make sure that the correct branch name is checked out?
I wrote a Jenkins pipeline which clones a git repository and runs a MSBUILD build.
I use GitSCM to clone the repository into the workspace like so:
```
stage ('Checkout SCM & Merge master t... | After lots of researching and even contacting Jenkins professionals and many tries from my side, I found how to solve this issue.
The following code fixes the issue:
```
checkout([$class: 'GitSCM', branches: [[name: '*/feature/*']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localB... |
21360077 | How to merge between two local repositories | 24 | 2014-01-26 05:26:47 | <p>I have two local git repositories (one is a clone of master repo, other is a clone of fork of master). Is there a way to merge a branch of one with the same branch from other? </p>
<p>Note - I can't just add the master as upstream , because we have some issues that way currently - <a href="https://stackoverflow.co... | 17,871 | 895,429 | 2014-01-26 05:55:33 | 21,360,233 | 49 | 2014-01-26 05:50:01 | 1,929,093 | 2014-01-26 05:55:33 | https://stackoverflow.com/q/21360077 | https://stackoverflow.com/a/21360233 | <p>You could add another remote repository such as 'local'.</p>
<p>Try the following way (which I just ran successfully):</p>
<p>(Suppose your local repositories are MyGitRepo.git and AnotherRepo.git in the same folder)</p>
<p>in MyGitRepo.git folder:</p>
<pre><code>$: git remote add local ../AnotherRepo
$: git fet... | <p>You could add another remote repository such as 'local'.</p> <p>Try the following way (which I just ran successfully):</p> <p>(Suppose your local repositories are MyGitRepo.git and AnotherRepo.git in the same folder)</p> <p>in MyGitRepo.git folder:</p> <pre><code>$: git remote add local ../AnotherRepo $: git fet... | 119, 28897 | git, git-merge | <h1>How to merge between two local repositories</h1>
<p>I have two local git repositories (one is a clone of master repo, other is a clone of fork of master). Is there a way to merge a branch of one with the same branch from other? </p>
<p>Note - I can't just add the master as upstream , because we have some issues t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,502 | git | # How to merge between two local repositories
I have two local git repositories (one is a clone of master repo, other is a clone of fork of master). Is there a way to merge a branch of one with the same branch from other?
Note - I can't just add the master as upstream , because we have some issues that way currently ... | You could add another remote repository such as 'local'.
Try the following way (which I just ran successfully):
(Suppose your local repositories are MyGitRepo.git and AnotherRepo.git in the same folder)
in MyGitRepo.git folder:
```
$: git remote add local ../AnotherRepo
$: git fetch local
$: git merge local/master
... |
4041087 | Git Pull: Change Authentication | 24 | 2010-10-28 08:34:56 | <p>I'm quite new to git. I have a repo setup on a server (A) where access is via ssh rsa keys. I have a few users there including myself. Now I do <code>git clone</code> on my local machine and get a local copy, make changes, and <code>push origin master</code>, everything works fine.</p>
<p>The problem I'm experienci... | 40,173 | 24,894 | 2022-01-14 03:57:37 | 4,042,737 | 49 | 2010-10-28 12:08:51 | 24,894 | 2017-12-21 15:54:46 | https://stackoverflow.com/q/4041087 | https://stackoverflow.com/a/4042737 | <p>After three hours of searching and playing I have found the answer myself. The authentication details are stored in the <code>.git/config</code> file under the <code>url</code> setting in the <code>[remote "origin"]</code> section.</p>
| <p>After three hours of searching and playing I have found the answer myself. The authentication details are stored in the <code>.git/config</code> file under the <code>url</code> setting in the <code>[remote "origin"]</code> section.</p> | 58, 80, 119 | apache, git, linux | <h1>Git Pull: Change Authentication</h1>
<p>I'm quite new to git. I have a repo setup on a server (A) where access is via ssh rsa keys. I have a few users there including myself. Now I do <code>git clone</code> on my local machine and get a local copy, make changes, and <code>push origin master</code>, everything works... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,503 | git | # Git Pull: Change Authentication
I'm quite new to git. I have a repo setup on a server (A) where access is via ssh rsa keys. I have a few users there including myself. Now I do `git clone` on my local machine and get a local copy, make changes, and `push origin master`, everything works fine.
The problem I'm experie... | After three hours of searching and playing I have found the answer myself. The authentication details are stored in the `.git/config` file under the `url` setting in the `[remote "origin"]` section. |
14697801 | Git: move specific commits to another branch | 23 | 2013-02-04 23:43:34 | <p>A have repository with two branches.</p>
<p>Master branch commits:</p>
<p>c1, c2, c3, c4, c5, c6, c7, ..., c15, ...</p>
<p>Staging Branch commits:</p>
<p>c1, c2, c3, c4, c5, c6, c7</p>
<p>I want to move all commits from Master branch after <strong>c7</strong> to staging branch</p>
<p>and then revert Master bra... | 33,892 | 1,057,519 | 2013-02-05 06:56:41 | 14,697,850 | 49 | 2013-02-04 23:48:27 | 981,959 | 2013-02-04 23:48:27 | https://stackoverflow.com/q/14697801 | https://stackoverflow.com/a/14697850 | <p>In the case you've described, where all commits on the staging branch are also on the master branch, it's very easy:</p>
<pre><code>git checkout staging
git merge master
git checkout master
git reset --hard c7-hash
</code></pre>
<p>The merge will be a fast-forward.</p>
<p>In the general case, you can use <code>gi... | <p>In the case you've described, where all commits on the staging branch are also on the master branch, it's very easy:</p> <pre><code>git checkout staging git merge master git checkout master git reset --hard c7-hash </code></pre> <p>The merge will be a fast-forward.</p> <p>In the general case, you can use <code>gi... | 119, 53850 | git, git-commit | <h1>Git: move specific commits to another branch</h1>
<p>A have repository with two branches.</p>
<p>Master branch commits:</p>
<p>c1, c2, c3, c4, c5, c6, c7, ..., c15, ...</p>
<p>Staging Branch commits:</p>
<p>c1, c2, c3, c4, c5, c6, c7</p>
<p>I want to move all commits from Master branch after <strong>c7</strong... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 17,506 | git | # Git: move specific commits to another branch
A have repository with two branches.
Master branch commits:
c1, c2, c3, c4, c5, c6, c7, ..., c15, ...
Staging Branch commits:
c1, c2, c3, c4, c5, c6, c7
I want to move all commits from Master branch after **c7** to staging branch
and then revert Master branch
with
... | In the case you've described, where all commits on the staging branch are also on the master branch, it's very easy:
```
git checkout staging
git merge master
git checkout master
git reset --hard c7-hash
```
The merge will be a fast-forward.
In the general case, you can use `git cherry-pick c8 c9 c10 c11 c12 c13 c14... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.