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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5159185 | How to create a git patch from the uncommitted changes in the current working directory without creating a commit? | 1,445 | 2011-03-01 19:14:36 | <p>Say I have uncommitted changes in my working directory. How can I make a patch from those without having to create a commit?</p>
| 1,028,408 | 72,113 | 2024-10-14 22:42:39 | 5,159,205 | 637 | 2011-03-01 19:16:20 | 78,720 | 2020-09-05 19:30:07 | https://stackoverflow.com/q/5159185 | https://stackoverflow.com/a/5159205 | <p><code>git diff</code> for unstaged changes.</p>
<p><code>git diff --cached</code> for staged changes.</p>
<p><code>git diff HEAD</code> for both staged and unstaged changes.</p>
| <p><code>git diff</code> for unstaged changes.</p> <p><code>git diff --cached</code> for staged changes.</p> <p><code>git diff HEAD</code> for both staged and unstaged changes.</p> | 119, 62078 | git, git-patch | <h1>How to create a git patch from the uncommitted changes in the current working directory without creating a commit?</h1>
<p>Say I have uncommitted changes in my working directory. How can I make a patch from those without having to create a commit?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,212 | git | # How to create a git patch from the uncommitted changes in the current working directory without creating a commit?
Say I have uncommitted changes in my working directory. How can I make a patch from those without having to create a commit? | `git diff` for unstaged changes.
`git diff --cached` for staged changes.
`git diff HEAD` for both staged and unstaged changes. |
5765645 | Should you commit .gitignore into the Git repos? | 660 | 2011-04-23 17:08:02 | <p>Do you think it is a good practice to commit <code>.gitignore</code> into a Git repo?</p>
<p>Some people don't like it, but I think it is good as you can track the file's history. Isn't it?</p>
| 271,807 | 365,256 | 2024-11-17 23:33:31 | 5,765,663 | 634 | 2011-04-23 17:11:58 | 628,490 | 2024-11-17 23:33:31 | https://stackoverflow.com/q/5765645 | https://stackoverflow.com/a/5765663 | <p>Normally yes, <code>.gitignore</code> is useful for everyone who wants to work with the repository. On occasion, you'll want to ignore more private things (maybe you often create <code>LOG</code> or something). In those cases you probably don't want to force that on anyone else.</p>
| <p>Normally yes, <code>.gitignore</code> is useful for everyone who wants to work with the repository. On occasion, you'll want to ignore more private things (maybe you often create <code>LOG</code> or something). In those cases you probably don't want to force that on anyone else.</p> | 119, 25056 | git, gitignore | <h1>Should you commit .gitignore into the Git repos?</h1>
<p>Do you think it is a good practice to commit <code>.gitignore</code> into a Git repo?</p>
<p>Some people don't like it, but I think it is good as you can track the file's history. Isn't it?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,214 | git | # Should you commit .gitignore into the Git repos?
Do you think it is a good practice to commit `.gitignore` into a Git repo?
Some people don't like it, but I think it is good as you can track the file's history. Isn't it? | Normally yes, `.gitignore` is useful for everyone who wants to work with the repository. On occasion, you'll want to ignore more private things (maybe you often create `LOG` or something). In those cases you probably don't want to force that on anyone else. |
30474447 | git: fatal: I don't handle protocol 'http' | 312 | 2015-05-27 06:12:52 | <p>I copy and pasted an git clone command from a web page: <a href="https://fedorahosted.org/ibus-typing-booster/">https://fedorahosted.org/ibus-typing-booster/</a></p>
<p>I got this:</p>
<pre><code>user@host> git clone http://git.fedorahosted.org/git/ibus-typing-booster.git
Cloning into 'ibus-typing-booster'..... | 213,157 | 633,961 | 2020-04-22 12:02:42 | 30,474,448 | 634 | 2015-05-27 06:12:52 | 633,961 | 2018-12-20 11:51:27 | https://stackoverflow.com/q/30474447 | https://stackoverflow.com/a/30474448 | <p>I copied and pasted the whole line <code>git clone http://...</code>.</p>
<p>The character between <code>git clone</code> and <code>http://...</code> looks like a space, but it is a <strong>special Unicode character</strong>!</p>
<p>Short answer: After removing this character, and entering a real space, it worked!... | <p>I copied and pasted the whole line <code>git clone http://...</code>.</p> <p>The character between <code>git clone</code> and <code>http://...</code> looks like a space, but it is a <strong>special Unicode character</strong>!</p> <p>Short answer: After removing this character, and entering a real space, it worked!... | 119, 1084, 3050 | clone, git, whitespace | <h1>git: fatal: I don't handle protocol 'http'</h1>
<p>I copy and pasted an git clone command from a web page: <a href="https://fedorahosted.org/ibus-typing-booster/">https://fedorahosted.org/ibus-typing-booster/</a></p>
<p>I got this:</p>
<pre><code>user@host> git clone http://git.fedorahosted.org/git/ibus-ty... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,215 | git | # git: fatal: I don't handle protocol 'http'
I copy and pasted an git clone command from a web page: <https://fedorahosted.org/ibus-typing-booster/>
I got this:
```
user@host> git clone http://git.fedorahosted.org/git/ibus-typing-booster.git
Cloning into 'ibus-typing-booster'...
fatal: I don't handle protocol '... | I copied and pasted the whole line `git clone http://...`.
The character between `git clone` and `http://...` looks like a space, but it is a **special Unicode character**!
Short answer: After removing this character, and entering a real space, it worked!
For people who love details: I see two ways to reveal ascii v... |
2223308 | How to remove a file from the staging area (= index = cache) in Git? | 460 | 2010-02-08 16:58:21 | <p><strong>EDIT</strong> This question can be understood in two ways, and the optimal answer is different in the two cases.</p>
<ul>
<li><p>Question 1: I added a <strong>previously untracked file</strong> to the staging area. How can I remove this file from the staging area without removing it from the file system?</p>... | 328,163 | 17,916 | 2023-05-23 13:10:40 | 2,223,340 | 632 | 2010-02-08 17:02:51 | 75,170 | 2015-07-13 09:04:44 | https://stackoverflow.com/q/2223308 | https://stackoverflow.com/a/2223340 | <p>You want:</p>
<pre><code>git rm --cached [file]
</code></pre>
<p>If you omit the <code>--cached</code> option, it will also delete it from the working tree. <code>git rm</code> is slightly safer than <code>git reset</code>, because you'll be warned if the staged content doesn't match either the tip of the branch o... | <p>You want:</p> <pre><code>git rm --cached [file] </code></pre> <p>If you omit the <code>--cached</code> option, it will also delete it from the working tree. <code>git rm</code> is slightly safer than <code>git reset</code>, because you'll be warned if the staged content doesn't match either the tip of the branch o... | 119 | git | <h1>How to remove a file from the staging area (= index = cache) in Git?</h1>
<p><strong>EDIT</strong> This question can be understood in two ways, and the optimal answer is different in the two cases.</p>
<ul>
<li><p>Question 1: I added a <strong>previously untracked file</strong> to the staging area. How can I remove... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,216 | git | # How to remove a file from the staging area (= index = cache) in Git?
**EDIT** This question can be understood in two ways, and the optimal answer is different in the two cases.
- Question 1: I added a **previously untracked file** to the staging area. How can I remove this file from the staging area without removin... | You want:
```
git rm --cached [file]
```
If you omit the `--cached` option, it will also delete it from the working tree. `git rm` is slightly safer than `git reset`, because you'll be warned if the staged content doesn't match either the tip of the branch or the file on disk. (If it doesn't, you have to add `--force... |
15669091 | Bower install using only https? | 259 | 2013-03-27 20:46:05 | <p>I am trying to set up Bower on a build server at our organization's data center, but <code>git</code>'s port does not appear to be open on the data center's firewall. I can use the git command line client to clone via <code>https://[repo]</code>, but not <code>git://[repo]</code>.</p>
<p>Is there a switch or prefe... | 71,944 | 182,654 | 2018-08-05 04:39:37 | 15,684,898 | 632 | 2013-03-28 14:48:27 | 64,949 | 2018-01-23 15:44:46 | https://stackoverflow.com/q/15669091 | https://stackoverflow.com/a/15684898 | <p>You can make git replace the protocol for you. Just run:</p>
<pre><code>git config --global url."https://".insteadOf git://
</code></pre>
<p>to use HTTPS protocol instead of Git.</p>
| <p>You can make git replace the protocol for you. Just run:</p> <pre><code>git config --global url."https://".insteadOf git:// </code></pre> <p>to use HTTPS protocol instead of Git.</p> | 119, 34099, 85693 | bower, git, git-clone | <h1>Bower install using only https?</h1>
<p>I am trying to set up Bower on a build server at our organization's data center, but <code>git</code>'s port does not appear to be open on the data center's firewall. I can use the git command line client to clone via <code>https://[repo]</code>, but not <code>git://[repo]</... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,217 | git | # Bower install using only https?
I am trying to set up Bower on a build server at our organization's data center, but `git`'s port does not appear to be open on the data center's firewall. I can use the git command line client to clone via `https://[repo]`, but not `git://[repo]`.
Is there a switch or preference whi... | You can make git replace the protocol for you. Just run:
```
git config --global url."https://".insteadOf git://
```
to use HTTPS protocol instead of Git. |
5737002 | How to delete a stash created with git stash create? | 1,082 | 2011-04-20 21:43:46 | <p>Git stash seems to do a lot of what I want, except that it is a little hard to script, as the if you have no changes, then <code>git stash; git stash pop</code> will do something different than if you do have changes in your repository.</p>
<p>It appears that <code>git stash create</code> is the answer to that prob... | 1,137,682 | 97,627 | 2024-04-30 11:40:09 | 5,737,046 | 631 | 2011-04-20 21:49:12 | 54,249 | 2019-07-13 01:29:30 | https://stackoverflow.com/q/5737002 | https://stackoverflow.com/a/5737046 | <p><strong>To delete a normal stash created with <code>git stash</code> , you want <code>git stash drop</code> or <code>git stash drop stash@{n}</code>. See below for more details.</strong></p>
<hr>
<p>You don't need to delete a stash created with <code>git stash create</code>. From the docs:</p>
<blockquote>
<p>C... | <p><strong>To delete a normal stash created with <code>git stash</code> , you want <code>git stash drop</code> or <code>git stash drop stash@{n}</code>. See below for more details.</strong></p> <hr> <p>You don't need to delete a stash created with <code>git stash create</code>. From the docs:</p> <blockquote> <p>C... | 119, 13091 | git, git-stash | <h1>How to delete a stash created with git stash create?</h1>
<p>Git stash seems to do a lot of what I want, except that it is a little hard to script, as the if you have no changes, then <code>git stash; git stash pop</code> will do something different than if you do have changes in your repository.</p>
<p>It appears... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,218 | git | # How to delete a stash created with git stash create?
Git stash seems to do a lot of what I want, except that it is a little hard to script, as the if you have no changes, then `git stash; git stash pop` will do something different than if you do have changes in your repository.
It appears that `git stash create` is... | **To delete a normal stash created with `git stash` , you want `git stash drop` or `git stash drop stash@{n}`. See below for more details.**
---
You don't need to delete a stash created with `git stash create`. From the docs:
> Create a stash entry (which is a regular commit object) and return its object name, witho... |
1157818 | How can I show what a commit did? | 366 | 2009-07-21 07:53:58 | <p>A stupid way I know is:</p>
<pre><code>git diff commit-number1 commit-number2
</code></pre>
<p>Is there a better way?</p>
<p>I mean, I want to know the commit1 itself. I don't want to add the commit2 before it as a parameter.</p>
| 269,609 | 75,501 | 2022-03-25 21:24:26 | 1,157,854 | 631 | 2009-07-21 08:02:45 | 43,582 | 2016-08-19 17:57:51 | https://stackoverflow.com/q/1157818 | https://stackoverflow.com/a/1157854 | <pre><code>git show <commit-id>
</code></pre>
<p><a href="https://git-scm.com/docs/git-show" rel="noreferrer">Documentation for git show</a></p>
| <pre><code>git show <commit-id> </code></pre> <p><a href="https://git-scm.com/docs/git-show" rel="noreferrer">Documentation for git show</a></p> | 119 | git | <h1>How can I show what a commit did?</h1>
<p>A stupid way I know is:</p>
<pre><code>git diff commit-number1 commit-number2
</code></pre>
<p>Is there a better way?</p>
<p>I mean, I want to know the commit1 itself. I don't want to add the commit2 before it as a parameter.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,219 | git | # How can I show what a commit did?
A stupid way I know is:
```
git diff commit-number1 commit-number2
```
Is there a better way?
I mean, I want to know the commit1 itself. I don't want to add the commit2 before it as a parameter. | ```
git show <commit-id>
```
[Documentation for git show](https://git-scm.com/docs/git-show) |
2529441 | How to read the output from git diff? | 357 | 2010-03-27 13:33:52 | <p>The man page for <code>git-diff</code> is rather long, and explains many cases which don't seem to be necessary for a beginner. For example:</p>
<pre><code>git diff origin/master
</code></pre>
| 166,822 | 39,444 | 2025-08-27 08:35:18 | 2,530,012 | 631 | 2010-03-27 16:28:28 | 46,058 | 2021-09-28 11:33:18 | https://stackoverflow.com/q/2529441 | https://stackoverflow.com/a/2530012 | <p>Lets take a look at example advanced diff from git history (in <a href="http://repo.or.cz/w/git.git/commitdiff/1088261f6fc90324014b5306cca4171987da85ce#patch3" rel="noreferrer">commit 1088261f in git.git repository</a>):</p>
<pre><code>diff --git a/builtin-http-fetch.c b/http-fetch.c
similarity index 95%
rename from... | <p>Lets take a look at example advanced diff from git history (in <a href="http://repo.or.cz/w/git.git/commitdiff/1088261f6fc90324014b5306cca4171987da85ce#patch3" rel="noreferrer">commit 1088261f in git.git repository</a>):</p> <pre><code>diff --git a/builtin-http-fetch.c b/http-fetch.c similarity index 95% rename from... | 119, 606, 9033 | diff, git, git-diff | <h1>How to read the output from git diff?</h1>
<p>The man page for <code>git-diff</code> is rather long, and explains many cases which don't seem to be necessary for a beginner. For example:</p>
<pre><code>git diff origin/master
</code></pre>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,220 | git | # How to read the output from git diff?
The man page for `git-diff` is rather long, and explains many cases which don't seem to be necessary for a beginner. For example:
```
git diff origin/master
``` | Lets take a look at example advanced diff from git history (in [commit 1088261f in git.git repository](http://repo.or.cz/w/git.git/commitdiff/1088261f6fc90324014b5306cca4171987da85ce#patch3)):
```
diff --git a/builtin-http-fetch.c b/http-fetch.c
similarity index 95%
rename from builtin-http-fetch.c
rename to http-fetc... |
273141 | Regex for numbers only in C# | 421 | 2008-11-07 18:42:49 | <p>I haven't used regular expressions at all, so I'm having difficulty troubleshooting. I want the regex to match only when the contained string is all numbers; but with the two examples below it is matching a string that contains all numbers plus an equals sign like "1234=4321". I'm sure there's a way to cha... | 1,328,603 | 4,660 | 2025-09-09 08:38:15 | 273,144 | 625 | 2008-11-07 18:44:27 | 1,288 | 2012-12-19 22:47:12 | https://stackoverflow.com/q/273141 | https://stackoverflow.com/a/273144 | <p>Use the beginning and end anchors.</p>
<pre><code>Regex regex = new Regex(@"^\d$");
</code></pre>
<p>Use <code>"^\d+$"</code> if you need to match more than one digit.</p>
<hr>
<p>Note that <code>"\d"</code> will match <code>[0-9]</code> and other digit characters like the Eastern Arabic numerals <code>٠١٢٣٤٥٦٧٨... | <p>Use the beginning and end anchors.</p> <pre><code>Regex regex = new Regex(@"^\d$"); </code></pre> <p>Use <code>"^\d+$"</code> if you need to match more than one digit.</p> <hr> <p>Note that <code>"\d"</code> will match <code>[0-9]</code> and other digit characters like the Eastern Arabic numerals <code>٠١٢٣٤٥٦٧٨... | 9, 18, 139, 9914, 17150 | c#, digits, regex, string, string-matching | <h1>Regex for numbers only in C#</h1>
<p>I haven't used regular expressions at all, so I'm having difficulty troubleshooting. I want the regex to match only when the contained string is all numbers; but with the two examples below it is matching a string that contains all numbers plus an equals sign like "1234=432... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,222 | git | # Regex for numbers only in C#
I haven't used regular expressions at all, so I'm having difficulty troubleshooting. I want the regex to match only when the contained string is all numbers; but with the two examples below it is matching a string that contains all numbers plus an equals sign like "1234=4321". I'm sure t... | Use the beginning and end anchors.
```
Regex regex = new Regex(@"^\d$");
```
Use `"^\d+$"` if you need to match more than one digit.
---
Note that `"\d"` will match `[0-9]` and other digit characters like the Eastern Arabic numerals `٠١٢٣٤٥٦٧٨٩`. Use `"^[0-9]+$"` to restrict matches to just the Arabic numerals 0 - ... |
32355540 | Complex Git branch name broke all Git commands | 345 | 2015-09-02 14:12:48 | <p>I was trying to create a branch from <code>master</code> with the following command,</p>
<pre><code>git branch SSLOC-201_Implement___str__()_of_ProductSearchQuery
</code></pre>
<p>when Git suddenly stopped responding. I suspect the unescaped <code>()</code> are to blame, somehow. Now, whenever I try to run any Git... | 22,243 | 70,600 | 2018-04-25 20:52:37 | 32,356,243 | 625 | 2015-09-02 14:42:37 | 2,541,573 | 2016-09-22 11:42:08 | https://stackoverflow.com/q/32355540 | https://stackoverflow.com/a/32356243 | <h1>Problem</h1>
<blockquote>
<p>Can anyone explain what happened? [...] I'd love to be able to delete that branch, but Git won't work for me.</p>
</blockquote>
<p>By running</p>
<pre><code>git branch SSLOC-201_Implement___str__()_of_ProductSearchQuery
</code></pre>
<p>in zsh, <strong>you did not create any branc... | <h1>Problem</h1> <blockquote> <p>Can anyone explain what happened? [...] I'd love to be able to delete that branch, but Git won't work for me.</p> </blockquote> <p>By running</p> <pre><code>git branch SSLOC-201_Implement___str__()_of_ProductSearchQuery </code></pre> <p>in zsh, <strong>you did not create any branc... | 119, 3791, 20347, 76220 | git, git-branch, parentheses, zsh | <h1>Complex Git branch name broke all Git commands</h1>
<p>I was trying to create a branch from <code>master</code> with the following command,</p>
<pre><code>git branch SSLOC-201_Implement___str__()_of_ProductSearchQuery
</code></pre>
<p>when Git suddenly stopped responding. I suspect the unescaped <code>()</code> a... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,223 | git | # Complex Git branch name broke all Git commands
I was trying to create a branch from `master` with the following command,
```
git branch SSLOC-201_Implement___str__()_of_ProductSearchQuery
```
when Git suddenly stopped responding. I suspect the unescaped `()` are to blame, somehow. Now, whenever I try to run any Gi... | # Problem
> Can anyone explain what happened? [...] I'd love to be able to delete that branch, but Git won't work for me.
By running
```
git branch SSLOC-201_Implement___str__()_of_ProductSearchQuery
```
in zsh, **you did not create any branch**. Instead, you accidentally defined three *shell functions*, called `gi... |
8358035 | What's the difference between Git Revert, Checkout and Reset? | 399 | 2011-12-02 13:37:48 | <p>I am trying to learn how to restore or rollback files and projects to a prior state, and don't understand the difference between <code>git revert</code>, <code>checkout</code>, and <code>reset</code>. Why are there 3 different commands for seemingly the same purpose, and when should someone choose one over the othe... | 218,086 | 714,232 | 2023-06-22 11:14:00 | 8,358,039 | 621 | 2011-12-02 14:43:33 | 95,706 | 2023-06-22 11:14:00 | https://stackoverflow.com/q/8358035 | https://stackoverflow.com/a/8358039 | <p>These three commands have entirely different purposes. They are not even remotely similar.</p>
<h2><code>git revert</code></h2>
<p>This command creates a new commit that undoes the changes from a previous commit. This command adds new history to the project (it doesn't modify existing history).</p>
<h2><code>git che... | <p>These three commands have entirely different purposes. They are not even remotely similar.</p> <h2><code>git revert</code></h2> <p>This command creates a new commit that undoes the changes from a previous commit. This command adds new history to the project (it doesn't modify existing history).</p> <h2><code>git che... | 119, 34403, 37230, 51381 | git, git-checkout, git-reset, git-revert | <h1>What's the difference between Git Revert, Checkout and Reset?</h1>
<p>I am trying to learn how to restore or rollback files and projects to a prior state, and don't understand the difference between <code>git revert</code>, <code>checkout</code>, and <code>reset</code>. Why are there 3 different commands for seemi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,224 | git | # What's the difference between Git Revert, Checkout and Reset?
I am trying to learn how to restore or rollback files and projects to a prior state, and don't understand the difference between `git revert`, `checkout`, and `reset`. Why are there 3 different commands for seemingly the same purpose, and when should some... | These three commands have entirely different purposes. They are not even remotely similar.
## `git revert`
This command creates a new commit that undoes the changes from a previous commit. This command adds new history to the project (it doesn't modify existing history).
## `git checkout`
This command checks-out co... |
37770467 | Why do I have to "git push --set-upstream origin <branch>"? | 433 | 2016-06-12 03:30:45 | <p>I created a local branch for testing Solaris and Sun Studio. I then pushed the branch upstream. After committing a change and attempting to push the changes:</p>
<pre><code>$ git commit blake2.cpp -m "Add workaround for missing _mm_set_epi64x"
[solaris 7ad22ff] Add workaround for missing _mm_set_epi64x
1 ... | 1,042,267 | 608,639 | 2025-03-13 14:15:16 | 37,770,744 | 618 | 2016-06-12 04:31:04 | 1,256,452 | 2016-06-30 22:32:59 | https://stackoverflow.com/q/37770467 | https://stackoverflow.com/a/37770744 | <h3>TL;DR: <code>git branch --set-upstream-to origin/solaris</code></h3>
<hr>
<p>The answer to the question you asked—which I'll rephrase a bit as "do I have to set an upstream"—is: no, you don't <em>have</em> to set an upstream at all.</p>
<p>If you do not have upstream for the current branch, however, Git changes ... | <h3>TL;DR: <code>git branch --set-upstream-to origin/solaris</code></h3> <hr> <p>The answer to the question you asked—which I'll rephrase a bit as "do I have to set an upstream"—is: no, you don't <em>have</em> to set an upstream at all.</p> <p>If you do not have upstream for the current branch, however, Git changes ... | 119, 1879 | branch, git | <h1>Why do I have to "git push --set-upstream origin <branch>"?</h1>
<p>I created a local branch for testing Solaris and Sun Studio. I then pushed the branch upstream. After committing a change and attempting to push the changes:</p>
<pre><code>$ git commit blake2.cpp -m "Add workaround for missing _mm_set_epi64x&... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,226 | git | # Why do I have to "git push --set-upstream origin "?
I created a local branch for testing Solaris and Sun Studio. I then pushed the branch upstream. After committing a change and attempting to push the changes:
```
$ git commit blake2.cpp -m "Add workaround for missing _mm_set_epi64x"
[solaris 7ad22ff] Add workaroun... | ### TL;DR: `git branch --set-upstream-to origin/solaris`
---
The answer to the question you asked—which I'll rephrase a bit as "do I have to set an upstream"—is: no, you don't *have* to set an upstream at all.
If you do not have upstream for the current branch, however, Git changes its behavior on `git push`, and on... |
7663451 | View a specific Git commit | 385 | 2011-10-05 15:04:04 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/7610073/get-information-about-a-sha-1-commit-object">Get Information about a SHA-1 commit object?</a> </p>
</blockquote>
<p>I needed to check when a specific change was added to a file I'm working on, so I used... | 321,109 | 168,775 | 2021-04-23 01:49:17 | 7,663,506 | 618 | 2011-10-05 15:08:19 | 385,478 | 2021-04-23 01:49:17 | https://stackoverflow.com/q/7663451 | https://stackoverflow.com/a/7663506 | <pre><code>git show <revhash>
</code></pre>
<p>Documentation <a href="https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-show.html" rel="noreferrer">here</a>.
Or if that doesn't work, try <a href="https://web.archive.org/web/20160505053436/http://git-htmldocs.googlecode.com:80/git/git-show.html" rel="n... | <pre><code>git show <revhash> </code></pre> <p>Documentation <a href="https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-show.html" rel="noreferrer">here</a>. Or if that doesn't work, try <a href="https://web.archive.org/web/20160505053436/http://git-htmldocs.googlecode.com:80/git/git-show.html" rel="n... | 119 | git | <h1>View a specific Git commit</h1>
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/7610073/get-information-about-a-sha-1-commit-object">Get Information about a SHA-1 commit object?</a> </p>
</blockquote>
<p>I needed to check when a specific change was added... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,227 | git | # View a specific Git commit
> **Possible Duplicate:**
> [Get Information about a SHA-1 commit object?](https://stackoverflow.com/questions/7610073/get-information-about-a-sha-1-commit-object)
I needed to check when a specific change was added to a file I'm working on, so I used the `git blame` command. From that I... | ```
git show <revhash>
```
Documentation [here](https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-show.html).
Or if that doesn't work, try [Google Code's Git Documentation](https://web.archive.org/web/20160505053436/http://git-htmldocs.googlecode.com:80/git/git-show.html) |
10415100 | Exclude file from "git diff" | 467 | 2012-05-02 13:48:34 | <p>I am trying to exclude a file (<code>db/irrelevant.php</code>) from a Git diff. I have tried putting a file in the <code>db</code> subdirectory called <code>.gitattributes</code> with the line <code>irrelevant.php -diff</code>
and I have also tried creating a file called <code>.git/info/attributes</code> containing ... | 187,843 | 821,509 | 2025-10-21 09:36:22 | 39,943,727 | 617 | 2016-10-09 12:40:04 | 281,545 | 2024-02-17 23:02:51 | https://stackoverflow.com/q/10415100 | https://stackoverflow.com/a/39943727 | <p>OMG, drivers and <a href="https://en.wikipedia.org/wiki/AWK" rel="noreferrer">AWK</a> to exclude a lousy file? Since <a href="https://stackoverflow.com/a/21079437/281545">Git 1.9 something</a> you can:</p>
<pre class="lang-bash prettyprint-override"><code>git diff -- . ':(exclude)db/irrelevant.php' ':(exclude)db/irr... | <p>OMG, drivers and <a href="https://en.wikipedia.org/wiki/AWK" rel="noreferrer">AWK</a> to exclude a lousy file? Since <a href="https://stackoverflow.com/a/21079437/281545">Git 1.9 something</a> you can:</p> <pre class="lang-bash prettyprint-override"><code>git diff -- . ':(exclude)db/irrelevant.php' ':(exclude)db/irr... | 119, 606, 9033 | diff, git, git-diff | <h1>Exclude file from "git diff"</h1>
<p>I am trying to exclude a file (<code>db/irrelevant.php</code>) from a Git diff. I have tried putting a file in the <code>db</code> subdirectory called <code>.gitattributes</code> with the line <code>irrelevant.php -diff</code>
and I have also tried creating a file called <code>.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,228 | git | # Exclude file from "git diff"
I am trying to exclude a file (`db/irrelevant.php`) from a Git diff. I have tried putting a file in the `db` subdirectory called `.gitattributes` with the line `irrelevant.php -diff`
and I have also tried creating a file called `.git/info/attributes` containing `db/irrelevant.php`.
In a... | OMG, drivers and [AWK](https://en.wikipedia.org/wiki/AWK) to exclude a lousy file? Since [Git 1.9 something](https://stackoverflow.com/a/21079437/281545) you can:
```
git diff -- . ':(exclude)db/irrelevant.php' ':(exclude)db/irrelevant2.php'
```
(On Windows, replace the single quotes `'` by double quotes `"`.)
Ah, e... |
5802426 | Git error: src refspec master does not match any | 266 | 2011-04-27 10:08:58 | <p>I need to create a repo named <code>carboncake</code>.</p>
<p><strong>I tried this:</strong></p>
<p>Cloned the gitosis-admin repository to my local machine</p>
<pre><code>$ git clone gitosis@myserver.net:repositories/gitosis-admin.git
$ cd gitosis-admin
$ vim gitosis.conf
</code></pre>
<p>Added the <code>[repo c... | 377,497 | 174,261 | 2012-08-27 13:39:29 | 5,802,508 | 616 | 2011-04-27 10:18:43 | 223,092 | 2011-04-27 10:18:43 | https://stackoverflow.com/q/5802426 | https://stackoverflow.com/a/5802508 | <p>You've created a new repository and added some files to the index, but you haven't created your first commit yet. After you've done:</p>
<pre><code> git add a_text_file.txt
</code></pre>
<p>... do:</p>
<pre><code> git commit -m "Initial commit."
</code></pre>
<p>... and those errors should go away.</p>
| <p>You've created a new repository and added some files to the index, but you haven't created your first commit yet. After you've done:</p> <pre><code> git add a_text_file.txt </code></pre> <p>... do:</p> <pre><code> git commit -m "Initial commit." </code></pre> <p>... and those errors should go away.</p> | 119, 7330 | git, repository | <h1>Git error: src refspec master does not match any</h1>
<p>I need to create a repo named <code>carboncake</code>.</p>
<p><strong>I tried this:</strong></p>
<p>Cloned the gitosis-admin repository to my local machine</p>
<pre><code>$ git clone gitosis@myserver.net:repositories/gitosis-admin.git
$ cd gitosis-admin
$ ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,229 | git | # Git error: src refspec master does not match any
I need to create a repo named `carboncake`.
**I tried this:**
Cloned the gitosis-admin repository to my local machine
```
$ git clone gitosis@myserver.net:repositories/gitosis-admin.git
$ cd gitosis-admin
$ vim gitosis.conf
```
Added the `[repo carboncake]` and `[... | You've created a new repository and added some files to the index, but you haven't created your first commit yet. After you've done:
```
git add a_text_file.txt
```
... do:
```
git commit -m "Initial commit."
```
... and those errors should go away. |
25576415 | What is the precise meaning of "ours" and "theirs" in git? | 615 | 2014-08-29 21:18:50 | <p>This might sound like too basic of a question, but I have searched for answers and I am more confused now than before.</p>
<p>What does "ours" and "theirs" mean in git when merging my branch into my other branch?
Both branches are "ours". </p>
<p>In a merge conflict is "ours" always the upper of the two versions d... | 259,995 | 811,519 | 2024-10-15 20:25:30 | 25,576,672 | 610 | 2014-08-29 21:43:16 | 1,256,452 | 2017-01-17 11:44:39 | https://stackoverflow.com/q/25576415 | https://stackoverflow.com/a/25576672 | <p>I suspect you're confused here because it's fundamentally confusing. To make things worse, the whole ours/theirs stuff switches roles (becomes backwards) when you are doing a rebase.</p>
<p>Ultimately, during a <code>git merge</code>, the "ours" branch refers to the branch you're merging <em>into</em>:</p>
<pre><... | <p>I suspect you're confused here because it's fundamentally confusing. To make things worse, the whole ours/theirs stuff switches roles (becomes backwards) when you are doing a rebase.</p> <p>Ultimately, during a <code>git merge</code>, the "ours" branch refers to the branch you're merging <em>into</em>:</p> <pre><... | 119, 717 | git, merge | <h1>What is the precise meaning of "ours" and "theirs" in git?</h1>
<p>This might sound like too basic of a question, but I have searched for answers and I am more confused now than before.</p>
<p>What does "ours" and "theirs" mean in git when merging my branch into my other branch?
Both branches are "ours". </p>
<p>... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,232 | git | # What is the precise meaning of "ours" and "theirs" in git?
This might sound like too basic of a question, but I have searched for answers and I am more confused now than before.
What does "ours" and "theirs" mean in git when merging my branch into my other branch?
Both branches are "ours".
In a merge conflict is "... | I suspect you're confused here because it's fundamentally confusing. To make things worse, the whole ours/theirs stuff switches roles (becomes backwards) when you are doing a rebase.
Ultimately, during a `git merge`, the "ours" branch refers to the branch you're merging *into*:
```
git checkout merge-into-ours
```
a... |
18225126 | How to use Git for Unity3D source control? | 572 | 2013-08-14 06:57:26 | <p>What are best practices for using <a href="http://en.wikipedia.org/wiki/Git_%28software%29" rel="noreferrer">Git</a> source control with Unity 3D, particularly in dealing with the binary nature of Unity 3D projects? Please describe the workflow, what paths would be included in .gitignore, what settings should be set... | 271,657 | 1,769,276 | 2023-06-09 00:25:59 | 18,225,479 | 610 | 2013-08-14 07:17:40 | 420,787 | 2019-05-10 07:40:27 | https://stackoverflow.com/q/18225126 | https://stackoverflow.com/a/18225479 | <p><em>The following is an excerpt from <a href="http://www.strichnet.com/using-git-with-3d-games/" rel="noreferrer">my personal blog </a>.</em></p>
<h2>Using Git with 3D Games</h2>
<p><strong>Update Oct 2015:</strong> GitHub has since released a plugin for Git called <a href="https://git-lfs.github.com/" rel="norefe... | <p><em>The following is an excerpt from <a href="http://www.strichnet.com/using-git-with-3d-games/" rel="noreferrer">my personal blog </a>.</em></p> <h2>Using Git with 3D Games</h2> <p><strong>Update Oct 2015:</strong> GitHub has since released a plugin for Git called <a href="https://git-lfs.github.com/" rel="norefe... | 119, 456, 28511 | git, unity-game-engine, version-control | <h1>How to use Git for Unity3D source control?</h1>
<p>What are best practices for using <a href="http://en.wikipedia.org/wiki/Git_%28software%29" rel="noreferrer">Git</a> source control with Unity 3D, particularly in dealing with the binary nature of Unity 3D projects? Please describe the workflow, what paths would be... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,233 | git | # How to use Git for Unity3D source control?
What are best practices for using [Git](http://en.wikipedia.org/wiki/Git_%28software%29) source control with Unity 3D, particularly in dealing with the binary nature of Unity 3D projects? Please describe the workflow, what paths would be included in .gitignore, what setting... | *The following is an excerpt from [my personal blog](http://www.strichnet.com/using-git-with-3d-games/) .*
## Using Git with 3D Games
**Update Oct 2015:** GitHub has since released a plugin for Git called [Git LFS](https://git-lfs.github.com/) that directly deals with the below problem. You can now easily and efficie... |
5483213 | fatal: git-write-tree: error building trees | 230 | 2011-03-30 07:25:48 | <p>I did a <code>git pull</code> from a shared git repository, but something went really wrong, after I tried a <code>git revert</code>. Here is the situation now:</p>
<pre><code>$ git stash
Source/MediaStorageAndFileFormat/gdcmImageCodec.cxx: needs merge
Source/MediaStorageAndFileFormat/gdcmJPEGLSCodec.cxx: needs mer... | 154,889 | 136,285 | 2022-08-20 14:28:32 | 16,056,225 | 609 | 2013-04-17 09:19:52 | 2,067,611 | 2022-08-06 19:46:37 | https://stackoverflow.com/q/5483213 | https://stackoverflow.com/a/16056225 | <p>Use</p>
<pre class="lang-bash prettyprint-override"><code>git reset --mixed
</code></pre>
<p>instead of <code> git reset --hard</code>. You will not lose any changes.</p>
| <p>Use</p> <pre class="lang-bash prettyprint-override"><code>git reset --mixed </code></pre> <p>instead of <code> git reset --hard</code>. You will not lose any changes.</p> | 119 | git | <h1>fatal: git-write-tree: error building trees</h1>
<p>I did a <code>git pull</code> from a shared git repository, but something went really wrong, after I tried a <code>git revert</code>. Here is the situation now:</p>
<pre><code>$ git stash
Source/MediaStorageAndFileFormat/gdcmImageCodec.cxx: needs merge
Source/Med... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,234 | git | # fatal: git-write-tree: error building trees
I did a `git pull` from a shared git repository, but something went really wrong, after I tried a `git revert`. Here is the situation now:
```
$ git stash
Source/MediaStorageAndFileFormat/gdcmImageCodec.cxx: needs merge
Source/MediaStorageAndFileFormat/gdcmJPEGLSCodec.cxx... | Use
```
git reset --mixed
```
instead of `git reset --hard`. You will not lose any changes. |
8191299 | Update a submodule to the latest commit | 490 | 2011-11-19 02:03:21 | <p>I have a project A which is a library and it is used in a project B.</p>
<p>Both projects A and B have a separate repository on github BUT inside B we have a submodule of A.</p>
<p>I edited some classes on the library, which is in the repo A, I pushed on the remote repo, so the library (repo A) is updated.</p>
<p... | 499,823 | 150,571 | 2022-10-05 23:22:02 | 8,191,413 | 608 | 2011-11-19 02:26:37 | 904,365 | 2019-10-23 05:51:19 | https://stackoverflow.com/q/8191299 | https://stackoverflow.com/a/8191413 | <p>Enter the submodule directory: </p>
<pre><code>cd projB/projA
</code></pre>
<p>Pull the repo from you project A (will <em>not</em> update the git status of your parent, project B): </p>
<pre><code>git pull origin master
</code></pre>
<p>Go back to the root directory & check update:</p>
<pre><code>cd ..
gi... | <p>Enter the submodule directory: </p> <pre><code>cd projB/projA </code></pre> <p>Pull the repo from you project A (will <em>not</em> update the git status of your parent, project B): </p> <pre><code>git pull origin master </code></pre> <p>Go back to the root directory & check update:</p> <pre><code>cd .. gi... | 119, 41612 | git, git-submodules | <h1>Update a submodule to the latest commit</h1>
<p>I have a project A which is a library and it is used in a project B.</p>
<p>Both projects A and B have a separate repository on github BUT inside B we have a submodule of A.</p>
<p>I edited some classes on the library, which is in the repo A, I pushed on the remote ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,235 | git | # Update a submodule to the latest commit
I have a project A which is a library and it is used in a project B.
Both projects A and B have a separate repository on github BUT inside B we have a submodule of A.
I edited some classes on the library, which is in the repo A, I pushed on the remote repo, so the library (r... | Enter the submodule directory:
```
cd projB/projA
```
Pull the repo from you project A (will *not* update the git status of your parent, project B):
```
git pull origin master
```
Go back to the root directory & check update:
```
cd ..
git status
```
If the submodule updated before, it will show something like be... |
10911317 | How to remove the first commit in git? | 321 | 2012-06-06 09:14:37 | <p>I am curious about how to remove the first commit in git.</p>
<p>What is the revision before committing any thing? Does this revision have a name or tag?</p>
| 183,175 | 1,009,442 | 2024-08-02 13:01:57 | 32,765,827 | 607 | 2015-09-24 15:55:31 | 1,978,945 | 2021-12-31 11:19:10 | https://stackoverflow.com/q/10911317 | https://stackoverflow.com/a/32765827 | <p>For me, the most secure way is to use the <code>update-ref</code> command:</p>
<pre><code>git update-ref -d HEAD
</code></pre>
<p>It will delete the named reference <code>HEAD</code>, so it will <strong>reset (softly, you will not lose your work) ALL your commits</strong> of your current branch.</p>
<p>If what you w... | <p>For me, the most secure way is to use the <code>update-ref</code> command:</p> <pre><code>git update-ref -d HEAD </code></pre> <p>It will delete the named reference <code>HEAD</code>, so it will <strong>reset (softly, you will not lose your work) ALL your commits</strong> of your current branch.</p> <p>If what you w... | 119, 5597, 7330, 53850 | commit, git, git-commit, repository | <h1>How to remove the first commit in git?</h1>
<p>I am curious about how to remove the first commit in git.</p>
<p>What is the revision before committing any thing? Does this revision have a name or tag?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,236 | git | # How to remove the first commit in git?
I am curious about how to remove the first commit in git.
What is the revision before committing any thing? Does this revision have a name or tag? | For me, the most secure way is to use the `update-ref` command:
```
git update-ref -d HEAD
```
It will delete the named reference `HEAD`, so it will **reset (softly, you will not lose your work) ALL your commits** of your current branch.
If what you want is to merge the first commit with the second one, you can use ... |
594757 | How do I do a 'git status' so it doesn't display untracked files without using .gitignore? | 388 | 2009-02-27 13:34:34 | <p>How do I do a <code>git status</code> so it doesn't display untracked files without using <code>.gitignore</code>? I want to get modification status information on tracked files only.</p>
| 112,929 | 20,712 | 2015-01-20 17:16:51 | 594,791 | 606 | 2009-02-27 13:40:22 | 6,456 | 2009-02-27 13:40:22 | https://stackoverflow.com/q/594757 | https://stackoverflow.com/a/594791 | <p>Use this:</p>
<pre><code>git status -uno
</code></pre>
<p>which is equivalent to:</p>
<pre><code>git status --untracked-files=no
</code></pre>
<p>It's a bit hidden in the manuals, but the manpage for status says "supports the same options as git-commit", so that's where you'd have to look.</p>
| <p>Use this:</p> <pre><code>git status -uno </code></pre> <p>which is equivalent to:</p> <pre><code>git status --untracked-files=no </code></pre> <p>It's a bit hidden in the manuals, but the manpage for status says "supports the same options as git-commit", so that's where you'd have to look.</p> | 119, 456 | git, version-control | <h1>How do I do a 'git status' so it doesn't display untracked files without using .gitignore?</h1>
<p>How do I do a <code>git status</code> so it doesn't display untracked files without using <code>.gitignore</code>? I want to get modification status information on tracked files only.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,237 | git | # How do I do a 'git status' so it doesn't display untracked files without using .gitignore?
How do I do a `git status` so it doesn't display untracked files without using `.gitignore`? I want to get modification status information on tracked files only. | Use this:
```
git status -uno
```
which is equivalent to:
```
git status --untracked-files=no
```
It's a bit hidden in the manuals, but the manpage for status says "supports the same options as git-commit", so that's where you'd have to look. |
1384325 | In git, is there a simple way of introducing an unrelated branch to a repository? | 412 | 2009-09-05 21:41:45 | <p>While helping a friend with a git problem today, I had to introduce a
branch that needed to be totally separate from the <code>master</code> branch.
The contents of this branch really had a different origin from what
had been developed on the <code>master</code> branch, but they were going to be
merged into the <cod... | 136,446 | 72,344 | 2024-06-24 16:43:39 | 4,288,660 | 605 | 2010-11-26 21:33:05 | 137,188 | 2016-05-05 13:50:23 | https://stackoverflow.com/q/1384325 | https://stackoverflow.com/a/4288660 | <p>There is a new feature (since V1.7.2) which makes this task a little more high-level than what's in any of the other answers.</p>
<p><code>git checkout</code> now supports the <strong><code>--orphan</code></strong> option. From the <a href="https://www.kernel.org/pub/software/scm/git/docs/git-checkout.html" rel="no... | <p>There is a new feature (since V1.7.2) which makes this task a little more high-level than what's in any of the other answers.</p> <p><code>git checkout</code> now supports the <strong><code>--orphan</code></strong> option. From the <a href="https://www.kernel.org/pub/software/scm/git/docs/git-checkout.html" rel="no... | 119, 1879 | branch, git | <h1>In git, is there a simple way of introducing an unrelated branch to a repository?</h1>
<p>While helping a friend with a git problem today, I had to introduce a
branch that needed to be totally separate from the <code>master</code> branch.
The contents of this branch really had a different origin from what
had been ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,238 | git | # In git, is there a simple way of introducing an unrelated branch to a repository?
While helping a friend with a git problem today, I had to introduce a
branch that needed to be totally separate from the `master` branch.
The contents of this branch really had a different origin from what
had been developed on the `ma... | There is a new feature (since V1.7.2) which makes this task a little more high-level than what's in any of the other answers.
`git checkout` now supports the **`--orphan`** option. From the [man page](https://www.kernel.org/pub/software/scm/git/docs/git-checkout.html):
`git checkout [-q] [-f] [-m] --orphan <new_branc... |
4350678 | Git diff -w ignore whitespace only at start & end of lines | 532 | 2010-12-03 23:00:19 | <p>I love to use <code>git diff -w</code> to ignore whitespace differences. But, I just noticed that it ignores even whitespace differences in the middle of lines. How could I only ignore whitespace differences that come at the start (^) or end ($) of lines?</p>
| 244,319 | 242,933 | 2018-11-07 19:50:32 | 4,350,724 | 604 | 2010-12-03 23:06:11 | 138,290 | 2014-10-25 13:14:45 | https://stackoverflow.com/q/4350678 | https://stackoverflow.com/a/4350724 | <p>For end of line use:</p>
<pre><code>git diff --ignore-space-at-eol
</code></pre>
<p>Instead of what are you using currently:</p>
<pre><code>git diff -w (--ignore-all-space)
</code></pre>
<p>For start of line... you are out of luck if you want a built in solution.</p>
<p>However, if you don't mind getting your h... | <p>For end of line use:</p> <pre><code>git diff --ignore-space-at-eol </code></pre> <p>Instead of what are you using currently:</p> <pre><code>git diff -w (--ignore-all-space) </code></pre> <p>For start of line... you are out of luck if you want a built in solution.</p> <p>However, if you don't mind getting your h... | 119, 606, 1084, 4333 | diff, git, ignore, whitespace | <h1>Git diff -w ignore whitespace only at start & end of lines</h1>
<p>I love to use <code>git diff -w</code> to ignore whitespace differences. But, I just noticed that it ignores even whitespace differences in the middle of lines. How could I only ignore whitespace differences that come at the start (^) or end ($) of ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,239 | git | # Git diff -w ignore whitespace only at start & end of lines
I love to use `git diff -w` to ignore whitespace differences. But, I just noticed that it ignores even whitespace differences in the middle of lines. How could I only ignore whitespace differences that come at the start (^) or end ($) of lines? | For end of line use:
```
git diff --ignore-space-at-eol
```
Instead of what are you using currently:
```
git diff -w (--ignore-all-space)
```
For start of line... you are out of luck if you want a built in solution.
However, if you don't mind getting your hands dirty there's a rather old patch floating out there s... |
15551618 | Get the creation date of a stash | 389 | 2013-03-21 15:25:55 | <p>Is there a way to tell when a stash was created?</p>
<p><code>git stash list</code> only lists the stashes, and <code>git stash show XXXXXX</code> shows all the files and changes, but not the <strong>date</strong> of the stash creation.</p>
| 73,026 | 128,532 | 2016-08-15 15:29:12 | 15,551,690 | 603 | 2013-03-21 15:29:06 | 537,031 | 2013-03-21 15:29:06 | https://stackoverflow.com/q/15551618 | https://stackoverflow.com/a/15551690 | <p>Try:</p>
<pre><code>git stash list --date=local
</code></pre>
<p>It should print something like:</p>
<pre><code>stash@{Thu Mar 21 10:30:17 2013}: WIP on master: 2ffc05b Adding resource
</code></pre>
| <p>Try:</p> <pre><code>git stash list --date=local </code></pre> <p>It should print something like:</p> <pre><code>stash@{Thu Mar 21 10:30:17 2013}: WIP on master: 2ffc05b Adding resource </code></pre> | 119, 13091 | git, git-stash | <h1>Get the creation date of a stash</h1>
<p>Is there a way to tell when a stash was created?</p>
<p><code>git stash list</code> only lists the stashes, and <code>git stash show XXXXXX</code> shows all the files and changes, but not the <strong>date</strong> of the stash creation.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,240 | git | # Get the creation date of a stash
Is there a way to tell when a stash was created?
`git stash list` only lists the stashes, and `git stash show XXXXXX` shows all the files and changes, but not the **date** of the stash creation. | Try:
```
git stash list --date=local
```
It should print something like:
```
stash@{Thu Mar 21 10:30:17 2013}: WIP on master: 2ffc05b Adding resource
``` |
1307114 | How can I archive git branches? | 442 | 2009-08-20 15:49:30 | <p>I have some old branches in my git repository that are no longer under active development. I would like to archive the branches so that they don't show up by default when running <code>git branch -l -r</code>. I don't want to delete them, because I want to keep the history. How can I do this?</p>
<p>I know that it'... | 170,505 | 20,072 | 2024-10-03 17:28:57 | 1,309,934 | 602 | 2009-08-21 03:14:08 | 51,233 | 2012-05-01 14:43:47 | https://stackoverflow.com/q/1307114 | https://stackoverflow.com/a/1309934 | <p>I believe the proper way to do this is to tag the branch. If you delete the branch after you have tagged it then you've effectively kept the branch around but it won't clutter your branch list.</p>
<p>If you need to go back to the branch just check out the tag. It will effectively restore the branch from the tag.</... | <p>I believe the proper way to do this is to tag the branch. If you delete the branch after you have tagged it then you've effectively kept the branch around but it won't clutter your branch list.</p> <p>If you need to go back to the branch just check out the tag. It will effectively restore the branch from the tag.</... | 119 | git | <h1>How can I archive git branches?</h1>
<p>I have some old branches in my git repository that are no longer under active development. I would like to archive the branches so that they don't show up by default when running <code>git branch -l -r</code>. I don't want to delete them, because I want to keep the history. H... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,241 | git | # How can I archive git branches?
I have some old branches in my git repository that are no longer under active development. I would like to archive the branches so that they don't show up by default when running `git branch -l -r`. I don't want to delete them, because I want to keep the history. How can I do this?
I... | I believe the proper way to do this is to tag the branch. If you delete the branch after you have tagged it then you've effectively kept the branch around but it won't clutter your branch list.
If you need to go back to the branch just check out the tag. It will effectively restore the branch from the tag.
To archive... |
16606203 | Force git stash to overwrite added files | 375 | 2013-05-17 09:53:57 | <p>I have some files which were untracked in git. I made some changes and wanted to commit them, but realised I had forgotten to check in the unmodified files first. So I stashed the files, then added the unmodified versions. </p>
<p>Then when I apply the stash to the repository, I get conflicts due to the files ha... | 292,807 | 1,191,089 | 2023-07-13 14:34:38 | 16,625,128 | 601 | 2013-05-18 14:03:22 | 952,648 | 2023-03-15 11:09:15 | https://stackoverflow.com/q/16606203 | https://stackoverflow.com/a/16625128 | <p>Use <code>git checkout</code> instead of <code>git stash apply</code>.</p>
<p><strong>WARNING</strong>: The command below will restore all the files in the current directory (<code>.</code>) to their stashed version. If you have uncommitted or unstaged changes, they will be <strong>permanently lost</strong>:</p>
<ul... | <p>Use <code>git checkout</code> instead of <code>git stash apply</code>.</p> <p><strong>WARNING</strong>: The command below will restore all the files in the current directory (<code>.</code>) to their stashed version. If you have uncommitted or unstaged changes, they will be <strong>permanently lost</strong>:</p> <ul... | 119 | git | <h1>Force git stash to overwrite added files</h1>
<p>I have some files which were untracked in git. I made some changes and wanted to commit them, but realised I had forgotten to check in the unmodified files first. So I stashed the files, then added the unmodified versions. </p>
<p>Then when I apply the stash to t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,242 | git | # Force git stash to overwrite added files
I have some files which were untracked in git. I made some changes and wanted to commit them, but realised I had forgotten to check in the unmodified files first. So I stashed the files, then added the unmodified versions.
Then when I apply the stash to the repository, I get... | Use `git checkout` instead of `git stash apply`.
**WARNING**: The command below will restore all the files in the current directory (`.`) to their stashed version. If you have uncommitted or unstaged changes, they will be **permanently lost**:
- If you edited files after creating the stash, those changes will be lost... |
37420642 | How to undo the last commit in git | 279 | 2016-05-24 17:55:21 | <p>By mistake, I did <code>git add .</code> and <code>git commit</code> in the <code>develop</code> branch. But luckily, I did not do <code>git push</code>.</p>
<p>So I wanted to revert it back to original state.</p>
<p>I tried <code>git reset --soft</code> and <code>git reset HEAD --hard</code> but looks like I have... | 343,461 | 1,479,974 | 2020-08-21 01:33:22 | 37,420,765 | 601 | 2016-05-24 18:02:19 | 1,105,871 | 2016-05-24 18:02:19 | https://stackoverflow.com/q/37420642 | https://stackoverflow.com/a/37420765 | <p>I think you haven't messed up yet. Try:</p>
<pre><code>git reset HEAD^
</code></pre>
<p>This will bring the dir to state before you've made the commit, <code>HEAD^</code> means the parent of the current commit (the one you don't want anymore), while keeping changes from it (unstaged).</p>
| <p>I think you haven't messed up yet. Try:</p> <pre><code>git reset HEAD^ </code></pre> <p>This will bring the dir to state before you've made the commit, <code>HEAD^</code> means the parent of the current commit (the one you don't want anymore), while keeping changes from it (unstaged).</p> | 119, 34403, 51381, 53850 | git, git-commit, git-reset, git-revert | <h1>How to undo the last commit in git</h1>
<p>By mistake, I did <code>git add .</code> and <code>git commit</code> in the <code>develop</code> branch. But luckily, I did not do <code>git push</code>.</p>
<p>So I wanted to revert it back to original state.</p>
<p>I tried <code>git reset --soft</code> and <code>git re... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,243 | git | # How to undo the last commit in git
By mistake, I did `git add .` and `git commit` in the `develop` branch. But luckily, I did not do `git push`.
So I wanted to revert it back to original state.
I tried `git reset --soft` and `git reset HEAD --hard` but looks like I have messed it up.
How do I fix this? I want to ... | I think you haven't messed up yet. Try:
```
git reset HEAD^
```
This will bring the dir to state before you've made the commit, `HEAD^` means the parent of the current commit (the one you don't want anymore), while keeping changes from it (unstaged). |
849308 | How can I pull/push from multiple remote locations? | 901 | 2009-05-11 18:07:37 | <p><strong>The short:</strong> is there a way to have a git repo push to and pull from a list of remote repos (rather than a single "origin")?</p>
<p><strong>The long:</strong> I'm developing an app in multiple computers, with different connectivity – my laptop might have connectivity with only either compute... | 473,407 | 98,003 | 2026-01-01 03:02:27 | 849,960 | 599 | 2009-05-11 20:34:26 | 85,134 | 2020-04-19 17:38:10 | https://stackoverflow.com/q/849308 | https://stackoverflow.com/a/849960 | <p>You can configure multiple remote repositories with the <code>git remote</code> command:</p>
<pre><code>git remote add alt alt-machine:/path/to/repo
</code></pre>
<p>To fetch from all the configured remotes and update tracking branches, but not merge into <code>HEAD</code>, do:</p>
<pre><code>git remote update
</... | <p>You can configure multiple remote repositories with the <code>git remote</code> command:</p> <pre><code>git remote add alt alt-machine:/path/to/repo </code></pre> <p>To fetch from all the configured remotes and update tracking branches, but not merge into <code>HEAD</code>, do:</p> <pre><code>git remote update </... | 119 | git | <h1>How can I pull/push from multiple remote locations?</h1>
<p><strong>The short:</strong> is there a way to have a git repo push to and pull from a list of remote repos (rather than a single "origin")?</p>
<p><strong>The long:</strong> I'm developing an app in multiple computers, with different connectivity... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,244 | git | # How can I pull/push from multiple remote locations?
**The short:** is there a way to have a git repo push to and pull from a list of remote repos (rather than a single "origin")?
**The long:** I'm developing an app in multiple computers, with different connectivity – my laptop might have connectivity with only eith... | You can configure multiple remote repositories with the `git remote` command:
```
git remote add alt alt-machine:/path/to/repo
```
To fetch from all the configured remotes and update tracking branches, but not merge into `HEAD`, do:
```
git remote update
```
If it's not currently connected to one of the remotes, it... |
449541 | How can I selectively merge or pick changes from another branch in Git? | 1,852 | 2009-01-16 04:55:08 | <p>I'm using Git on a new project that has two parallel -- but currently experimental -- development branches:</p>
<ul>
<li><code>master</code>: import of existing codebase plus a few modifications that I'm generally sure of</li>
<li><code>exp1</code>: experimental branch #1</li>
<li><code>exp2</code>: experimental bra... | 1,245,043 | 1,146 | 2025-09-05 10:57:23 | 449,632 | 588 | 2009-01-16 06:01:26 | 3,146 | 2022-08-27 09:46:00 | https://stackoverflow.com/q/449541 | https://stackoverflow.com/a/449632 | <p>You use the <a href="https://git-scm.com/docs/git-cherry-pick" rel="noreferrer">cherry-pick</a> command to get individual commits from one branch.</p>
<p>If the change(s) you want are not in individual commits, then use the method shown here to <a href="http://plasmasturm.org/log/530/" rel="noreferrer">split the com... | <p>You use the <a href="https://git-scm.com/docs/git-cherry-pick" rel="noreferrer">cherry-pick</a> command to get individual commits from one branch.</p> <p>If the change(s) you want are not in individual commits, then use the method shown here to <a href="http://plasmasturm.org/log/530/" rel="noreferrer">split the com... | 119, 28897, 62078, 78810 | git, git-cherry-pick, git-merge, git-patch | <h1>How can I selectively merge or pick changes from another branch in Git?</h1>
<p>I'm using Git on a new project that has two parallel -- but currently experimental -- development branches:</p>
<ul>
<li><code>master</code>: import of existing codebase plus a few modifications that I'm generally sure of</li>
<li><code... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,246 | git | # How can I selectively merge or pick changes from another branch in Git?
I'm using Git on a new project that has two parallel -- but currently experimental -- development branches:
- `master`: import of existing codebase plus a few modifications that I'm generally sure of
- `exp1`: experimental branch #1
- `exp2`: e... | You use the [cherry-pick](https://git-scm.com/docs/git-cherry-pick) command to get individual commits from one branch.
If the change(s) you want are not in individual commits, then use the method shown here to [split the commit into individual commits](http://plasmasturm.org/log/530/). Roughly speaking, you use `git r... |
9589814 | How do I force git pull to overwrite everything on every pull? | 235 | 2012-03-06 18:36:28 | <p>I have a CENTRAL bare repository that has three developer repositories pulling and pushing to it normally.</p>
<p>I also have two other repositories that pull from the CENTRAL bare repo: one is the live server, and the other is a test/stage server—each pulling from its own respective branch.</p>
<p>The scenario is... | 422,784 | 400,265 | 2017-05-31 09:28:34 | 9,589,927 | 588 | 2012-03-06 18:45:17 | 148,870 | 2012-03-07 19:40:14 | https://stackoverflow.com/q/9589814 | https://stackoverflow.com/a/9589927 | <p>Really the ideal way to do this is to not use <code>pull</code> at all, but instead <code>fetch</code> and <code>reset</code>:</p>
<pre><code>git fetch origin master
git reset --hard FETCH_HEAD
git clean -df
</code></pre>
<p>(Altering <code>master</code> to whatever branch you want to be following.)</p>
<p><code>... | <p>Really the ideal way to do this is to not use <code>pull</code> at all, but instead <code>fetch</code> and <code>reset</code>:</p> <pre><code>git fetch origin master git reset --hard FETCH_HEAD git clean -df </code></pre> <p>(Altering <code>master</code> to whatever branch you want to be following.)</p> <p><code>... | 119, 28896 | git, git-pull | <h1>How do I force git pull to overwrite everything on every pull?</h1>
<p>I have a CENTRAL bare repository that has three developer repositories pulling and pushing to it normally.</p>
<p>I also have two other repositories that pull from the CENTRAL bare repo: one is the live server, and the other is a test/stage ser... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,247 | git | # How do I force git pull to overwrite everything on every pull?
I have a CENTRAL bare repository that has three developer repositories pulling and pushing to it normally.
I also have two other repositories that pull from the CENTRAL bare repo: one is the live server, and the other is a test/stage server—each pulling... | Really the ideal way to do this is to not use `pull` at all, but instead `fetch` and `reset`:
```
git fetch origin master
git reset --hard FETCH_HEAD
git clean -df
```
(Altering `master` to whatever branch you want to be following.)
`pull` is designed around merging changes together in some way, whereas `reset` is d... |
22082307 | git switch branch without discarding local changes | 371 | 2014-02-27 22:47:05 | <p>Alright, lets say one day we make happen to make a bunch of modifications and when we go to commit them we notice we were working on the wrong branch.</p>
<p>How can we force git to switch branches <strong>without discarding local changes</strong>.</p>
<p>I'm probably going to go about this in a naive way while I ... | 352,146 | 1,517,919 | 2025-11-03 17:26:25 | 22,082,669 | 586 | 2014-02-27 23:08:33 | 1,256,452 | 2025-11-03 17:26:25 | https://stackoverflow.com/q/22082307 | https://stackoverflow.com/a/22082669 | <p>There are a bunch of different ways depending on how far along you are and which branch(es) you want them on.</p>
<p>Let's take a classic mistake:</p>
<pre><code>$ git checkout master
... pause for coffee, etc ...
... return, edit a bunch of stuff, then: oops, wanted to be on develop
</code></pre>
<p>So now you want... | <p>There are a bunch of different ways depending on how far along you are and which branch(es) you want them on.</p> <p>Let's take a classic mistake:</p> <pre><code>$ git checkout master ... pause for coffee, etc ... ... return, edit a bunch of stuff, then: oops, wanted to be on develop </code></pre> <p>So now you want... | 119, 76220 | git, git-branch | <h1>git switch branch without discarding local changes</h1>
<p>Alright, lets say one day we make happen to make a bunch of modifications and when we go to commit them we notice we were working on the wrong branch.</p>
<p>How can we force git to switch branches <strong>without discarding local changes</strong>.</p>
<p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,248 | git | # git switch branch without discarding local changes
Alright, lets say one day we make happen to make a bunch of modifications and when we go to commit them we notice we were working on the wrong branch.
How can we force git to switch branches **without discarding local changes**.
I'm probably going to go about this... | There are a bunch of different ways depending on how far along you are and which branch(es) you want them on.
Let's take a classic mistake:
```
$ git checkout master
... pause for coffee, etc ...
... return, edit a bunch of stuff, then: oops, wanted to be on develop
```
So now you want these changes, which you have ... |
5542910 | How do I "commit" changes in a git submodule? | 368 | 2011-04-04 18:51:54 | <p>I have, in my naivety, set up a git submodule and treated it like a Subversion external - i.e. it's now full of changes that I've just realized haven't been committed or pushed anywhere.</p>
<p>Is there some easy way to commit/push the submodule changes back to the upstream repo? And what's the recommended techniqu... | 351,167 | 5,017 | 2019-06-21 07:09:46 | 5,542,964 | 586 | 2011-04-04 18:58:01 | 172,588 | 2019-06-21 07:09:46 | https://stackoverflow.com/q/5542910 | https://stackoverflow.com/a/5542964 | <p>A <strong><em>submodule</em></strong> is its own <strong><em>repo/work-area</em></strong>, with its own <code>.git</code> directory.</p>
<p>So, first <code>commit/push</code> your <strong><em>submodule's</em></strong> changes:</p>
<pre class="lang-sh prettyprint-override"><code>$ cd path/to/submodule
$ git add <... | <p>A <strong><em>submodule</em></strong> is its own <strong><em>repo/work-area</em></strong>, with its own <code>.git</code> directory.</p> <p>So, first <code>commit/push</code> your <strong><em>submodule's</em></strong> changes:</p> <pre class="lang-sh prettyprint-override"><code>$ cd path/to/submodule $ git add <... | 119, 41612 | git, git-submodules | <h1>How do I "commit" changes in a git submodule?</h1>
<p>I have, in my naivety, set up a git submodule and treated it like a Subversion external - i.e. it's now full of changes that I've just realized haven't been committed or pushed anywhere.</p>
<p>Is there some easy way to commit/push the submodule changes back to... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,249 | git | # How do I "commit" changes in a git submodule?
I have, in my naivety, set up a git submodule and treated it like a Subversion external - i.e. it's now full of changes that I've just realized haven't been committed or pushed anywhere.
Is there some easy way to commit/push the submodule changes back to the upstream re... | A ***submodule*** is its own ***repo/work-area***, with its own `.git` directory.
So, first `commit/push` your ***submodule's*** changes:
```
$ cd path/to/submodule
$ git add <stuff>
$ git commit -m "comment"
$ git push
```
Then, update your ***main project*** to track the updated version of the ***submodule***:
``... |
12276001 | Find unmerged Git branches? | 344 | 2012-09-05 06:53:44 | <p>I have a Git repository with many branches, some of them already merged and some not. Since the number of branches is quite large, how can I determine which branches have not yet been merged? I would like to avoid having to do an "octopus" merge and re-merging branches that have already been merged.</p>
| 95,111 | 1,126,126 | 2023-04-06 00:23:06 | 12,276,041 | 585 | 2012-09-05 06:57:15 | 148,870 | 2015-01-09 20:05:27 | https://stackoverflow.com/q/12276001 | https://stackoverflow.com/a/12276041 | <p>Try this:</p>
<pre><code>git branch --merged master
</code></pre>
<p>It does what it says on the tin (lists branches which have been merged into <code>master</code>). You can also pull up the inverse with:</p>
<pre><code>git branch --no-merged master
</code></pre>
<p>If you don't specify <code>master</code>, e.g... | <p>Try this:</p> <pre><code>git branch --merged master </code></pre> <p>It does what it says on the tin (lists branches which have been merged into <code>master</code>). You can also pull up the inverse with:</p> <pre><code>git branch --no-merged master </code></pre> <p>If you don't specify <code>master</code>, e.g... | 119, 28897, 53847 | branching-and-merging, git, git-merge | <h1>Find unmerged Git branches?</h1>
<p>I have a Git repository with many branches, some of them already merged and some not. Since the number of branches is quite large, how can I determine which branches have not yet been merged? I would like to avoid having to do an "octopus" merge and re-merging branches that have ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,250 | git | # Find unmerged Git branches?
I have a Git repository with many branches, some of them already merged and some not. Since the number of branches is quite large, how can I determine which branches have not yet been merged? I would like to avoid having to do an "octopus" merge and re-merging branches that have already b... | Try this:
```
git branch --merged master
```
It does what it says on the tin (lists branches which have been merged into `master`). You can also pull up the inverse with:
```
git branch --no-merged master
```
If you don't specify `master`, e.g...
```
git branch --merged
```
then it will show you branches which ha... |
38206196 | merge one local branch into another local branch | 464 | 2016-07-05 14:35:43 | <p>I have multiple branches which are branched off the master (each in a separate subdirectory).</p>
<ul>
<li>newdevBranch: new development, not yet completely finished</li>
<li>hotFixBranch: hotfix for a problem, but still under test</li>
<li>messAroundBranch: mess around branch, which I will not restore</li>
</ul>
<p... | 1,117,917 | 1,750,498 | 2025-01-14 08:16:47 | 38,206,292 | 584 | 2016-07-05 14:39:38 | 2,029,132 | 2025-01-14 08:16:47 | https://stackoverflow.com/q/38206196 | https://stackoverflow.com/a/38206292 | <ul>
<li><code>newdevBranch</code>: new development, not yet completely finished</li>
<li><code>hotFixBranch</code>: hotfix for a problem, but still under test</li>
<li><code>messAroundBranch</code>: mess around branch, which I will not restore</li>
</ul>
<p>First, checkout to your <code>messAroundBranch</code>:</p>
<p... | <ul> <li><code>newdevBranch</code>: new development, not yet completely finished</li> <li><code>hotFixBranch</code>: hotfix for a problem, but still under test</li> <li><code>messAroundBranch</code>: mess around branch, which I will not restore</li> </ul> <p>First, checkout to your <code>messAroundBranch</code>:</p> <p... | 119, 717 | git, merge | <h1>merge one local branch into another local branch</h1>
<p>I have multiple branches which are branched off the master (each in a separate subdirectory).</p>
<ul>
<li>newdevBranch: new development, not yet completely finished</li>
<li>hotFixBranch: hotfix for a problem, but still under test</li>
<li>messAroundBranch: ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,251 | git | # merge one local branch into another local branch
I have multiple branches which are branched off the master (each in a separate subdirectory).
- newdevBranch: new development, not yet completely finished
- hotFixBranch: hotfix for a problem, but still under test
- messAroundBranch: mess around branch, which I will ... | - `newdevBranch`: new development, not yet completely finished
- `hotFixBranch`: hotfix for a problem, but still under test
- `messAroundBranch`: mess around branch, which I will not restore
First, checkout to your `messAroundBranch`:
```
git checkout messAroundBranch
```
Then merge the `newdevBranch` into `messArou... |
3949804 | Force overwrite of local file with what's in origin repo? | 303 | 2010-10-16 16:50:05 | <p>I want to get the latest file that's in the repository, and overwrite what I have locally. How can I do this with the git client?</p>
| 406,807 | 39,677 | 2023-07-12 18:53:28 | 3,949,809 | 584 | 2010-10-16 16:52:31 | 148,870 | 2023-07-12 18:53:28 | https://stackoverflow.com/q/3949804 | https://stackoverflow.com/a/3949809 | <p>If you want to overwrite only one file:</p>
<pre><code>git fetch
git checkout origin/main <filepath>
</code></pre>
<p>If you want to overwrite <em>all</em> changed files:</p>
<pre><code>git fetch
git reset --hard origin/main
</code></pre>
<p>(This assumes that you're working on <code>main</code> locally and yo... | <p>If you want to overwrite only one file:</p> <pre><code>git fetch git checkout origin/main <filepath> </code></pre> <p>If you want to overwrite <em>all</em> changed files:</p> <pre><code>git fetch git reset --hard origin/main </code></pre> <p>(This assumes that you're working on <code>main</code> locally and yo... | 119 | git | <h1>Force overwrite of local file with what's in origin repo?</h1>
<p>I want to get the latest file that's in the repository, and overwrite what I have locally. How can I do this with the git client?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,252 | git | # Force overwrite of local file with what's in origin repo?
I want to get the latest file that's in the repository, and overwrite what I have locally. How can I do this with the git client? | If you want to overwrite only one file:
```
git fetch
git checkout origin/main <filepath>
```
If you want to overwrite *all* changed files:
```
git fetch
git reset --hard origin/main
```
(This assumes that you're working on `main` locally and you want the changes on the origin's `main` - if you're on a branch, or y... |
3368590 | Show diff between commits | 493 | 2010-07-30 03:49:01 | <p>I am using Git on <a href="https://en.wikipedia.org/wiki/Ubuntu_version_history#Ubuntu_10.04_LTS_.28Lucid_Lynx.29" rel="noreferrer">Ubuntu 10.04</a> (Lucid Lynx).</p>
<p>I have made some commits to my master.</p>
<p>However, I want to get the difference between these commits. All of them are on my master bran... | 723,605 | 70,942 | 2025-09-23 05:39:18 | 3,368,758 | 581 | 2010-07-30 04:47:43 | 6,309 | 2025-09-23 05:39:18 | https://stackoverflow.com/q/3368590 | https://stackoverflow.com/a/3368758 | <p>Try</p>
<pre><code>git diff k73ud^..dj374
</code></pre>
<p>to make sure to include all changes of <code>k73ud</code> in the resulting diff.</p>
<p><a href="https://git-scm.com/docs/git-diff" rel="noreferrer"><code>git diff</code></a> compares two endpoints (<a href="https://stackoverflow.com/a/7256391/6309">instead ... | <p>Try</p> <pre><code>git diff k73ud^..dj374 </code></pre> <p>to make sure to include all changes of <code>k73ud</code> in the resulting diff.</p> <p><a href="https://git-scm.com/docs/git-diff" rel="noreferrer"><code>git diff</code></a> compares two endpoints (<a href="https://stackoverflow.com/a/7256391/6309">instead ... | 119, 9033 | git, git-diff | <h1>Show diff between commits</h1>
<p>I am using Git on <a href="https://en.wikipedia.org/wiki/Ubuntu_version_history#Ubuntu_10.04_LTS_.28Lucid_Lynx.29" rel="noreferrer">Ubuntu 10.04</a> (Lucid Lynx).</p>
<p>I have made some commits to my master.</p>
<p>However, I want to get the difference between these commits... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,253 | git | # Show diff between commits
I am using Git on [Ubuntu 10.04](https://en.wikipedia.org/wiki/Ubuntu_version_history#Ubuntu_10.04_LTS_.28Lucid_Lynx.29) (Lucid Lynx).
I have made some commits to my master.
However, I want to get the difference between these commits. All of them are on my master branch.
For example:
``... | Try
```
git diff k73ud^..dj374
```
to make sure to include all changes of `k73ud` in the resulting diff.
[`git diff`](https://git-scm.com/docs/git-diff) compares two endpoints ([instead of a commit range](https://stackoverflow.com/a/7256391/6309)).
Since the OP wants to see the changes introduced by `k73ud`, they ne... |
1889559 | Make 'git diff' ignore ^M | 726 | 2009-12-11 17:23:49 | <p>In a project where some of the files contain <code>^M</code> as newline
separators, diffing these files is apparently impossible, since
<code>git diff</code> sees the entire file as just a single line.</p>
<p>How does one <code>git diff</code> when comparing the current and previous
versions of a source code file?</... | 556,647 | 78,336 | 2025-07-14 06:49:48 | 1,889,699 | 580 | 2009-12-11 17:43:44 | 52,573 | 2025-06-06 15:02:29 | https://stackoverflow.com/q/1889559 | https://stackoverflow.com/a/1889699 | <p><a href="https://help.github.com/articles/dealing-with-line-endings/" rel="noreferrer">GitHub suggests</a> that you should make sure to only use \n as a newline character in git-handled repos. There's an option to auto-convert:</p>
<pre class="lang-bash prettyprint-override"><code>$ git config --global core.autocrlf... | <p><a href="https://help.github.com/articles/dealing-with-line-endings/" rel="noreferrer">GitHub suggests</a> that you should make sure to only use \n as a newline character in git-handled repos. There's an option to auto-convert:</p> <pre class="lang-bash prettyprint-override"><code>$ git config --global core.autocrlf... | 119, 606, 3705, 9033, 14899 | carriage-return, diff, git, git-diff, newline | <h1>Make 'git diff' ignore ^M</h1>
<p>In a project where some of the files contain <code>^M</code> as newline
separators, diffing these files is apparently impossible, since
<code>git diff</code> sees the entire file as just a single line.</p>
<p>How does one <code>git diff</code> when comparing the current and previou... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,254 | git | # Make 'git diff' ignore ^M
In a project where some of the files contain `^M` as newline
separators, diffing these files is apparently impossible, since
`git diff` sees the entire file as just a single line.
How does one `git diff` when comparing the current and previous
versions of a source code file?
Is there an o... | [GitHub suggests](https://help.github.com/articles/dealing-with-line-endings/) that you should make sure to only use \n as a newline character in git-handled repos. There's an option to auto-convert:
```
$ git config --global core.autocrlf true
```
Of course, this is said to convert crlf to lf, while you want to conv... |
2231546 | Git: See my last commit | 637 | 2010-02-09 18:42:54 | <p>I just want to see the files that were committed in the last commit exactly as I saw the list when I did <code>git commit</code>. Unfortunately searching for</p>
<pre><code>git "last commit" log
</code></pre>
<p>in Google gets me nowhere. And </p>
<pre><code>git diff HEAD^..HEAD
</code></pre>
<p>is not what I ne... | 803,533 | 8,047 | 2025-02-15 19:07:43 | 2,232,490 | 578 | 2010-02-09 21:02:19 | 149,170 | 2013-04-09 03:34:18 | https://stackoverflow.com/q/2231546 | https://stackoverflow.com/a/2232490 | <p>As determined via comments, it appears that the OP is looking for</p>
<pre><code>$ git log --name-status HEAD^..HEAD
</code></pre>
<p>This is also very close to the output you'd get from <code>svn status</code> or <code>svn log -v</code>, which many people coming from subversion to git are familiar with.</p>
<p><... | <p>As determined via comments, it appears that the OP is looking for</p> <pre><code>$ git log --name-status HEAD^..HEAD </code></pre> <p>This is also very close to the output you'd get from <code>svn status</code> or <code>svn log -v</code>, which many people coming from subversion to git are familiar with.</p> <p><... | 119 | git | <h1>Git: See my last commit</h1>
<p>I just want to see the files that were committed in the last commit exactly as I saw the list when I did <code>git commit</code>. Unfortunately searching for</p>
<pre><code>git "last commit" log
</code></pre>
<p>in Google gets me nowhere. And </p>
<pre><code>git diff HEAD^..HEAD
<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,256 | git | # Git: See my last commit
I just want to see the files that were committed in the last commit exactly as I saw the list when I did `git commit`. Unfortunately searching for
```
git "last commit" log
```
in Google gets me nowhere. And
```
git diff HEAD^..HEAD
```
is not what I need, of course, since it spews the gu... | As determined via comments, it appears that the OP is looking for
```
$ git log --name-status HEAD^..HEAD
```
This is also very close to the output you'd get from `svn status` or `svn log -v`, which many people coming from subversion to git are familiar with.
`--name-status` is the key here; as noted by other folks ... |
4298960 | Git add and commit in one command | 622 | 2010-11-28 20:40:39 | <p>Is there any way I can do</p>
<pre><code>git add -A
git commit -m "commit message"
</code></pre>
<p>in one command? </p>
<p>I seem to be doing those two commands a lot, and if Git had an option like <code>git commit -Am "commit message"</code>, it would make life that much more convenient.</p>
<p><code>git commi... | 641,790 | 238,030 | 2025-04-21 13:54:18 | 4,299,159 | 577 | 2010-11-28 21:23:46 | 19,246 | 2024-10-06 01:15:56 | https://stackoverflow.com/q/4298960 | https://stackoverflow.com/a/4299159 | <p>You can use <a href="https://git-scm.com/book/ms/v2/Git-Basics-Git-Aliases" rel="noreferrer"><strong>Git Aliases</strong></a>, e.g.</p>
<pre class="lang-sh prettyprint-override"><code>git config --global alias.add-commit '!git add -A && git commit'
</code></pre>
<p>and use it with</p>
<pre class="lang-sh pr... | <p>You can use <a href="https://git-scm.com/book/ms/v2/Git-Basics-Git-Aliases" rel="noreferrer"><strong>Git Aliases</strong></a>, e.g.</p> <pre class="lang-sh prettyprint-override"><code>git config --global alias.add-commit '!git add -A && git commit' </code></pre> <p>and use it with</p> <pre class="lang-sh pr... | 119, 34792, 53850 | git, git-add, git-commit | <h1>Git add and commit in one command</h1>
<p>Is there any way I can do</p>
<pre><code>git add -A
git commit -m "commit message"
</code></pre>
<p>in one command? </p>
<p>I seem to be doing those two commands a lot, and if Git had an option like <code>git commit -Am "commit message"</code>, it would make life that mu... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,258 | git | # Git add and commit in one command
Is there any way I can do
```
git add -A
git commit -m "commit message"
```
in one command?
I seem to be doing those two commands a lot, and if Git had an option like `git commit -Am "commit message"`, it would make life that much more convenient.
`git commit` has the `-a` modif... | You can use [**Git Aliases**](https://git-scm.com/book/ms/v2/Git-Basics-Git-Aliases), e.g.
```
git config --global alias.add-commit '!git add -A && git commit'
```
and use it with
```
git add-commit -m 'My commit message'
```
---
## NOTE
- On Linux one should use *single quotes* when adding an *alias*, as otherwi... |
15316601 | In what cases could `git pull` be harmful? | 441 | 2013-03-09 22:23:10 | <p>I have a colleague who claims that <code>git pull</code> is harmful, and gets upset whenever someone uses it.</p>
<p>The <code>git pull</code> command seems to be the canonical way to update your local repository. Does using <code>git pull</code> create problems? What problems does it create? Is there a better way... | 108,954 | 712,605 | 2019-08-13 21:56:58 | 15,316,602 | 577 | 2013-03-09 22:23:10 | 712,605 | 2019-01-09 16:21:44 | https://stackoverflow.com/q/15316601 | https://stackoverflow.com/a/15316602 | <h2>Summary</h2>
<p>By default, <code>git pull</code> creates merge commits which add noise and complexity to the code history. In addition, <code>pull</code> makes it easy to not think about how your changes might be affected by incoming changes.</p>
<p>The <code>git pull</code> command is safe so long as it only p... | <h2>Summary</h2> <p>By default, <code>git pull</code> creates merge commits which add noise and complexity to the code history. In addition, <code>pull</code> makes it easy to not think about how your changes might be affected by incoming changes.</p> <p>The <code>git pull</code> command is safe so long as it only p... | 119, 28896 | git, git-pull | <h1>In what cases could `git pull` be harmful?</h1>
<p>I have a colleague who claims that <code>git pull</code> is harmful, and gets upset whenever someone uses it.</p>
<p>The <code>git pull</code> command seems to be the canonical way to update your local repository. Does using <code>git pull</code> create problems?... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,259 | git | # In what cases could `git pull` be harmful?
I have a colleague who claims that `git pull` is harmful, and gets upset whenever someone uses it.
The `git pull` command seems to be the canonical way to update your local repository. Does using `git pull` create problems? What problems does it create? Is there a better w... | ## Summary
By default, `git pull` creates merge commits which add noise and complexity to the code history. In addition, `pull` makes it easy to not think about how your changes might be affected by incoming changes.
The `git pull` command is safe so long as it only performs fast-forward merges. If `git pull` is conf... |
18137175 | In Git, what is the difference between origin/master vs origin master? | 436 | 2013-08-08 22:20:59 | <p>I know, <strong>origin</strong> is a term for the remote repository and <strong>master</strong> is the branch there.</p>
<p>I am purposely omitting the "context" here and I am hoping that the answer should not depend upon the context. So in git command lines, what is the difference between <strong>origin/master</st... | 339,781 | 18,852 | 2024-05-22 16:57:22 | 18,137,512 | 576 | 2013-08-08 22:46:35 | 82,294 | 2021-12-10 19:13:54 | https://stackoverflow.com/q/18137175 | https://stackoverflow.com/a/18137512 | <p>(<strong>Note:</strong> When this question was originally posted, "master" was the default name for branches in Git. Since "main" is now the default name, this answer has been updated to use "main", in the hope that this will be more natural for people new to Git.)</p>
<p>There are actu... | <p>(<strong>Note:</strong> When this question was originally posted, "master" was the default name for branches in Git. Since "main" is now the default name, this answer has been updated to use "main", in the hope that this will be more natural for people new to Git.)</p> <p>There are actu... | 119 | git | <h1>In Git, what is the difference between origin/master vs origin master?</h1>
<p>I know, <strong>origin</strong> is a term for the remote repository and <strong>master</strong> is the branch there.</p>
<p>I am purposely omitting the "context" here and I am hoping that the answer should not depend upon the context. S... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,260 | git | # In Git, what is the difference between origin/master vs origin master?
I know, **origin** is a term for the remote repository and **master** is the branch there.
I am purposely omitting the "context" here and I am hoping that the answer should not depend upon the context. So in git command lines, what is the differ... | (**Note:** When this question was originally posted, "master" was the default name for branches in Git. Since "main" is now the default name, this answer has been updated to use "main", in the hope that this will be more natural for people new to Git.)
There are actually three things here: `origin main` is two separat... |
11801071 | How to return from 'detached HEAD' state? | 371 | 2012-08-03 18:11:08 | <p>If one would checkout a branch:</p>
<pre><code>git checkout 760ac7e
</code></pre>
<p>from e.g. <code>b9ac70b</code>, how can one go back to the last known head <code>b9ac70b</code> without knowing its SHA1?</p>
| 231,862 | 359,862 | 2024-10-31 18:25:24 | 11,801,199 | 574 | 2012-08-03 18:20:13 | 520,162 | 2016-01-25 18:32:39 | https://stackoverflow.com/q/11801071 | https://stackoverflow.com/a/11801199 | <p>If you remember which branch was checked out before (e.g. <code>master</code>) you could simply</p>
<pre><code>git checkout master
</code></pre>
<p>to get out of <em>detached HEAD</em> state.</p>
<p>Generally speaking: <code>git checkout <branchname></code> will get you out of that.</p>
<p>If you don't rem... | <p>If you remember which branch was checked out before (e.g. <code>master</code>) you could simply</p> <pre><code>git checkout master </code></pre> <p>to get out of <em>detached HEAD</em> state.</p> <p>Generally speaking: <code>git checkout <branchname></code> will get you out of that.</p> <p>If you don't rem... | 119 | git | <h1>How to return from 'detached HEAD' state?</h1>
<p>If one would checkout a branch:</p>
<pre><code>git checkout 760ac7e
</code></pre>
<p>from e.g. <code>b9ac70b</code>, how can one go back to the last known head <code>b9ac70b</code> without knowing its SHA1?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,261 | git | # How to return from 'detached HEAD' state?
If one would checkout a branch:
```
git checkout 760ac7e
```
from e.g. `b9ac70b`, how can one go back to the last known head `b9ac70b` without knowing its SHA1? | If you remember which branch was checked out before (e.g. `master`) you could simply
```
git checkout master
```
to get out of *detached HEAD* state.
Generally speaking: `git checkout <branchname>` will get you out of that.
If you don't remember the last branch name, try
```
git checkout -
```
This also tries to ... |
32384473 | .gitignore not ignoring .idea path | 238 | 2015-09-03 20:01:57 | <p>What am I missing that needs to be done in order to get <code>git</code> to ignore my <code>.idea/</code> path?</p>
<pre><code>ctote@ubuntu:~/dev/1$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be com... | 157,518 | 1,143,724 | 2022-08-17 05:19:53 | 32,384,542 | 573 | 2015-09-03 20:06:15 | 390,819 | 2015-09-03 20:12:15 | https://stackoverflow.com/q/32384473 | https://stackoverflow.com/a/32384542 | <p><code>.gitignore</code> only ignores newly added (untracked) files.</p>
<p>If you have files that have already been added to the repository, all their changes will be tracked as usual, even if they are matched by .gitignore rules.</p>
<p>To remove that folder from the repository (without deleting it from disk), do... | <p><code>.gitignore</code> only ignores newly added (untracked) files.</p> <p>If you have files that have already been added to the repository, all their changes will be tracked as usual, even if they are matched by .gitignore rules.</p> <p>To remove that folder from the repository (without deleting it from disk), do... | 119, 25056 | git, gitignore | <h1>.gitignore not ignoring .idea path</h1>
<p>What am I missing that needs to be done in order to get <code>git</code> to ignore my <code>.idea/</code> path?</p>
<pre><code>ctote@ubuntu:~/dev/1$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,262 | git | # .gitignore not ignoring .idea path
What am I missing that needs to be done in order to get `git` to ignore my `.idea/` path?
```
ctote@ubuntu:~/dev/1$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committ... | `.gitignore` only ignores newly added (untracked) files.
If you have files that have already been added to the repository, all their changes will be tracked as usual, even if they are matched by .gitignore rules.
To remove that folder from the repository (without deleting it from disk), do:
```
git rm --cached -r .i... |
1094269 | What's the purpose of git mv? | 435 | 2009-07-07 19:22:06 | <p>From what I understand, Git doesn't really need to track <em>file</em> rename/move/copy operations, so what's the real purpose
of <a href="https://git-scm.com/docs/git-mv" rel="noreferrer"><code>git mv</code></a>? The man page isn't particularly descriptive...</p>
<p>Is it obsolete? Is it an internal command, not me... | 227,351 | 21,239 | 2025-10-04 14:38:14 | 1,094,392 | 572 | 2009-07-07 19:42:06 | 19,563 | 2009-07-07 19:42:06 | https://stackoverflow.com/q/1094269 | https://stackoverflow.com/a/1094392 | <pre><code>git mv oldname newname
</code></pre>
<p>is just shorthand for:</p>
<pre><code>mv oldname newname
git add newname
git rm oldname
</code></pre>
<p>i.e. it updates the index for both old and new paths automatically.</p>
| <pre><code>git mv oldname newname </code></pre> <p>is just shorthand for:</p> <pre><code>mv oldname newname git add newname git rm oldname </code></pre> <p>i.e. it updates the index for both old and new paths automatically.</p> | 119, 112902 | git, git-mv | <h1>What's the purpose of git mv?</h1>
<p>From what I understand, Git doesn't really need to track <em>file</em> rename/move/copy operations, so what's the real purpose
of <a href="https://git-scm.com/docs/git-mv" rel="noreferrer"><code>git mv</code></a>? The man page isn't particularly descriptive...</p>
<p>Is it obso... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,263 | git | # What's the purpose of git mv?
From what I understand, Git doesn't really need to track *file* rename/move/copy operations, so what's the real purpose
of [`git mv`](https://git-scm.com/docs/git-mv)? The man page isn't particularly descriptive...
Is it obsolete? Is it an internal command, not meant to be used by regu... | ```
git mv oldname newname
```
is just shorthand for:
```
mv oldname newname
git add newname
git rm oldname
```
i.e. it updates the index for both old and new paths automatically. |
11968531 | What to gitignore from the .idea folder? | 726 | 2012-08-15 11:32:40 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/3041154/intellij-idea-9-10-what-folders-to-check-into-or-not-check-into-source-contro">Intellij Idea 9/10, what folders to check into (or not check into) source control?</a> </p>
</blockquote>
<p>I started usin... | 680,951 | 21,728 | 2024-06-24 10:36:52 | 11,968,647 | 569 | 2012-08-15 11:41:29 | 1,542,540 | 2019-11-21 10:18:34 | https://stackoverflow.com/q/11968531 | https://stackoverflow.com/a/11968647 | <p><a href="https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems" rel="noreferrer">The official support page</a> should answer your question.</p>
<p>So in your <code>.gitignore</code> you might ignore the files ending with <code>.iws</code>, and the <c... | <p><a href="https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems" rel="noreferrer">The official support page</a> should answer your question.</p> <p>So in your <code>.gitignore</code> you might ignore the files ending with <code>.iws</code>, and the <c... | 119, 8945, 25056, 66822 | git, gitignore, intellij-idea, webstorm | <h1>What to gitignore from the .idea folder?</h1>
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/3041154/intellij-idea-9-10-what-folders-to-check-into-or-not-check-into-source-contro">Intellij Idea 9/10, what folders to check into (or not check into) source con... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,264 | git | # What to gitignore from the .idea folder?
> **Possible Duplicate:**
> [Intellij Idea 9/10, what folders to check into (or not check into) source control?](https://stackoverflow.com/questions/3041154/intellij-idea-9-10-what-folders-to-check-into-or-not-check-into-source-contro)
I started using WebStorm for web deve... | [The official support page](https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems) should answer your question.
So in your `.gitignore` you might ignore the files ending with `.iws`, and the `workspace.xml` and `tasks.xml` files. |
14005854 | What to do with branch after merge | 494 | 2012-12-22 19:27:40 | <p>I had two branches: <code>master</code> and <code>branch1</code>. I just merged <code>branch1</code> back into <code>master</code> and I'm done with that branch. Should I delete it or just let it sit around? Will deleting it cause any loss of data?</p>
| 272,140 | 1,676,002 | 2023-03-02 14:33:29 | 14,005,910 | 568 | 2012-12-22 19:32:20 | 1,248,008 | 2023-03-02 14:33:29 | https://stackoverflow.com/q/14005854 | https://stackoverflow.com/a/14005910 | <p>After the merge, it's safe to delete the branch:</p>
<pre><code>git branch -d branch1
</code></pre>
<p>Additionally, git will warn you (and refuse to delete the branch) if it thinks you didn't fully merge it yet. If you forcefully delete a branch (with <code>git branch -D</code>) which is not completely merged yet, ... | <p>After the merge, it's safe to delete the branch:</p> <pre><code>git branch -d branch1 </code></pre> <p>Additionally, git will warn you (and refuse to delete the branch) if it thinks you didn't fully merge it yet. If you forcefully delete a branch (with <code>git branch -D</code>) which is not completely merged yet, ... | 119, 717, 1879 | branch, git, merge | <h1>What to do with branch after merge</h1>
<p>I had two branches: <code>master</code> and <code>branch1</code>. I just merged <code>branch1</code> back into <code>master</code> and I'm done with that branch. Should I delete it or just let it sit around? Will deleting it cause any loss of data?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,265 | git | # What to do with branch after merge
I had two branches: `master` and `branch1`. I just merged `branch1` back into `master` and I'm done with that branch. Should I delete it or just let it sit around? Will deleting it cause any loss of data? | After the merge, it's safe to delete the branch:
```
git branch -d branch1
```
Additionally, git will warn you (and refuse to delete the branch) if it thinks you didn't fully merge it yet. If you forcefully delete a branch (with `git branch -D`) which is not completely merged yet, you have to do some tricks to get th... |
7310177 | How do I make a branch point at a specific commit? | 424 | 2011-09-05 15:41:14 | <p>In Git, I understand that a branch is a pointer to a commit.</p>
<p>How do I make a specific branch point to a specific commit? Say I want to make <code>master</code> point at <code>1258f0d0aae...</code>, how do I do that?</p>
| 376,343 | 76,701 | 2022-03-10 06:11:08 | 7,310,222 | 567 | 2011-09-05 15:46:26 | 223,092 | 2018-07-25 11:35:09 | https://stackoverflow.com/q/7310177 | https://stackoverflow.com/a/7310222 | <p>You can make <code>master</code> point at <code>1258f0d0aae</code> this way:</p>
<pre><code>git checkout master
git reset --hard 1258f0d0aae
</code></pre>
<p>But you have to be careful about doing this. It may well rewrite the history of that branch. That would create problems if you have published it and other pe... | <p>You can make <code>master</code> point at <code>1258f0d0aae</code> this way:</p> <pre><code>git checkout master git reset --hard 1258f0d0aae </code></pre> <p>But you have to be careful about doing this. It may well rewrite the history of that branch. That would create problems if you have published it and other pe... | 119, 76220 | git, git-branch | <h1>How do I make a branch point at a specific commit?</h1>
<p>In Git, I understand that a branch is a pointer to a commit.</p>
<p>How do I make a specific branch point to a specific commit? Say I want to make <code>master</code> point at <code>1258f0d0aae...</code>, how do I do that?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,267 | git | # How do I make a branch point at a specific commit?
In Git, I understand that a branch is a pointer to a commit.
How do I make a specific branch point to a specific commit? Say I want to make `master` point at `1258f0d0aae...`, how do I do that? | You can make `master` point at `1258f0d0aae` this way:
```
git checkout master
git reset --hard 1258f0d0aae
```
But you have to be careful about doing this. It may well rewrite the history of that branch. That would create problems if you have published it and other people are working on the branch.
Also, the `git r... |
2471606 | How and/or why is merging in Git better than in SVN? | 406 | 2010-03-18 16:32:33 | <p>I've heard in a few places that one of the main reasons why distributed version control systems shine, is much better merging than in traditional tools like SVN.
Is this actually due to inherent differences in how the two systems work, or do <em>specific</em> DVCS implementations like Git/Mercurial just have clevere... | 71,278 | 197,229 | 2019-04-10 22:11:29 | 2,472,251 | 567 | 2010-03-18 18:03:49 | 3,713 | 2018-02-22 09:38:59 | https://stackoverflow.com/q/2471606 | https://stackoverflow.com/a/2472251 | <p>The claim of why merging is better in a DVCS than in Subversion was largely based on how branching and merge worked in Subversion a while ago. Subversion prior to <a href="http://svn.apache.org/repos/asf/subversion/trunk/notes/merge-tracking/index.html" rel="noreferrer">1.5.0</a> didn't store any information about w... | <p>The claim of why merging is better in a DVCS than in Subversion was largely based on how branching and merge worked in Subversion a while ago. Subversion prior to <a href="http://svn.apache.org/repos/asf/subversion/trunk/notes/merge-tracking/index.html" rel="noreferrer">1.5.0</a> didn't store any information about w... | 63, 119, 456, 717, 802 | git, mercurial, merge, svn, version-control | <h1>How and/or why is merging in Git better than in SVN?</h1>
<p>I've heard in a few places that one of the main reasons why distributed version control systems shine, is much better merging than in traditional tools like SVN.
Is this actually due to inherent differences in how the two systems work, or do <em>specific<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,268 | git | # How and/or why is merging in Git better than in SVN?
I've heard in a few places that one of the main reasons why distributed version control systems shine, is much better merging than in traditional tools like SVN.
Is this actually due to inherent differences in how the two systems work, or do *specific* DVCS implem... | The claim of why merging is better in a DVCS than in Subversion was largely based on how branching and merge worked in Subversion a while ago. Subversion prior to [1.5.0](http://svn.apache.org/repos/asf/subversion/trunk/notes/merge-tracking/index.html) didn't store any information about when branches were merged, thus ... |
42871542 | How can I create a Git repository with the default branch name other than "master"? | 352 | 2017-03-18 07:03:53 | <p>In the <a href="https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches" rel="noreferrer">Pro Git book</a>, it says</p>
<blockquote>
<p>“origin” is not special</p>
<p>Just like the branch name “master” does not have any special meaning in Git, neither does “origin”. <strong>While “master” is the default name fo... | 273,753 | 3,142,049 | 2021-11-25 00:39:17 | 42,871,621 | 567 | 2017-03-18 07:14:17 | 82,294 | 2020-10-27 11:07:27 | https://stackoverflow.com/q/42871542 | https://stackoverflow.com/a/42871621 | <h2>Newer Git, New Repo</h2>
<p>Since git version 2.28.0 the <code>git init</code> command now takes a <code>--initial-branch</code> (or <code>-b</code> for short) parameter. These two commands create a new Git repo with a branch named "trunk", which always made more sense to me than "master" (maste... | <h2>Newer Git, New Repo</h2> <p>Since git version 2.28.0 the <code>git init</code> command now takes a <code>--initial-branch</code> (or <code>-b</code> for short) parameter. These two commands create a new Git repo with a branch named "trunk", which always made more sense to me than "master" (maste... | 119, 456 | git, version-control | <h1>How can I create a Git repository with the default branch name other than "master"?</h1>
<p>In the <a href="https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches" rel="noreferrer">Pro Git book</a>, it says</p>
<blockquote>
<p>“origin” is not special</p>
<p>Just like the branch name “master” does not have any... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,269 | git | # How can I create a Git repository with the default branch name other than "master"?
In the [Pro Git book](https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches), it says
> “origin” is not special
>
> Just like the branch name “master” does not have any special meaning in Git, neither does “origin”. **While “... | ## Newer Git, New Repo
Since git version 2.28.0 the `git init` command now takes a `--initial-branch` (or `-b` for short) parameter. These two commands create a new Git repo with a branch named "trunk", which always made more sense to me than "master" (master of what?):
```
git init --initial-branch=trunk
git init -b... |
38983153 | git is not respecting gitignore instruction to ignore .env files | 263 | 2016-08-16 19:39:46 | <p>I have a project. In the root directory are these 4 files:</p>
<blockquote>
<p>.env .env.example .env.local .env.staging</p>
</blockquote>
<p>I have a .gitignore file, and I'm listing these 4 files in the .gitignore, one after another, like this</p>
<pre><code>.env
.env.example
.env.local
.env.staging
</code></pre>
... | 389,836 | 1,801,713 | 2025-01-02 17:21:11 | 38,983,205 | 565 | 2016-08-16 19:43:12 | 6,194,839 | 2024-10-24 01:22:46 | https://stackoverflow.com/q/38983153 | https://stackoverflow.com/a/38983205 | <h2>Use <a href="https://git-scm.com/docs/git-rm" rel="noreferrer">git rm</a>:</h2>
<p>If you have already added the files to be tracked, you need to remove them from tracking:</p>
<pre><code>git rm .env.local --cached
git rm .env.staging --cached
git commit -m "Stopped tracking env.local, and env.staging"
</... | <h2>Use <a href="https://git-scm.com/docs/git-rm" rel="noreferrer">git rm</a>:</h2> <p>If you have already added the files to be tracked, you need to remove them from tracking:</p> <pre><code>git rm .env.local --cached git rm .env.staging --cached git commit -m "Stopped tracking env.local, and env.staging" </... | 119, 25056 | git, gitignore | <h1>git is not respecting gitignore instruction to ignore .env files</h1>
<p>I have a project. In the root directory are these 4 files:</p>
<blockquote>
<p>.env .env.example .env.local .env.staging</p>
</blockquote>
<p>I have a .gitignore file, and I'm listing these 4 files in the .gitignore, one after another, like th... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,270 | git | # git is not respecting gitignore instruction to ignore .env files
I have a project. In the root directory are these 4 files:
> .env .env.example .env.local .env.staging
I have a .gitignore file, and I'm listing these 4 files in the .gitignore, one after another, like this
```
.env
.env.example
.env.local
.env.stag... | ## Use [git rm](https://git-scm.com/docs/git-rm):
If you have already added the files to be tracked, you need to remove them from tracking:
```
git rm .env.local --cached
git rm .env.staging --cached
git commit -m "Stopped tracking env.local, and env.staging"
```
Now you should be able to clone your branch without t... |
25053697 | Git merge two local branches | 301 | 2014-07-31 08:02:08 | <p>I have branch <code>Master</code>, <code>branchA</code> and <code>branchB</code>.
Now I'm working in the <code>branchA</code> and I need to merge <code>branchA</code> with <code>branchB</code> and proceed my work in the <code>branchA</code>. All files are comitted in the <code>branchA</code> and <code>branchB</code>... | 458,742 | 3,127,896 | 2025-07-21 19:42:47 | 25,053,738 | 564 | 2014-07-31 08:04:15 | 515,034 | 2024-02-12 20:26:10 | https://stackoverflow.com/q/25053697 | https://stackoverflow.com/a/25053738 | <p>If I understood your question, you want to merge <code>branchB</code> into <code>branchA</code>. To do so,</p>
<p>first checkout <code>branchA</code> like below,</p>
<pre><code>git checkout branchA
</code></pre>
<p>Then execute the below command to merge <code>branchB</code> into <code>branchA</code>:</p>
<pre><code... | <p>If I understood your question, you want to merge <code>branchB</code> into <code>branchA</code>. To do so,</p> <p>first checkout <code>branchA</code> like below,</p> <pre><code>git checkout branchA </code></pre> <p>Then execute the below command to merge <code>branchB</code> into <code>branchA</code>:</p> <pre><code... | 119, 717 | git, merge | <h1>Git merge two local branches</h1>
<p>I have branch <code>Master</code>, <code>branchA</code> and <code>branchB</code>.
Now I'm working in the <code>branchA</code> and I need to merge <code>branchA</code> with <code>branchB</code> and proceed my work in the <code>branchA</code>. All files are comitted in the <code>b... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,271 | git | # Git merge two local branches
I have branch `Master`, `branchA` and `branchB`.
Now I'm working in the `branchA` and I need to merge `branchA` with `branchB` and proceed my work in the `branchA`. All files are comitted in the `branchA` and `branchB`.
What's the fast way to implement it? | If I understood your question, you want to merge `branchB` into `branchA`. To do so,
first checkout `branchA` like below,
```
git checkout branchA
```
Then execute the below command to merge `branchB` into `branchA`:
```
git merge branchB
```
You can also condense this into one liner:
```
git merge branchA branch... |
2883840 | Differences between git pull origin master & git pull origin/master | 421 | 2010-05-21 16:34:06 | <p>What is the difference between <code>git pull origin master</code> and <code>git pull origin/master</code> ?</p>
| 715,401 | 164,299 | 2022-04-19 16:50:14 | 2,883,857 | 563 | 2010-05-21 16:36:12 | 247,563 | 2010-05-21 16:53:59 | https://stackoverflow.com/q/2883840 | https://stackoverflow.com/a/2883857 | <p><code>git pull origin master</code> will pull changes from the <code>origin</code> remote, <code>master</code> branch and merge them to the local checked-out branch.</p>
<p><code>git pull origin/master</code> will pull changes from the locally stored branch <code>origin/master</code> and merge that to the local che... | <p><code>git pull origin master</code> will pull changes from the <code>origin</code> remote, <code>master</code> branch and merge them to the local checked-out branch.</p> <p><code>git pull origin/master</code> will pull changes from the locally stored branch <code>origin/master</code> and merge that to the local che... | 119, 456 | git, version-control | <h1>Differences between git pull origin master & git pull origin/master</h1>
<p>What is the difference between <code>git pull origin master</code> and <code>git pull origin/master</code> ?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,272 | git | # Differences between git pull origin master & git pull origin/master
What is the difference between `git pull origin master` and `git pull origin/master` ? | `git pull origin master` will pull changes from the `origin` remote, `master` branch and merge them to the local checked-out branch.
`git pull origin/master` will pull changes from the locally stored branch `origin/master` and merge that to the local checked-out branch. The `origin/master` branch is essentially a "cac... |
4785107 | Resolve conflicts using remote changes when pulling from Git remote | 337 | 2011-01-24 17:36:46 | <p>I'm trying to pull code from my GitHub repo onto my server, but the pull keeps failing because of merge conflicts. I don't want to keep any of the changes that may have occurred on my local server since the last pull.</p>
<p>So is there a way I can force Git to overwrite with whatever version is in GitHub, rather t... | 259,360 | 574,190 | 2017-02-15 03:11:25 | 4,787,356 | 560 | 2011-01-24 21:26:38 | 119,963 | 2011-12-31 17:11:48 | https://stackoverflow.com/q/4785107 | https://stackoverflow.com/a/4787356 |
<p>If you truly want to discard the <em>commits</em> you've made locally, i.e. never have them in the history again, you're not asking how to pull - pull means merge, and you don't need to merge. All you need do is this:</p>
<pre class="lang-sh prettyprint-override"><code># fetch from the default remote, origin
git ... | <p>If you truly want to discard the <em>commits</em> you've made locally, i.e. never have them in the history again, you're not asking how to pull - pull means merge, and you don't need to merge. All you need do is this:</p> <pre class="lang-sh prettyprint-override"><code># fetch from the default remote, origin git ... | 119, 28896 | git, git-pull | <h1>Resolve conflicts using remote changes when pulling from Git remote</h1>
<p>I'm trying to pull code from my GitHub repo onto my server, but the pull keeps failing because of merge conflicts. I don't want to keep any of the changes that may have occurred on my local server since the last pull.</p>
<p>So is there a ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,273 | git | # Resolve conflicts using remote changes when pulling from Git remote
I'm trying to pull code from my GitHub repo onto my server, but the pull keeps failing because of merge conflicts. I don't want to keep any of the changes that may have occurred on my local server since the last pull.
So is there a way I can force ... | If you truly want to discard the *commits* you've made locally, i.e. never have them in the history again, you're not asking how to pull - pull means merge, and you don't need to merge. All you need do is this:
```
# fetch from the default remote, origin
git fetch
# reset your current branch (master) to origin's maste... |
17604232 | Edit a commit message in Sourcetree Windows (already pushed to remote) | 276 | 2013-07-11 21:57:59 | <p>How do I edit an incorrect commit message in Sourcetree without touching the command line?</p>
<p><strong>Additional details:</strong></p>
<ul>
<li>This is not the latest commit.</li>
<li>Everything was already pushed to <a href="https://en.wikipedia.org/wiki/Bitbucket" rel="nofollow noreferrer">Bitbucket</a>.</li>
... | 275,417 | 2,327,283 | 2025-02-19 17:32:33 | 23,239,109 | 558 | 2014-04-23 08:42:22 | null | 2025-02-19 17:32:33 | https://stackoverflow.com/q/17604232 | https://stackoverflow.com/a/23239109 | <p>Here are the steps to edit the commit message of a previous commit (<em><strong>which is not the most recent commit</strong></em>) using <strong>Sourcetree for Windows version 1.5.2.0</strong>:</p>
<h2>Step 1</h2>
<p>Select the commit <em><strong>immediately before</strong></em> the commit that you want to edit.
For... | <p>Here are the steps to edit the commit message of a previous commit (<em><strong>which is not the most recent commit</strong></em>) using <strong>Sourcetree for Windows version 1.5.2.0</strong>:</p> <h2>Step 1</h2> <p>Select the commit <em><strong>immediately before</strong></em> the commit that you want to edit. For... | 119, 90056 | atlassian-sourcetree, git | <h1>Edit a commit message in Sourcetree Windows (already pushed to remote)</h1>
<p>How do I edit an incorrect commit message in Sourcetree without touching the command line?</p>
<p><strong>Additional details:</strong></p>
<ul>
<li>This is not the latest commit.</li>
<li>Everything was already pushed to <a href="https:/... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,274 | git | # Edit a commit message in Sourcetree Windows (already pushed to remote)
How do I edit an incorrect commit message in Sourcetree without touching the command line?
**Additional details:**
- This is not the latest commit.
- Everything was already pushed to [Bitbucket](https://en.wikipedia.org/wiki/Bitbucket).
- This ... | Here are the steps to edit the commit message of a previous commit (***which is not the most recent commit***) using **Sourcetree for Windows version 1.5.2.0**:
## Step 1
Select the commit ***immediately before*** the commit that you want to edit.
For example, if I want to edit the commit with message "FOOBAR!" then ... |
1329291 | Ignoring an already checked-in directory's contents? | 251 | 2009-08-25 16:10:26 | <p>I have a git repository that's used only to hold graphics and sound files used in several projects. They are all in one directory without sub-directories. Now I just created a script to copy these assets over from another, structured directory, with several levels of sub-directories.</p>
<p>Now I only want the (sou... | 87,112 | 96,531 | 2023-04-30 09:27:56 | 1,330,097 | 557 | 2009-08-25 18:24:57 | 23,071 | 2009-08-25 18:50:22 | https://stackoverflow.com/q/1329291 | https://stackoverflow.com/a/1330097 | <p>This command will cause git to untrack your directory and all files under it without actually deleting them:</p>
<p><code>git rm -r --cached <your directory></code></p>
<p>The <code>-r</code> option causes the removal of all files under your directory. </p>
<p>The <code>--cached</code> option causes the fi... | <p>This command will cause git to untrack your directory and all files under it without actually deleting them:</p> <p><code>git rm -r --cached <your directory></code></p> <p>The <code>-r</code> option causes the removal of all files under your directory. </p> <p>The <code>--cached</code> option causes the fi... | 119, 456 | git, version-control | <h1>Ignoring an already checked-in directory's contents?</h1>
<p>I have a git repository that's used only to hold graphics and sound files used in several projects. They are all in one directory without sub-directories. Now I just created a script to copy these assets over from another, structured directory, with sever... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,275 | git | # Ignoring an already checked-in directory's contents?
I have a git repository that's used only to hold graphics and sound files used in several projects. They are all in one directory without sub-directories. Now I just created a script to copy these assets over from another, structured directory, with several levels... | This command will cause git to untrack your directory and all files under it without actually deleting them:
`git rm -r --cached <your directory>`
The `-r` option causes the removal of all files under your directory.
The `--cached` option causes the files to only be removed from git's index, not your working copy. B... |
79165 | How do I migrate an SVN repository with history to a new Git repository? | 1,637 | 2008-09-17 02:04:20 | <p>I read the Git manual, FAQ, Git - SVN crash course, etc. and they all explain this and that, but nowhere can you find a simple instruction like:</p>
<p>SVN repository in: <code>svn://myserver/path/to/svn/repos</code></p>
<p>Git repository in: <code>git://myserver/path/to/git/repos</code></p>
<pre><code>git-do-the... | 583,260 | 14,690 | 2022-12-16 17:38:39 | 79,178 | 555 | 2008-09-17 02:08:25 | 11,138 | 2019-09-09 10:42:14 | https://stackoverflow.com/q/79165 | https://stackoverflow.com/a/79178 | <p>Magic:</p>
<pre><code>$ git svn clone http://svn/repo/here/trunk
</code></pre>
<p>Git and SVN operate very differently. You need to learn Git, and if you want to track changes from SVN upstream, you need to learn <code>git-svn</code>. The <code>git-svn</code> <a href="https://git-scm.com/docs/git-svn" rel="noref... | <p>Magic:</p> <pre><code>$ git svn clone http://svn/repo/here/trunk </code></pre> <p>Git and SVN operate very differently. You need to learn Git, and if you want to track changes from SVN upstream, you need to learn <code>git-svn</code>. The <code>git-svn</code> <a href="https://git-scm.com/docs/git-svn" rel="noref... | 63, 119, 456, 6452 | git, git-svn, svn, version-control | <h1>How do I migrate an SVN repository with history to a new Git repository?</h1>
<p>I read the Git manual, FAQ, Git - SVN crash course, etc. and they all explain this and that, but nowhere can you find a simple instruction like:</p>
<p>SVN repository in: <code>svn://myserver/path/to/svn/repos</code></p>
<p>Git repos... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,276 | git | # How do I migrate an SVN repository with history to a new Git repository?
I read the Git manual, FAQ, Git - SVN crash course, etc. and they all explain this and that, but nowhere can you find a simple instruction like:
SVN repository in: `svn://myserver/path/to/svn/repos`
Git repository in: `git://myserver/path/to/... | Magic:
```
$ git svn clone http://svn/repo/here/trunk
```
Git and SVN operate very differently. You need to learn Git, and if you want to track changes from SVN upstream, you need to learn `git-svn`. The `git-svn` [main page has a good examples section](https://git-scm.com/docs/git-svn):
```
$ git svn --help
``` |
4254389 | Git: "Corrupt loose object" | 546 | 2010-11-23 09:16:29 | <p>Whenever I pull from my remote, I get the following error about compression. When I run the manual compression, I get the same:</p>
<pre><code>$ git gc
error: Could not read 3813783126d41a3200b35b6681357c213352ab31
fatal: bad tree object 3813783126d41a3200b35b6681357c213352ab31
error: failed to run repack
</code></... | 399,889 | 64,105 | 2025-07-16 14:07:00 | 13,918,515 | 555 | 2012-12-17 16:59:27 | 1,910,521 | 2016-09-22 15:02:06 | https://stackoverflow.com/q/4254389 | https://stackoverflow.com/a/13918515 | <p>I had the same problem (don't know why).</p>
<p><strong>This fix requires access to an uncorrupted remote copy of the repository, and will keep your locally working copy intact.</strong></p>
<p>But it has some drawbacks:</p>
<ul>
<li>You will lose the record of any commits that were not pushed, and will have to r... | <p>I had the same problem (don't know why).</p> <p><strong>This fix requires access to an uncorrupted remote copy of the repository, and will keep your locally working copy intact.</strong></p> <p>But it has some drawbacks:</p> <ul> <li>You will lose the record of any commits that were not pushed, and will have to r... | 119, 456 | git, version-control | <h1>Git: "Corrupt loose object"</h1>
<p>Whenever I pull from my remote, I get the following error about compression. When I run the manual compression, I get the same:</p>
<pre><code>$ git gc
error: Could not read 3813783126d41a3200b35b6681357c213352ab31
fatal: bad tree object 3813783126d41a3200b35b6681357c213352ab31
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,277 | git | # Git: "Corrupt loose object"
Whenever I pull from my remote, I get the following error about compression. When I run the manual compression, I get the same:
```
$ git gc
error: Could not read 3813783126d41a3200b35b6681357c213352ab31
fatal: bad tree object 3813783126d41a3200b35b6681357c213352ab31
error: failed to run... | I had the same problem (don't know why).
**This fix requires access to an uncorrupted remote copy of the repository, and will keep your locally working copy intact.**
But it has some drawbacks:
- You will lose the record of any commits that were not pushed, and will have to recommit them.
- You will lose any stashes... |
5613902 | How to "pull" from a local branch into another one? | 350 | 2011-04-10 18:40:25 | <p>This sounds so simple, but I just can't figure it out. I made an experimental branch a while ago, and now I'd like to pull in all the changes that happened on master since I made it. This is all local. I want to pull from local master into local my_branch, but I can't do it. This doesn't seem to work, telling me tha... | 326,909 | 131,854 | 2024-04-05 13:32:18 | 5,613,911 | 552 | 2011-04-10 18:42:13 | 112,968 | 2024-02-29 21:53:09 | https://stackoverflow.com/q/5613902 | https://stackoverflow.com/a/5613911 | <p>You have to tell Git from where to pull, in this case from the current directory/repository (<code>.</code>):</p>
<pre><code>git pull . master
</code></pre>
<p>But when working locally, you can simply use <a href="https://git-scm.com/docs/git-merge" rel="noreferrer">merge</a> (pull internally calls merge):</p>
<pre>... | <p>You have to tell Git from where to pull, in this case from the current directory/repository (<code>.</code>):</p> <pre><code>git pull . master </code></pre> <p>But when working locally, you can simply use <a href="https://git-scm.com/docs/git-merge" rel="noreferrer">merge</a> (pull internally calls merge):</p> <pre>... | 119 | git | <h1>How to "pull" from a local branch into another one?</h1>
<p>This sounds so simple, but I just can't figure it out. I made an experimental branch a while ago, and now I'd like to pull in all the changes that happened on master since I made it. This is all local. I want to pull from local master into local my_branch,... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,278 | git | # How to "pull" from a local branch into another one?
This sounds so simple, but I just can't figure it out. I made an experimental branch a while ago, and now I'd like to pull in all the changes that happened on master since I made it. This is all local. I want to pull from local master into local my_branch, but I ca... | You have to tell Git from where to pull, in this case from the current directory/repository (`.`):
```
git pull . master
```
But when working locally, you can simply use [merge](https://git-scm.com/docs/git-merge) (pull internally calls merge):
```
git merge master
```
What is meant by "pull internally calls merge"... |
2125710 | How to revert a "git rm -r ."? | 476 | 2010-01-24 02:47:30 | <p>I accidentely said <code>git rm -r .</code>. How do I recover from this?</p>
<p>I did not commit.</p>
<p>I think all files were marked for deletion and were also physically removed from my local checkout.</p>
<p><em>EDIT:</em> I could (if I knew the command) revert to the last commit. But it would be a lot better... | 369,894 | 89,021 | 2021-04-30 10:03:38 | 2,125,738 | 549 | 2010-01-24 02:56:49 | 69,755 | 2010-01-24 02:56:49 | https://stackoverflow.com/q/2125710 | https://stackoverflow.com/a/2125738 | <pre><code>git reset HEAD
</code></pre>
<p>Should do it. If you don't have any uncommitted changes that you care about, then</p>
<pre><code>git reset --hard HEAD
</code></pre>
<p>should forcibly reset everything to your last commit. If you do have uncommitted changes, but the first command doesn't work, then save yo... | <pre><code>git reset HEAD </code></pre> <p>Should do it. If you don't have any uncommitted changes that you care about, then</p> <pre><code>git reset --hard HEAD </code></pre> <p>should forcibly reset everything to your last commit. If you do have uncommitted changes, but the first command doesn't work, then save yo... | 119, 112901 | git, git-rm | <h1>How to revert a "git rm -r ."?</h1>
<p>I accidentely said <code>git rm -r .</code>. How do I recover from this?</p>
<p>I did not commit.</p>
<p>I think all files were marked for deletion and were also physically removed from my local checkout.</p>
<p><em>EDIT:</em> I could (if I knew the command) revert to the l... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,279 | git | # How to revert a "git rm -r ."?
I accidentely said `git rm -r .`. How do I recover from this?
I did not commit.
I think all files were marked for deletion and were also physically removed from my local checkout.
*EDIT:* I could (if I knew the command) revert to the last commit. But it would be a lot better if I co... | ```
git reset HEAD
```
Should do it. If you don't have any uncommitted changes that you care about, then
```
git reset --hard HEAD
```
should forcibly reset everything to your last commit. If you do have uncommitted changes, but the first command doesn't work, then save your uncommitted changes with `git stash`:
``... |
2294313 | How to download a branch with git? | 310 | 2010-02-19 05:42:32 | <p>I have a project hosted on GitHub. I created a branch on one computer, then pushed my changes to GitHub with: </p>
<pre><code>git push origin branch-name
</code></pre>
<p>Now I am on a different computer, and I want to download that branch. So I tried:</p>
<pre><code>git pull origin branch-name
</code></pre>
<p>... | 562,939 | 48,523 | 2025-03-26 07:12:07 | 2,294,385 | 549 | 2010-02-19 06:00:49 | 48,523 | 2019-04-08 06:08:20 | https://stackoverflow.com/q/2294313 | https://stackoverflow.com/a/2294385 | <p>Thanks to a <a href="https://stackoverflow.com/questions/67699/how-do-i-clone-all-remote-branches-with-git">related question</a>, I found out that I need to "checkout" the remote branch as a new local branch, and specify a new local branch name.</p>
<pre><code>git checkout -b newlocalbranchname origin/branch-name
<... | <p>Thanks to a <a href="https://stackoverflow.com/questions/67699/how-do-i-clone-all-remote-branches-with-git">related question</a>, I found out that I need to "checkout" the remote branch as a new local branch, and specify a new local branch name.</p> <pre><code>git checkout -b newlocalbranchname origin/branch-name <... | 119, 1879 | branch, git | <h1>How to download a branch with git?</h1>
<p>I have a project hosted on GitHub. I created a branch on one computer, then pushed my changes to GitHub with: </p>
<pre><code>git push origin branch-name
</code></pre>
<p>Now I am on a different computer, and I want to download that branch. So I tried:</p>
<pre><code>gi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,280 | git | # How to download a branch with git?
I have a project hosted on GitHub. I created a branch on one computer, then pushed my changes to GitHub with:
```
git push origin branch-name
```
Now I am on a different computer, and I want to download that branch. So I tried:
```
git pull origin branch-name
```
...but all thi... | Thanks to a [related question](https://stackoverflow.com/questions/67699/how-do-i-clone-all-remote-branches-with-git), I found out that I need to "checkout" the remote branch as a new local branch, and specify a new local branch name.
```
git checkout -b newlocalbranchname origin/branch-name
```
Or you can do:
```
g... |
6017987 | How can I list all the deleted files in a Git repository? | 421 | 2011-05-16 13:15:27 | <p>I know Git stores information of when files get deleted and I am able to check individual commits to see which files have been removed, but is there a command that would generate a list of every deleted file across a repository's lifespan?</p>
| 174,486 | 197,302 | 2022-07-05 05:05:06 | 6,018,043 | 548 | 2011-05-16 13:19:57 | 155,392 | 2011-05-16 13:19:57 | https://stackoverflow.com/q/6017987 | https://stackoverflow.com/a/6018043 | <pre><code>git log --diff-filter=D --summary
</code></pre>
<p>See <a href="https://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo">Find and restore a deleted file in a Git repository</a></p>
<p>If you don't want all the information about which commit they were removed in, you can just add a <... | <pre><code>git log --diff-filter=D --summary </code></pre> <p>See <a href="https://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo">Find and restore a deleted file in a Git repository</a></p> <p>If you don't want all the information about which commit they were removed in, you can just add a <... | 119 | git | <h1>How can I list all the deleted files in a Git repository?</h1>
<p>I know Git stores information of when files get deleted and I am able to check individual commits to see which files have been removed, but is there a command that would generate a list of every deleted file across a repository's lifespan?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,281 | git | # How can I list all the deleted files in a Git repository?
I know Git stores information of when files get deleted and I am able to check individual commits to see which files have been removed, but is there a command that would generate a list of every deleted file across a repository's lifespan? | ```
git log --diff-filter=D --summary
```
See [Find and restore a deleted file in a Git repository](https://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo)
If you don't want all the information about which commit they were removed in, you can just add a `grep delete` in there.
```
git log --... |
41052538 | Git error - gpg failed to sign data | 384 | 2016-12-09 03:17:36 | <p>I just started using git and I install git and gpg via homebrew.
For some reason, I get this error when i do <code>git commit</code>
I looked at so many other stackoverflow questions regarding this topic and none of them worked for me.
How can I fix this error so that I can upload successfully. </p>
<pre><code>erro... | 269,438 | 5,213,477 | 2025-07-09 09:53:52 | 41,054,093 | 547 | 2016-12-09 06:06:08 | 441,757 | 2025-07-09 09:53:52 | https://stackoverflow.com/q/41052538 | https://stackoverflow.com/a/41054093 | <p>For troubleshooting, two things to first try:</p>
<ul>
<li>run <code>gpg --version</code>, and make sure you have GnuPG version 2+ (not version 1) installed</li>
<li>run <code>echo "test" | gpg --clearsign</code>, to make sure <code>gpg</code> itself is working</li>
</ul>
<p>If that all looks all right, on... | <p>For troubleshooting, two things to first try:</p> <ul> <li>run <code>gpg --version</code>, and make sure you have GnuPG version 2+ (not version 1) installed</li> <li>run <code>echo "test" | gpg --clearsign</code>, to make sure <code>gpg</code> itself is working</li> </ul> <p>If that all looks all right, on... | 119, 6735 | git, gnupg | <h1>Git error - gpg failed to sign data</h1>
<p>I just started using git and I install git and gpg via homebrew.
For some reason, I get this error when i do <code>git commit</code>
I looked at so many other stackoverflow questions regarding this topic and none of them worked for me.
How can I fix this error so that I c... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,282 | git | # Git error - gpg failed to sign data
I just started using git and I install git and gpg via homebrew.
For some reason, I get this error when i do `git commit`
I looked at so many other stackoverflow questions regarding this topic and none of them worked for me.
How can I fix this error so that I can upload successful... | For troubleshooting, two things to first try:
- run `gpg --version`, and make sure you have GnuPG version 2+ (not version 1) installed
- run `echo "test" | gpg --clearsign`, to make sure `gpg` itself is working
If that all looks all right, one next thing to try:
- run `brew install pinentry` to ensure you have a goo... |
6459080 | How can I undo a `git commit` locally and on a remote after `git push` | 339 | 2011-06-23 18:44:31 | <p>I have performed <code>git commit</code> followed by a <code>git push</code>. How can I revert that change on both local and remote repositories?</p>
<pre><code>$ git log
commit 364705c23011b0fc6a7ca2d80c86cef4a7c4db7ac8
Author: Michael Silver <Michael Silver@gmail.com>
Date: Tue Jun 11 12:24:23 2011 -0700... | 271,953 | 286,802 | 2023-01-01 17:39:19 | 6,459,166 | 547 | 2011-06-23 18:51:58 | 149,264 | 2022-12-23 13:19:13 | https://stackoverflow.com/q/6459080 | https://stackoverflow.com/a/6459166 | <pre><code>git reset --hard HEAD~1
git push -f <remote> <branch>
</code></pre>
<p><em>(Example push:</em> <code>git push -f origin bugfix/bug123</code><em>)</em></p>
<p>This will undo the last commit and push the updated history to the remote. You need to pass the <code>-f</code> because you're replacing up... | <pre><code>git reset --hard HEAD~1 git push -f <remote> <branch> </code></pre> <p><em>(Example push:</em> <code>git push -f origin bugfix/bug123</code><em>)</em></p> <p>This will undo the last commit and push the updated history to the remote. You need to pass the <code>-f</code> because you're replacing up... | 119, 28898, 53850 | git, git-commit, git-push | <h1>How can I undo a `git commit` locally and on a remote after `git push`</h1>
<p>I have performed <code>git commit</code> followed by a <code>git push</code>. How can I revert that change on both local and remote repositories?</p>
<pre><code>$ git log
commit 364705c23011b0fc6a7ca2d80c86cef4a7c4db7ac8
Author: Michae... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,283 | git | # How can I undo a `git commit` locally and on a remote after `git push`
I have performed `git commit` followed by a `git push`. How can I revert that change on both local and remote repositories?
```
$ git log
commit 364705c23011b0fc6a7ca2d80c86cef4a7c4db7ac8
Author: Michael Silver <Michael Silver@gmail.com>
Date: ... | ```
git reset --hard HEAD~1
git push -f <remote> <branch>
```
*(Example push:* `git push -f origin bugfix/bug123`*)*
This will undo the last commit and push the updated history to the remote. You need to pass the `-f` because you're replacing upstream history in the remote.
**Edit:**
Please note that `--hard` will ... |
1304626 | Switch branch and ignore any changes without committing | 437 | 2009-08-20 07:56:05 | <p>I was working on a git branch and was ready to commit my changes, so I made a commit with a useful commit message. I then absentmindedly made minor changes to the code that are not worth keeping. I now want to change branches, but git gives me,</p>
<blockquote>
<p>error: You have local changes to "X"; cannot swit... | 656,406 | 92,610 | 2025-04-29 06:51:40 | 1,304,645 | 546 | 2009-08-20 08:02:06 | 6,309 | 2022-12-13 23:06:02 | https://stackoverflow.com/q/1304626 | https://stackoverflow.com/a/1304645 | <p>You need a clean state to change branches. The branch checkout will only be allowed if it does not affect the 'dirty files' (as <a href="https://stackoverflow.com/users/19563/charles-bailey">Charles Bailey</a> remarks in the comments).</p>
<p>Otherwise, you should either:</p>
<ul>
<li><a href="http://git-scm.com/boo... | <p>You need a clean state to change branches. The branch checkout will only be allowed if it does not affect the 'dirty files' (as <a href="https://stackoverflow.com/users/19563/charles-bailey">Charles Bailey</a> remarks in the comments).</p> <p>Otherwise, you should either:</p> <ul> <li><a href="http://git-scm.com/boo... | 119, 1879, 37230 | branch, git, git-checkout | <h1>Switch branch and ignore any changes without committing</h1>
<p>I was working on a git branch and was ready to commit my changes, so I made a commit with a useful commit message. I then absentmindedly made minor changes to the code that are not worth keeping. I now want to change branches, but git gives me,</p>
<b... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,284 | git | # Switch branch and ignore any changes without committing
I was working on a git branch and was ready to commit my changes, so I made a commit with a useful commit message. I then absentmindedly made minor changes to the code that are not worth keeping. I now want to change branches, but git gives me,
> error: You ha... | You need a clean state to change branches. The branch checkout will only be allowed if it does not affect the 'dirty files' (as [Charles Bailey](https://stackoverflow.com/users/19563/charles-bailey) remarks in the comments).
Otherwise, you should either:
- [stash](http://git-scm.com/book/en/v1/Git-Tools-Stashing) you... |
18308535 | Automatic prune with Git fetch or pull | 350 | 2013-08-19 07:30:21 | <p>If someone deleted a remote branch because the work is over and I don't know, I won't do a <code>git fetch --prune</code> and eventually I will push back the deleted branch.</p>
<p>Is there a viable solution for forcing Git to use the prune mode when fetching / pulling without having to specify it every time?</p>
| 205,188 | 701,829 | 2021-05-24 16:42:35 | 18,718,936 | 546 | 2013-09-10 12:25:39 | 6,309 | 2018-01-22 12:08:37 | https://stackoverflow.com/q/18308535 | https://stackoverflow.com/a/18718936 | <p><a href="https://github.com/git/git/blob/bb80ee09974667a1db6bbc5e33574ed869b76a88/Documentation/RelNotes/1.8.5.txt#L99-L101" rel="noreferrer">Since git 1.8.5 (Q4 2013)</a>:</p>
<blockquote>
<p>"<code>git fetch</code>" (hence "<code>git pull</code>" as well) learned to check "<code>fetch.prune</code>" and "<code>r... | <p><a href="https://github.com/git/git/blob/bb80ee09974667a1db6bbc5e33574ed869b76a88/Documentation/RelNotes/1.8.5.txt#L99-L101" rel="noreferrer">Since git 1.8.5 (Q4 2013)</a>:</p> <blockquote> <p>"<code>git fetch</code>" (hence "<code>git pull</code>" as well) learned to check "<code>fetch.prune</code>" and "<code>r... | 119 | git | <h1>Automatic prune with Git fetch or pull</h1>
<p>If someone deleted a remote branch because the work is over and I don't know, I won't do a <code>git fetch --prune</code> and eventually I will push back the deleted branch.</p>
<p>Is there a viable solution for forcing Git to use the prune mode when fetching / pullin... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,285 | git | # Automatic prune with Git fetch or pull
If someone deleted a remote branch because the work is over and I don't know, I won't do a `git fetch --prune` and eventually I will push back the deleted branch.
Is there a viable solution for forcing Git to use the prune mode when fetching / pulling without having to specify... | [Since git 1.8.5 (Q4 2013)](https://github.com/git/git/blob/bb80ee09974667a1db6bbc5e33574ed869b76a88/Documentation/RelNotes/1.8.5.txt#L99-L101):
> "`git fetch`" (hence "`git pull`" as well) learned to check "`fetch.prune`" and "`remote.*.prune`" configuration variables and to behave as if the "`--prune`" command line ... |
3319479 | Can I 'git commit' a file and ignore its content changes? | 452 | 2010-07-23 15:10:36 | <p>Our developers have their own local configurations stored in a file called <code>devtargets.rb</code> which is used in our rake build tasks. I don't want developers to clobber each other's devtargets file.</p>
<p>My first thought was to put that file in the <code>.gitignore</code> list so that it is not committed to... | 112,094 | 93,448 | 2026-01-24 16:32:39 | 3,320,183 | 542 | 2010-07-23 16:20:02 | 1,665 | 2017-02-01 16:47:54 | https://stackoverflow.com/q/3319479 | https://stackoverflow.com/a/3320183 | <p>Sure, I do exactly this from time to time using</p>
<pre><code>git update-index --assume-unchanged [<file> ...]
</code></pre>
<p>To undo and start tracking again (if you forgot what files were untracked, <a href="https://stackoverflow.com/questions/2363197">see this question</a>):</p>
<pre><code>git update-ind... | <p>Sure, I do exactly this from time to time using</p> <pre><code>git update-index --assume-unchanged [<file> ...] </code></pre> <p>To undo and start tracking again (if you forgot what files were untracked, <a href="https://stackoverflow.com/questions/2363197">see this question</a>):</p> <pre><code>git update-ind... | 119, 25056 | git, gitignore | <h1>Can I 'git commit' a file and ignore its content changes?</h1>
<p>Our developers have their own local configurations stored in a file called <code>devtargets.rb</code> which is used in our rake build tasks. I don't want developers to clobber each other's devtargets file.</p>
<p>My first thought was to put that file... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,286 | git | # Can I 'git commit' a file and ignore its content changes?
Our developers have their own local configurations stored in a file called `devtargets.rb` which is used in our rake build tasks. I don't want developers to clobber each other's devtargets file.
My first thought was to put that file in the `.gitignore` list ... | Sure, I do exactly this from time to time using
```
git update-index --assume-unchanged [<file> ...]
```
To undo and start tracking again (if you forgot what files were untracked, [see this question](https://stackoverflow.com/questions/2363197)):
```
git update-index --no-assume-unchanged [<file> ...]
```
[Relevant... |
8728093 | How do I "un-revert" a reverted Git commit? | 904 | 2012-01-04 13:59:25 | <p>Given a change that has been committed using <code>commit</code>, and then reverted using <code>revert</code>, what is the best way to then undo that revert?</p>
<p>Ideally, this should be done with a new commit, so as to not re-write history.</p>
| 774,521 | 778,572 | 2024-02-01 09:47:47 | 8,730,046 | 541 | 2012-01-04 16:14:25 | 1,864,976 | 2013-09-05 10:07:34 | https://stackoverflow.com/q/8728093 | https://stackoverflow.com/a/8730046 | <p>If you haven't pushed that change yet, <code>git reset --hard HEAD^</code></p>
<p>Otherwise, reverting the revert is perfectly fine.</p>
<p>Another way is to <code>git checkout HEAD^^ -- .</code> and then <code>git add -A && git commit</code>.</p>
| <p>If you haven't pushed that change yet, <code>git reset --hard HEAD^</code></p> <p>Otherwise, reverting the revert is perfectly fine.</p> <p>Another way is to <code>git checkout HEAD^^ -- .</code> and then <code>git add -A && git commit</code>.</p> | 119, 5766, 12309 | git, revert, undo | <h1>How do I "un-revert" a reverted Git commit?</h1>
<p>Given a change that has been committed using <code>commit</code>, and then reverted using <code>revert</code>, what is the best way to then undo that revert?</p>
<p>Ideally, this should be done with a new commit, so as to not re-write history.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,287 | git | # How do I "un-revert" a reverted Git commit?
Given a change that has been committed using `commit`, and then reverted using `revert`, what is the best way to then undo that revert?
Ideally, this should be done with a new commit, so as to not re-write history. | If you haven't pushed that change yet, `git reset --hard HEAD^`
Otherwise, reverting the revert is perfectly fine.
Another way is to `git checkout HEAD^^ -- .` and then `git add -A && git commit`. |
2432579 | git: Your branch is ahead by X commits | 487 | 2010-03-12 12:15:54 | <p>How does this actually come about?</p>
<p>I am working in one repo by myself at the moment, so this is my workflow:</p>
<ol>
<li>Change files</li>
<li>Commit</li>
<li>Repeat 1-2 until satisfied</li>
<li>Push to master</li>
</ol>
<p>Then when I do a <code>git status</code> it tells me that my branch is <em>ahead b... | 639,353 | 75,924 | 2022-06-08 22:46:13 | 3,323,933 | 541 | 2010-07-24 05:26:11 | 114,658 | 2015-07-06 19:59:59 | https://stackoverflow.com/q/2432579 | https://stackoverflow.com/a/3323933 | <p>If you get this message after doing a <code>git pull remote branch</code>, try following it up with a <code>git fetch</code>. (Optionally, run <code>git fetch -p</code> to prune deleted branches from the repo)</p>
<p>Fetch seems to update the local representation of the remote branch, which doesn't necessarily happ... | <p>If you get this message after doing a <code>git pull remote branch</code>, try following it up with a <code>git fetch</code>. (Optionally, run <code>git fetch -p</code> to prune deleted branches from the repo)</p> <p>Fetch seems to update the local representation of the remote branch, which doesn't necessarily happ... | 119, 53850 | git, git-commit | <h1>git: Your branch is ahead by X commits</h1>
<p>How does this actually come about?</p>
<p>I am working in one repo by myself at the moment, so this is my workflow:</p>
<ol>
<li>Change files</li>
<li>Commit</li>
<li>Repeat 1-2 until satisfied</li>
<li>Push to master</li>
</ol>
<p>Then when I do a <code>git status<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,288 | git | # git: Your branch is ahead by X commits
How does this actually come about?
I am working in one repo by myself at the moment, so this is my workflow:
1. Change files
2. Commit
3. Repeat 1-2 until satisfied
4. Push to master
Then when I do a `git status` it tells me that my branch is *ahead by X commits* (presumably... | If you get this message after doing a `git pull remote branch`, try following it up with a `git fetch`. (Optionally, run `git fetch -p` to prune deleted branches from the repo)
Fetch seems to update the local representation of the remote branch, which doesn't necessarily happen when you do a `git pull remote branch`. |
6436681 | How to stage only part of a new file with git? | 276 | 2011-06-22 07:58:17 | <p>I <strong>love</strong> <em>git add --interactive</em>. It is now part of my daily workflow.</p>
<p>The problem seems that it does not work with untracked files. What I want to do is track a new file, but only add part of it, i.e. some parts of this new file are not yet ready to be staged. </p>
<p>For example, wit... | 26,220 | 401,523 | 2025-09-27 18:40:57 | 6,440,500 | 541 | 2011-06-22 13:16:58 | 712,605 | 2025-09-27 18:39:44 | https://stackoverflow.com/q/6436681 | https://stackoverflow.com/a/6440500 | <p>Whoa, all that <code>update-index</code> and <code>hash-object</code> business seems overly complicated. How about this instead:</p>
<pre class="lang-bash prettyprint-override"><code>git add -N new_file
git add -i # or 'git add -p' if you prefer
</code></pre>
<p>From <code>git help add</code>:</p>
<pre><code>-N, -... | <p>Whoa, all that <code>update-index</code> and <code>hash-object</code> business seems overly complicated. How about this instead:</p> <pre class="lang-bash prettyprint-override"><code>git add -N new_file git add -i # or 'git add -p' if you prefer </code></pre> <p>From <code>git help add</code>:</p> <pre><code>-N, -... | 119 | git | <h1>How to stage only part of a new file with git?</h1>
<p>I <strong>love</strong> <em>git add --interactive</em>. It is now part of my daily workflow.</p>
<p>The problem seems that it does not work with untracked files. What I want to do is track a new file, but only add part of it, i.e. some parts of this new file a... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,289 | git | # How to stage only part of a new file with git?
I **love** *git add --interactive*. It is now part of my daily workflow.
The problem seems that it does not work with untracked files. What I want to do is track a new file, but only add part of it, i.e. some parts of this new file are not yet ready to be staged.
For ... | Whoa, all that `update-index` and `hash-object` business seems overly complicated. How about this instead:
```
git add -N new_file
git add -i # or 'git add -p' if you prefer
```
From `git help add`:
```
-N, --intent-to-add
Record only the fact that the path will be added later. An entry
for the path is pla... |
22053757 | Checkout another branch when there are uncommitted changes on the current branch | 523 | 2014-02-26 21:29:13 | <p>Most of the time when I try to checkout another existing branch, Git doesn't allow me if I have some uncommitted changes on the current branch. So I'll have to commit or stash those changes first. </p>
<p>However, occasionally Git does allow me to checkout another branch without committing or stashing those changes... | 320,915 | 3,285,487 | 2023-12-09 22:13:22 | 22,055,552 | 540 | 2014-02-26 23:10:52 | 1,256,452 | 2020-12-12 01:32:10 | https://stackoverflow.com/q/22053757 | https://stackoverflow.com/a/22055552 | <h3>Preliminary notes</h3>
<p>This answer is an attempt to explain <em>why</em> Git behaves the way it does. It is not a recommendation to engage in any particular workflows. (My own preference is to just commit anyway, avoiding <code>git stash</code> and not trying to be too tricky, but others like other methods.)</... | <h3>Preliminary notes</h3> <p>This answer is an attempt to explain <em>why</em> Git behaves the way it does. It is not a recommendation to engage in any particular workflows. (My own preference is to just commit anyway, avoiding <code>git stash</code> and not trying to be too tricky, but others like other methods.)</... | 119 | git | <h1>Checkout another branch when there are uncommitted changes on the current branch</h1>
<p>Most of the time when I try to checkout another existing branch, Git doesn't allow me if I have some uncommitted changes on the current branch. So I'll have to commit or stash those changes first. </p>
<p>However, occasionally... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,290 | git | # Checkout another branch when there are uncommitted changes on the current branch
Most of the time when I try to checkout another existing branch, Git doesn't allow me if I have some uncommitted changes on the current branch. So I'll have to commit or stash those changes first.
However, occasionally Git does allow m... | ### Preliminary notes
This answer is an attempt to explain *why* Git behaves the way it does. It is not a recommendation to engage in any particular workflows. (My own preference is to just commit anyway, avoiding `git stash` and not trying to be too tricky, but others like other methods.)
The observation here is tha... |
14409420 | Restart/undo conflict resolution in a single file | 297 | 2013-01-18 23:40:16 | <p>In a larger git merge with several conflicting files, I incorrectly marked a file as resolved (using <code>git add FILE</code> after some editing)</p>
<p>Now I'd like to undo my conflict resolution attempt and start over resolving that file.</p>
<p>How can I do that?</p>
| 78,451 | 1,104,870 | 2024-01-03 10:28:35 | 14,409,744 | 540 | 2013-01-19 00:18:05 | 1,104,870 | 2024-01-03 10:28:35 | https://stackoverflow.com/q/14409420 | https://stackoverflow.com/a/14409744 | <p>Use <code>git checkout</code> with <a href="https://git-scm.com/docs/git-checkout#Documentation/git-checkout.txt--m" rel="noreferrer">flag <code>--merge</code> (short version <code>-m</code>)</a>:</p>
<pre><code>git checkout --merge FILE
</code></pre>
<p>This restores the unresolved state, including all information ... | <p>Use <code>git checkout</code> with <a href="https://git-scm.com/docs/git-checkout#Documentation/git-checkout.txt--m" rel="noreferrer">flag <code>--merge</code> (short version <code>-m</code>)</a>:</p> <pre><code>git checkout --merge FILE </code></pre> <p>This restores the unresolved state, including all information ... | 119, 28897 | git, git-merge | <h1>Restart/undo conflict resolution in a single file</h1>
<p>In a larger git merge with several conflicting files, I incorrectly marked a file as resolved (using <code>git add FILE</code> after some editing)</p>
<p>Now I'd like to undo my conflict resolution attempt and start over resolving that file.</p>
<p>How can... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,291 | git | # Restart/undo conflict resolution in a single file
In a larger git merge with several conflicting files, I incorrectly marked a file as resolved (using `git add FILE` after some editing)
Now I'd like to undo my conflict resolution attempt and start over resolving that file.
How can I do that? | Use `git checkout` with [flag `--merge` (short version `-m`)](https://git-scm.com/docs/git-checkout#Documentation/git-checkout.txt--m):
```
git checkout --merge FILE
```
This restores the unresolved state, including all information about parent and merge base, which allows restarting the resolution.
This command can... |
1862423 | How to tell which commit a tag points to in Git? | 591 | 2009-12-07 19:45:17 | <p>I have a bunch of unannotated tags in the repository and I want to work out which commit they point to. Is there a command that that will just list the tags and their commit SHAs? Checking out the tag and looking at the HEAD seems a bit too laborious to me.</p>
<h2>Update</h2>
<p>I realized after I went through th... | 353,803 | 129,404 | 2025-04-01 09:48:29 | 1,862,542 | 538 | 2009-12-07 20:07:27 | 28,804 | 2021-03-22 12:13:54 | https://stackoverflow.com/q/1862423 | https://stackoverflow.com/a/1862542 | <p>One way to do this would be with <code>git rev-list</code>. The following will output the commit to which a tag points:</p>
<pre><code>$ git rev-list -n 1 $TAG
</code></pre>
<p><strong>NOTE This works for both Annotated and Unannotated tags</strong></p>
<p>You could add it as an alias in <code>~/.gitconfig</code> if... | <p>One way to do this would be with <code>git rev-list</code>. The following will output the commit to which a tag points:</p> <pre><code>$ git rev-list -n 1 $TAG </code></pre> <p><strong>NOTE This works for both Annotated and Unannotated tags</strong></p> <p>You could add it as an alias in <code>~/.gitconfig</code> if... | 119, 60718 | git, git-tag | <h1>How to tell which commit a tag points to in Git?</h1>
<p>I have a bunch of unannotated tags in the repository and I want to work out which commit they point to. Is there a command that that will just list the tags and their commit SHAs? Checking out the tag and looking at the HEAD seems a bit too laborious to me.</... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,292 | git | # How to tell which commit a tag points to in Git?
I have a bunch of unannotated tags in the repository and I want to work out which commit they point to. Is there a command that that will just list the tags and their commit SHAs? Checking out the tag and looking at the HEAD seems a bit too laborious to me.
## Update... | One way to do this would be with `git rev-list`. The following will output the commit to which a tag points:
```
$ git rev-list -n 1 $TAG
```
**NOTE This works for both Annotated and Unannotated tags**
You could add it as an alias in `~/.gitconfig` if you use it a lot:
```
[alias]
tagcommit = rev-list -n 1
```
A... |
21651185 | How to merge a remote branch locally | 339 | 2014-02-08 20:06:03 | <p>I've pulled all remote branches via <code>git fetch --all</code>. I can see the branch I'd like to merge via <code>git branch -a</code> as remotes/origin/branchname. Problem is it is not accessible. I can't merge or checkout.</p>
| 765,899 | 2,694,165 | 2024-05-17 09:20:27 | 21,653,559 | 535 | 2014-02-09 00:23:15 | 6,309 | 2022-01-05 17:19:57 | https://stackoverflow.com/q/21651185 | https://stackoverflow.com/a/21653559 | <p>You can reference those remote tracking branches ~(listed with <code>git branch -r</code>) with the name of their remote.</p>
<p>You need to fetch the remote branch:</p>
<pre><code>git fetch origin aRemoteBranch
</code></pre>
<p>If you want to merge one of those remote branches on your local branch:</p>
<pre><code>g... | <p>You can reference those remote tracking branches ~(listed with <code>git branch -r</code>) with the name of their remote.</p> <p>You need to fetch the remote branch:</p> <pre><code>git fetch origin aRemoteBranch </code></pre> <p>If you want to merge one of those remote branches on your local branch:</p> <pre><code>g... | 119, 1879, 76220 | branch, git, git-branch | <h1>How to merge a remote branch locally</h1>
<p>I've pulled all remote branches via <code>git fetch --all</code>. I can see the branch I'd like to merge via <code>git branch -a</code> as remotes/origin/branchname. Problem is it is not accessible. I can't merge or checkout.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,293 | git | # How to merge a remote branch locally
I've pulled all remote branches via `git fetch --all`. I can see the branch I'd like to merge via `git branch -a` as remotes/origin/branchname. Problem is it is not accessible. I can't merge or checkout. | You can reference those remote tracking branches ~(listed with `git branch -r`) with the name of their remote.
You need to fetch the remote branch:
```
git fetch origin aRemoteBranch
```
If you want to merge one of those remote branches on your local branch:
```
git checkout aLocalBranch
git merge origin/aRemoteBra... |
4380945 | Exclude a directory from 'git diff' | 313 | 2010-12-07 19:51:25 | <p>How can I exclude an entire directory from my Git diff (in this case <em>/spec</em>)?</p>
<p>I'm creating a diff for our entire software release using the <code>git diff</code> command. However, the changes to the <em>spec</em> folder are irrelevant for this procedure, and just create headaches. Now I know I can do... | 138,326 | 454,344 | 2024-05-29 12:20:00 | 29,374,503 | 535 | 2015-03-31 17:12:30 | 442,698 | 2024-05-29 10:45:02 | https://stackoverflow.com/q/4380945 | https://stackoverflow.com/a/29374503 | <p>Based on <a href="https://stackoverflow.com/a/21079437/442698">this answer</a>, you can also use:</p>
<pre class="lang-none prettyprint-override"><code>git diff previous_release..current_release -- . ':!spec'
</code></pre>
<p>This is a newish Git feature which allows excluding certain paths. It should be more reliab... | <p>Based on <a href="https://stackoverflow.com/a/21079437/442698">this answer</a>, you can also use:</p> <pre class="lang-none prettyprint-override"><code>git diff previous_release..current_release -- . ':!spec' </code></pre> <p>This is a newish Git feature which allows excluding certain paths. It should be more reliab... | 119 | git | <h1>Exclude a directory from 'git diff'</h1>
<p>How can I exclude an entire directory from my Git diff (in this case <em>/spec</em>)?</p>
<p>I'm creating a diff for our entire software release using the <code>git diff</code> command. However, the changes to the <em>spec</em> folder are irrelevant for this procedure, a... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,294 | git | # Exclude a directory from 'git diff'
How can I exclude an entire directory from my Git diff (in this case */spec*)?
I'm creating a diff for our entire software release using the `git diff` command. However, the changes to the *spec* folder are irrelevant for this procedure, and just create headaches. Now I know I ca... | Based on [this answer](https://stackoverflow.com/a/21079437/442698), you can also use:
```
git diff previous_release..current_release -- . ':!spec'
```
This is a newish Git feature which allows excluding certain paths. It should be more reliable than various shell one-liners.
I'm posting this here because this quest... |
13846300 | How can I make "git pull" use rebase by default for all my repositories? | 445 | 2012-12-12 18:33:20 | <p>Is there a way to setup the host Git repository such that any <code>git pull</code> done from its (local) clones uses <code>--rebase</code> by default? By searching on Stack Overflow, I learned about <code>branch.autosetuprebase</code>, but it needs to be configured per clone individually. </p>
<p>My project f... | 397,043 | 252,576 | 2025-05-04 18:00:41 | 13,974,638 | 533 | 2012-12-20 14:45:11 | 4,757 | 2018-10-18 18:30:04 | https://stackoverflow.com/q/13846300 | https://stackoverflow.com/a/13974638 | <p>There are now 3 different levels of configuration for default pull behaviour. From most general to most fine grained they are:</p>
<h3>1. <code>pull.rebase</code></h3>
<p>Setting this to <code>true</code> means that <code>git pull</code> is always equivalent to <code>git pull --rebase</code> (unless <code>branch.&... | <p>There are now 3 different levels of configuration for default pull behaviour. From most general to most fine grained they are:</p> <h3>1. <code>pull.rebase</code></h3> <p>Setting this to <code>true</code> means that <code>git pull</code> is always equivalent to <code>git pull --rebase</code> (unless <code>branch.&... | 119 | git | <h1>How can I make "git pull" use rebase by default for all my repositories?</h1>
<p>Is there a way to setup the host Git repository such that any <code>git pull</code> done from its (local) clones uses <code>--rebase</code> by default? By searching on Stack Overflow, I learned about <code>branch.autosetuprebase</... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,295 | git | # How can I make "git pull" use rebase by default for all my repositories?
Is there a way to setup the host Git repository such that any `git pull` done from its (local) clones uses `--rebase` by default? By searching on Stack Overflow, I learned about `branch.autosetuprebase`, but it needs to be configured per clone ... | There are now 3 different levels of configuration for default pull behaviour. From most general to most fine grained they are:
### 1. `pull.rebase`
Setting this to `true` means that `git pull` is always equivalent to `git pull --rebase` (unless `branch.<branchname>.rebase` is explicitly set to `false`). This can also... |
5698148 | Where does the .gitignore file belong? | 493 | 2011-04-18 03:14:48 | <p>Does the .gitignore file belong in the .git folder structure somewhere or in the main source files?</p>
| 389,854 | 541,262 | 2022-11-03 11:49:12 | 19,098,654 | 530 | 2013-09-30 15:58:21 | 2,831,854 | 2013-09-30 15:58:21 | https://stackoverflow.com/q/5698148 | https://stackoverflow.com/a/19098654 | <p>Put .gitignore in the <em>working</em> directory. It doesn't work if you put it in the .git (repository) directory. </p>
<pre><code>$ ls -1d .git*
.git
.gitignore
</code></pre>
| <p>Put .gitignore in the <em>working</em> directory. It doesn't work if you put it in the .git (repository) directory. </p> <pre><code>$ ls -1d .git* .git .gitignore </code></pre> | 119, 25056 | git, gitignore | <h1>Where does the .gitignore file belong?</h1>
<p>Does the .gitignore file belong in the .git folder structure somewhere or in the main source files?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,297 | git | # Where does the .gitignore file belong?
Does the .gitignore file belong in the .git folder structure somewhere or in the main source files? | Put .gitignore in the *working* directory. It doesn't work if you put it in the .git (repository) directory.
```
$ ls -1d .git*
.git
.gitignore
``` |
2363197 | Can I get a list of files marked --assume-unchanged? | 397 | 2010-03-02 13:00:48 | <p>What have I marked as <code>--assume-unchanged</code>? Is there any way to find out what I've tucked away using that option?</p>
<p>I've dug through the <code>.git/</code> directory and don't see anything that looks like what I'd expect, but it must be somewhere. I've forgotten what I marked this way a few weeks ag... | 61,839 | 1,665 | 2024-06-15 12:06:03 | 2,363,495 | 529 | 2010-03-02 13:48:16 | 24,762 | 2024-06-15 12:05:10 | https://stackoverflow.com/q/2363197 | https://stackoverflow.com/a/2363495 | <p>You can use <a href="http://git-scm.com/docs/git-ls-files" rel="noreferrer"><code>git ls-files -v</code></a>. If the character printed is lower-case, the file is marked assume-unchanged.</p>
<p>To print just the files that are unchanged use:</p>
<pre class="lang-bash prettyprint-override"><code>git ls-files -v | gr... | <p>You can use <a href="http://git-scm.com/docs/git-ls-files" rel="noreferrer"><code>git ls-files -v</code></a>. If the character printed is lower-case, the file is marked assume-unchanged.</p> <p>To print just the files that are unchanged use:</p> <pre class="lang-bash prettyprint-override"><code>git ls-files -v | gr... | 119 | git | <h1>Can I get a list of files marked --assume-unchanged?</h1>
<p>What have I marked as <code>--assume-unchanged</code>? Is there any way to find out what I've tucked away using that option?</p>
<p>I've dug through the <code>.git/</code> directory and don't see anything that looks like what I'd expect, but it must be s... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,299 | git | # Can I get a list of files marked --assume-unchanged?
What have I marked as `--assume-unchanged`? Is there any way to find out what I've tucked away using that option?
I've dug through the `.git/` directory and don't see anything that looks like what I'd expect, but it must be somewhere. I've forgotten what I marked... | You can use [`git ls-files -v`](http://git-scm.com/docs/git-ls-files). If the character printed is lower-case, the file is marked assume-unchanged.
To print just the files that are unchanged use:
```
git ls-files -v | grep '^[[:lower:]]'
```
To embrace your lazy programmer, turn this into a [git alias](https://git.w... |
11657295 | Count the number of commits on a Git branch | 285 | 2012-07-25 19:37:52 | <p>I found this answer already: <a href="https://stackoverflow.com/questions/10913892/number-of-commits-on-branch-in-git">Number of commits on branch in git</a>
but that assumes that the branch was created from master.</p>
<p>How can I count the number of commits along a branch <em>without</em> relying on that assumpt... | 185,513 | 1,135,138 | 2026-01-06 14:06:06 | 11,657,647 | 528 | 2012-07-25 19:58:39 | 337,297 | 2014-08-19 17:39:24 | https://stackoverflow.com/q/11657295 | https://stackoverflow.com/a/11657647 | <p>To count the commits for the branch you are on:</p>
<pre><code>git rev-list --count HEAD
</code></pre>
<p>for a branch</p>
<pre><code>git rev-list --count <branch-name>
</code></pre>
<p>If you want to count the commits on a branch that are made since you created the branch</p>
<pre><code>git rev-list --co... | <p>To count the commits for the branch you are on:</p> <pre><code>git rev-list --count HEAD </code></pre> <p>for a branch</p> <pre><code>git rev-list --count <branch-name> </code></pre> <p>If you want to count the commits on a branch that are made since you created the branch</p> <pre><code>git rev-list --co... | 119 | git | <h1>Count the number of commits on a Git branch</h1>
<p>I found this answer already: <a href="https://stackoverflow.com/questions/10913892/number-of-commits-on-branch-in-git">Number of commits on branch in git</a>
but that assumes that the branch was created from master.</p>
<p>How can I count the number of commits al... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,300 | git | # Count the number of commits on a Git branch
I found this answer already: [Number of commits on branch in git](https://stackoverflow.com/questions/10913892/number-of-commits-on-branch-in-git)
but that assumes that the branch was created from master.
How can I count the number of commits along a branch *without* rely... | To count the commits for the branch you are on:
```
git rev-list --count HEAD
```
for a branch
```
git rev-list --count <branch-name>
```
If you want to count the commits on a branch that are made since you created the branch
```
git rev-list --count HEAD ^<branch-name>
```
This will count all commits ever made t... |
5083224 | git pull while not in a git directory | 365 | 2011-02-22 19:58:57 | <p>Let's say I have a directory, <code>/X/Y</code>, which is a git repository. Is it possible to somehow call a command like <code>git pull</code> from inside <code>/X</code>, but targeting the <code>/X/Y</code> directory?</p>
<p><strong>EDIT:</strong> I guess I was wondering specifically: is it possible to do this us... | 175,179 | 528,317 | 2020-02-06 10:18:23 | 20,115,526 | 527 | 2013-11-21 08:09:31 | 6,309 | 2020-02-06 10:18:23 | https://stackoverflow.com/q/5083224 | https://stackoverflow.com/a/20115526 | <p>Starting <a href="https://github.com/git/git/blob/5fd09df3937f54c5cfda4f1087f5d99433cce527/Documentation/RelNotes/1.8.5.txt#L115-L116" rel="noreferrer">git 1.8.5 (Q4 2013)</a>, you will be able to "use a Git command, but without having to change directories".</p>
<blockquote>
<p>Just like "<code>make -C <direc... | <p>Starting <a href="https://github.com/git/git/blob/5fd09df3937f54c5cfda4f1087f5d99433cce527/Documentation/RelNotes/1.8.5.txt#L115-L116" rel="noreferrer">git 1.8.5 (Q4 2013)</a>, you will be able to "use a Git command, but without having to change directories".</p> <blockquote> <p>Just like "<code>make -C <direc... | 119 | git | <h1>git pull while not in a git directory</h1>
<p>Let's say I have a directory, <code>/X/Y</code>, which is a git repository. Is it possible to somehow call a command like <code>git pull</code> from inside <code>/X</code>, but targeting the <code>/X/Y</code> directory?</p>
<p><strong>EDIT:</strong> I guess I was wonde... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,301 | git | # git pull while not in a git directory
Let's say I have a directory, `/X/Y`, which is a git repository. Is it possible to somehow call a command like `git pull` from inside `/X`, but targeting the `/X/Y` directory?
**EDIT:** I guess I was wondering specifically: is it possible to do this using the a git command, but... | Starting [git 1.8.5 (Q4 2013)](https://github.com/git/git/blob/5fd09df3937f54c5cfda4f1087f5d99433cce527/Documentation/RelNotes/1.8.5.txt#L115-L116), you will be able to "use a Git command, but without having to change directories".
> Just like "`make -C <directory>`", **"`git -C <directory> ...`" tells Git to go there... |
2337281 | How do I do an initial push to a remote repository with Git? | 248 | 2010-02-25 20:15:57 | <p>I've read through countless tutorials and I keep coming up short. Here's what I've got:</p>
<ul>
<li>I'm running RubyMine on my Windows desktop</li>
<li>I've installed Git on my WebFaction hosting account per their <a href="http://docs.webfaction.com/software/git.html?highlight=git#create-a-place-to-store-git-reposi... | 599,651 | 310,091 | 2022-03-23 06:11:51 | 2,337,373 | 527 | 2010-02-25 20:27:21 | 155,094 | 2010-02-25 20:27:21 | https://stackoverflow.com/q/2337281 | https://stackoverflow.com/a/2337373 | <p>On server:</p>
<pre><code>mkdir my_project.git
cd my_project.git
git --bare init
</code></pre>
<p>On client:</p>
<pre><code>mkdir my_project
cd my_project
touch .gitignore
git init
git add .
git commit -m "Initial commit"
git remote add origin youruser@yourserver.com:/path/to/my_project.git
git push origin master... | <p>On server:</p> <pre><code>mkdir my_project.git cd my_project.git git --bare init </code></pre> <p>On client:</p> <pre><code>mkdir my_project cd my_project touch .gitignore git init git add . git commit -m "Initial commit" git remote add origin youruser@yourserver.com:/path/to/my_project.git git push origin master... | 119, 456 | git, version-control | <h1>How do I do an initial push to a remote repository with Git?</h1>
<p>I've read through countless tutorials and I keep coming up short. Here's what I've got:</p>
<ul>
<li>I'm running RubyMine on my Windows desktop</li>
<li>I've installed Git on my WebFaction hosting account per their <a href="http://docs.webfaction.... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,302 | git | # How do I do an initial push to a remote repository with Git?
I've read through countless tutorials and I keep coming up short. Here's what I've got:
- I'm running RubyMine on my Windows desktop
- I've installed Git on my WebFaction hosting account per their [instructions](http://docs.webfaction.com/software/git.htm... | On server:
```
mkdir my_project.git
cd my_project.git
git --bare init
```
On client:
```
mkdir my_project
cd my_project
touch .gitignore
git init
git add .
git commit -m "Initial commit"
git remote add origin youruser@yourserver.com:/path/to/my_project.git
git push origin master
```
Note that when you add the origi... |
7214039 | How do you move a commit to the staging area in git? | 301 | 2011-08-27 10:48:13 | <p>If you want to move a commit to the staging area - that is uncommit it and move all of the changes which were in it into the staging area (effectively putting the branch in the state that it would have been in prior to the commit) - how do you do it? Or is it something that you can't do?</p>
<p>The closest that I k... | 199,430 | 160,887 | 2025-08-22 13:15:23 | 7,214,061 | 526 | 2011-08-27 10:52:43 | 41,116 | 2018-04-27 21:09:38 | https://stackoverflow.com/q/7214039 | https://stackoverflow.com/a/7214061 | <pre><code>git reset --soft HEAD^
</code></pre>
<p>This will reset your index to <code>HEAD^</code> (the previous commit) but leave your changes in the staging area.</p>
<p>There are some <a href="https://git-scm.com/docs/git-reset#_discussion" rel="noreferrer">handy diagrams</a> in the <a href="http://git-scm.com/do... | <pre><code>git reset --soft HEAD^ </code></pre> <p>This will reset your index to <code>HEAD^</code> (the previous commit) but leave your changes in the staging area.</p> <p>There are some <a href="https://git-scm.com/docs/git-reset#_discussion" rel="noreferrer">handy diagrams</a> in the <a href="http://git-scm.com/do... | 119, 5597, 20002 | commit, git, staging | <h1>How do you move a commit to the staging area in git?</h1>
<p>If you want to move a commit to the staging area - that is uncommit it and move all of the changes which were in it into the staging area (effectively putting the branch in the state that it would have been in prior to the commit) - how do you do it? Or i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,303 | git | # How do you move a commit to the staging area in git?
If you want to move a commit to the staging area - that is uncommit it and move all of the changes which were in it into the staging area (effectively putting the branch in the state that it would have been in prior to the commit) - how do you do it? Or is it some... | ```
git reset --soft HEAD^
```
This will reset your index to `HEAD^` (the previous commit) but leave your changes in the staging area.
There are some [handy diagrams](https://git-scm.com/docs/git-reset#_discussion) in the [`git-reset`](http://git-scm.com/docs/git-reset) docs
If you are on Windows you might need to u... |
44702757 | How to remove all git origin and local tags? | 213 | 2017-06-22 14:48:33 | <p>How do you remove a git tag that has already been pushed?
Delete all git remote (origin) tags and Delete all git local tags.</p>
| 103,614 | 2,858,268 | 2024-12-06 13:01:00 | 44,702,758 | 526 | 2017-06-22 14:48:33 | 2,858,268 | 2024-03-12 10:43:35 | https://stackoverflow.com/q/44702757 | https://stackoverflow.com/a/44702758 | <ol>
<li>Delete All local tags. (Optional Recommended)
<pre class="lang-bash prettyprint-override"><code># Clears out all your local
git tag -d $(git tag -l)
</code></pre>
</li>
<li>Fetch remote All tags. (Optional Recommended)
<pre class="lang-bash prettyprint-override"><code># All remote tags give you a complete lis... | <ol> <li>Delete All local tags. (Optional Recommended) <pre class="lang-bash prettyprint-override"><code># Clears out all your local git tag -d $(git tag -l) </code></pre> </li> <li>Fetch remote All tags. (Optional Recommended) <pre class="lang-bash prettyprint-override"><code># All remote tags give you a complete lis... | 115, 119, 45426 | git, removeall, tags | <h1>How to remove all git origin and local tags?</h1>
<p>How do you remove a git tag that has already been pushed?
Delete all git remote (origin) tags and Delete all git local tags.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,304 | git | # How to remove all git origin and local tags?
How do you remove a git tag that has already been pushed?
Delete all git remote (origin) tags and Delete all git local tags. | 1. Delete All local tags. (Optional Recommended)
```
# Clears out all your local
git tag -d $(git tag -l)
```
2. Fetch remote All tags. (Optional Recommended)
```
# All remote tags give you a complete list of remote tags locally
git fetch
```
3. Delete All remote tags.
```
# Note: push... |
5827944 | Git error on commit after merge - fatal: cannot do a partial commit during a merge | 356 | 2011-04-29 04:36:59 | <p>I ran a <code>git pull</code> that ended in a conflict. I resolved the conflict and everything is fine now (I used mergetool also).</p>
<p>When I commit the resolved file with <code>git commit file.php -m "message"</code> I get the error:</p>
<pre><code>fatal: cannot do a partial commit during a merge.
</code></p... | 444,617 | 134,143 | 2023-12-11 07:18:48 | 8,062,976 | 525 | 2011-11-09 09:39:50 | 324,106 | 2011-11-09 09:39:50 | https://stackoverflow.com/q/5827944 | https://stackoverflow.com/a/8062976 | <p>I found that adding "-i" to the commit command fixes this problem for me. The -i basically tells it to stage additional files before committing.
That is:</p>
<pre><code>git commit -i myfile.php
</code></pre>
| <p>I found that adding "-i" to the commit command fixes this problem for me. The -i basically tells it to stage additional files before committing. That is:</p> <pre><code>git commit -i myfile.php </code></pre> | 119, 5597, 28897, 106113 | commit, git, git-merge, git-merge-conflict | <h1>Git error on commit after merge - fatal: cannot do a partial commit during a merge</h1>
<p>I ran a <code>git pull</code> that ended in a conflict. I resolved the conflict and everything is fine now (I used mergetool also).</p>
<p>When I commit the resolved file with <code>git commit file.php -m "message"</code> I... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,305 | git | # Git error on commit after merge - fatal: cannot do a partial commit during a merge
I ran a `git pull` that ended in a conflict. I resolved the conflict and everything is fine now (I used mergetool also).
When I commit the resolved file with `git commit file.php -m "message"` I get the error:
```
fatal: cannot do a... | I found that adding "-i" to the commit command fixes this problem for me. The -i basically tells it to stage additional files before committing.
That is:
```
git commit -i myfile.php
``` |
13685920 | Install specific git commit with pip | 305 | 2012-12-03 15:03:30 | <p>I'm developing a django app and I'm using pip to manage my requirements. How can I do to install a specific git's commit?</p>
<p>In my case I need to install this commit:
<a href="https://github.com/aladagemre/django-notification/commit/2927346f4c513a217ac8ad076e494dd1adbf70e1">https://github.com/aladagemre/django-... | 176,992 | 1,522,618 | 2025-11-17 12:54:34 | 13,754,517 | 523 | 2012-12-06 23:29:31 | 565,999 | 2022-05-20 08:36:36 | https://stackoverflow.com/q/13685920 | https://stackoverflow.com/a/13754517 | <p>You can specify commit hash, branch name, tag.</p>
<p>For the branch name and the tag, you can also install a compressed distribution. This is faster and more efficient, as it does not require cloning the entire repository. GitHub creates those bundles automatically.</p>
<p><strong>hash:</strong></p>
<pre><code>$ pi... | <p>You can specify commit hash, branch name, tag.</p> <p>For the branch name and the tag, you can also install a compressed distribution. This is faster and more efficient, as it does not require cloning the entire repository. GitHub creates those bundles automatically.</p> <p><strong>hash:</strong></p> <pre><code>$ pi... | 119, 529, 5119, 5597 | commit, git, installation, pip | <h1>Install specific git commit with pip</h1>
<p>I'm developing a django app and I'm using pip to manage my requirements. How can I do to install a specific git's commit?</p>
<p>In my case I need to install this commit:
<a href="https://github.com/aladagemre/django-notification/commit/2927346f4c513a217ac8ad076e494dd1a... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,306 | git | # Install specific git commit with pip
I'm developing a django app and I'm using pip to manage my requirements. How can I do to install a specific git's commit?
In my case I need to install this commit:
<https://github.com/aladagemre/django-notification/commit/2927346f4c513a217ac8ad076e494dd1adbf70e1> | You can specify commit hash, branch name, tag.
For the branch name and the tag, you can also install a compressed distribution. This is faster and more efficient, as it does not require cloning the entire repository. GitHub creates those bundles automatically.
**hash:**
```
$ pip install git+https://github.com/alada... |
1425892 | How do you merge two Git repositories? | 2,345 | 2009-09-15 08:31:54 | <p>Consider the following scenario:</p>
<p>I have developed a small experimental project A in its own Git repo. It has now matured, and I'd like A to be part of larger project B, which has its own big repository. I'd now like to add A as a subdirectory of B.</p>
<p>How do I merge A into B, without losing history on a... | 814,645 | 164,171 | 2025-11-20 18:08:22 | 14,992,078 | 521 | 2013-02-20 23:44:27 | 199,607 | 2018-05-07 10:44:36 | https://stackoverflow.com/q/1425892 | https://stackoverflow.com/a/14992078 | <p>A single branch of another repository can be easily placed under a subdirectory retaining its history. For example:</p>
<pre><code>git subtree add --prefix=rails git://github.com/rails/rails.git master
</code></pre>
<p>This will appear as a single commit where all files of Rails master branch are added into "rails... | <p>A single branch of another repository can be easily placed under a subdirectory retaining its history. For example:</p> <pre><code>git subtree add --prefix=rails git://github.com/rails/rails.git master </code></pre> <p>This will appear as a single commit where all files of Rails master branch are added into "rails... | 119, 717, 7330, 68200 | git, git-subtree, merge, repository | <h1>How do you merge two Git repositories?</h1>
<p>Consider the following scenario:</p>
<p>I have developed a small experimental project A in its own Git repo. It has now matured, and I'd like A to be part of larger project B, which has its own big repository. I'd now like to add A as a subdirectory of B.</p>
<p>How ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,308 | git | # How do you merge two Git repositories?
Consider the following scenario:
I have developed a small experimental project A in its own Git repo. It has now matured, and I'd like A to be part of larger project B, which has its own big repository. I'd now like to add A as a subdirectory of B.
How do I merge A into B, wi... | A single branch of another repository can be easily placed under a subdirectory retaining its history. For example:
```
git subtree add --prefix=rails git://github.com/rails/rails.git master
```
This will appear as a single commit where all files of Rails master branch are added into "rails" directory.
However the co... |
1683531 | How to import existing Git repository into another? | 597 | 2009-11-05 20:55:03 | <p>I have a Git repository in a folder called <strong>XXX</strong>, and I have second Git repository called <strong>YYY</strong>.</p>
<p>I want to import the <strong>XXX</strong> repository into the <strong>YYY</strong> repository as a subdirectory named <strong>ZZZ</strong> and add all <strong>XXX</strong>'s change h... | 288,964 | 80,369 | 2025-06-29 16:06:56 | 1,684,694 | 521 | 2009-11-06 00:47:59 | 150,032 | 2018-10-02 05:36:13 | https://stackoverflow.com/q/1683531 | https://stackoverflow.com/a/1684694 | <p>Probably the simplest way would be to pull the <strong>XXX</strong> stuff into a branch in <strong>YYY</strong> and then merge it into master:</p>
<p>In <strong>YYY</strong>:</p>
<pre><code>git remote add other /path/to/XXX
git fetch other
git checkout -b ZZZ other/master
mkdir ZZZ
git mv stuff ZZZ/stuff ... | <p>Probably the simplest way would be to pull the <strong>XXX</strong> stuff into a branch in <strong>YYY</strong> and then merge it into master:</p> <p>In <strong>YYY</strong>:</p> <pre><code>git remote add other /path/to/XXX git fetch other git checkout -b ZZZ other/master mkdir ZZZ git mv stuff ZZZ/stuff ... | 119, 717, 28897 | git, git-merge, merge | <h1>How to import existing Git repository into another?</h1>
<p>I have a Git repository in a folder called <strong>XXX</strong>, and I have second Git repository called <strong>YYY</strong>.</p>
<p>I want to import the <strong>XXX</strong> repository into the <strong>YYY</strong> repository as a subdirectory named <st... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,309 | git | # How to import existing Git repository into another?
I have a Git repository in a folder called **XXX**, and I have second Git repository called **YYY**.
I want to import the **XXX** repository into the **YYY** repository as a subdirectory named **ZZZ** and add all **XXX**'s change history to **YYY**.
Folder struct... | Probably the simplest way would be to pull the **XXX** stuff into a branch in **YYY** and then merge it into master:
In **YYY**:
```
git remote add other /path/to/XXX
git fetch other
git checkout -b ZZZ other/master
mkdir ZZZ
git mv stuff ZZZ/stuff # repeat as necessary for each file/dir
git comm... |
7923091 | How to list all tags that contain a commit? | 328 | 2011-10-27 22:13:37 | <p>This question is similar to <a href="https://stackoverflow.com/questions/4545370/how-to-list-all-tags-pointing-to-a-specific-commit-in-git">How to list all tags pointing to a specific commit in git</a>, but with one difference: I wish to search for all tags that contain a specific commit within the tree of each tag,... | 95,547 | 553,707 | 2022-06-10 04:17:15 | 7,923,114 | 520 | 2011-10-27 22:16:21 | 625,403 | 2020-01-16 02:05:42 | https://stackoverflow.com/q/7923091 | https://stackoverflow.com/a/7923114 | <pre><code>git tag --contains <commit>
</code></pre>
| <pre><code>git tag --contains <commit> </code></pre> | 115, 119, 60718 | git, git-tag, tags | <h1>How to list all tags that contain a commit?</h1>
<p>This question is similar to <a href="https://stackoverflow.com/questions/4545370/how-to-list-all-tags-pointing-to-a-specific-commit-in-git">How to list all tags pointing to a specific commit in git</a>, but with one difference: I wish to search for all tags that c... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,310 | git | # How to list all tags that contain a commit?
This question is similar to [How to list all tags pointing to a specific commit in git](https://stackoverflow.com/questions/4545370/how-to-list-all-tags-pointing-to-a-specific-commit-in-git), but with one difference: I wish to search for all tags that contain a specific co... | ```
git tag --contains <commit>
``` |
13687334 | Moving uncommitted changes to a new branch | 322 | 2012-12-03 16:16:50 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/1394797/move-existing-uncommited-work-to-a-new-branch-in-git">Move existing, uncommited work to a new branch in Git</a> </p>
</blockquote>
<p>I have some code in branch ABC. </p>
<p>After making some changes t... | 192,685 | 359,862 | 2020-11-23 18:48:28 | 13,687,357 | 516 | 2012-12-03 16:18:11 | 41,116 | 2012-12-03 16:18:11 | https://stackoverflow.com/q/13687334 | https://stackoverflow.com/a/13687357 | <p>Just create a new branch:</p>
<pre><code>git checkout -b newBranch
</code></pre>
<p>And if you do <code>git status</code> you'll see that the state of the code hasn't changed and you can commit it to the new branch.</p>
| <p>Just create a new branch:</p> <pre><code>git checkout -b newBranch </code></pre> <p>And if you do <code>git status</code> you'll see that the state of the code hasn't changed and you can commit it to the new branch.</p> | 119 | git | <h1>Moving uncommitted changes to a new branch</h1>
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/1394797/move-existing-uncommited-work-to-a-new-branch-in-git">Move existing, uncommited work to a new branch in Git</a> </p>
</blockquote>
<p>I have some code... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,311 | git | # Moving uncommitted changes to a new branch
> **Possible Duplicate:**
> [Move existing, uncommited work to a new branch in Git](https://stackoverflow.com/questions/1394797/move-existing-uncommited-work-to-a-new-branch-in-git)
I have some code in branch ABC.
After making some changes to it, i'd like to move all th... | Just create a new branch:
```
git checkout -b newBranch
```
And if you do `git status` you'll see that the state of the code hasn't changed and you can commit it to the new branch. |
43535132 | Given a commit id, how to determine if current branch contains the commit? | 443 | 2017-04-21 06:08:11 | <p>What I'm trying to do is a version check. I want to ensure the code stays on top of a minimum version. So I need a way to know if the current branch contains a specified commit.</p>
| 249,740 | 978,360 | 2024-05-29 10:22:25 | 43,535,203 | 515 | 2017-04-21 06:12:31 | 2,168,346 | 2024-05-27 01:03:32 | https://stackoverflow.com/q/43535132 | https://stackoverflow.com/a/43535203 | <h1>Naïve method</h1>
<p>There are multiple ways to achieve this result. First naive option is to use <code>git log</code> and search for a specific commit using <code>grep</code>, but that is not always precise</p>
<pre><code>git log | grep <commit_id>
</code></pre>
<p>This could result in false positives if git... | <h1>Naïve method</h1> <p>There are multiple ways to achieve this result. First naive option is to use <code>git log</code> and search for a specific commit using <code>grep</code>, but that is not always precise</p> <pre><code>git log | grep <commit_id> </code></pre> <p>This could result in false positives if git... | 119 | git | <h1>Given a commit id, how to determine if current branch contains the commit?</h1>
<p>What I'm trying to do is a version check. I want to ensure the code stays on top of a minimum version. So I need a way to know if the current branch contains a specified commit.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,312 | git | # Given a commit id, how to determine if current branch contains the commit?
What I'm trying to do is a version check. I want to ensure the code stays on top of a minimum version. So I need a way to know if the current branch contains a specified commit. | # Naïve method
There are multiple ways to achieve this result. First naive option is to use `git log` and search for a specific commit using `grep`, but that is not always precise
```
git log | grep <commit_id>
```
This could result in false positives if git log mentions the commit SHA for other reasons, e.g. it's m... |
14893399 | Rebase feature branch onto another feature branch | 466 | 2013-02-15 11:09:24 | <p>I have two (private) feature branches that I'm working on.</p>
<pre><code>a -- b -- c <-- Master
\ \
\ d -- e <-- Branch1
\
f -- g <-- Branch2
</code></pre>
<p>After working on these branches a little while I've discovered that I n... | 446,094 | 537,542 | 2023-02-25 13:04:45 | 14,893,561 | 511 | 2013-02-15 11:19:58 | 1,142,387 | 2018-10-22 19:54:49 | https://stackoverflow.com/q/14893399 | https://stackoverflow.com/a/14893561 | <ol>
<li><p>Switch to Branch2</p>
<pre><code>git checkout Branch2
</code></pre></li>
<li><p>Apply the current (Branch2) changes on top of the Branch1 changes, staying
in Branch2:</p>
<pre><code>git rebase Branch1
</code></pre></li>
</ol>
<p>Which would leave you with the desired result in Branch2: </p>
<pre><code>... | <ol> <li><p>Switch to Branch2</p> <pre><code>git checkout Branch2 </code></pre></li> <li><p>Apply the current (Branch2) changes on top of the Branch1 changes, staying in Branch2:</p> <pre><code>git rebase Branch1 </code></pre></li> </ol> <p>Which would leave you with the desired result in Branch2: </p> <pre><code>... | 119, 29934, 40701 | feature-branch, git, git-rebase | <h1>Rebase feature branch onto another feature branch</h1>
<p>I have two (private) feature branches that I'm working on.</p>
<pre><code>a -- b -- c <-- Master
\ \
\ d -- e <-- Branch1
\
f -- g <-- Branch2
</code></pre>
<p>After workin... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,314 | git | # Rebase feature branch onto another feature branch
I have two (private) feature branches that I'm working on.
```
a -- b -- c <-- Master
\ \
\ d -- e <-- Branch1
\
f -- g <-- Branch2
```
After working on these branches a little while I've di... | 1. Switch to Branch2
```
git checkout Branch2
```
2. Apply the current (Branch2) changes on top of the Branch1 changes, staying
in Branch2:
```
git rebase Branch1
```
Which would leave you with the desired result in Branch2:
```
a -- b -- c <-- Master
\
... |
6476513 | Git file permissions on Windows | 264 | 2011-06-25 07:28:58 | <p>I've read through a few questions regarding file permissions in Git and I'm still a bit confused. I've got a repo on GitHub forked from another. Post merge, they should be identical. However:</p>
<pre><code>$ git diff --summary origin/epsilon master/epsilon
mode change 100644 => 100755 ants/dist/sample_bots/csh... | 149,665 | 45,525 | 2024-11-04 19:05:48 | 13,593,391 | 511 | 2012-11-27 21:28:13 | 1,857,897 | 2012-11-27 21:28:13 | https://stackoverflow.com/q/6476513 | https://stackoverflow.com/a/13593391 | <p>I found the solution of how to change permissions (also) on Windows here: <a href="http://blog.lesc.se/2011/11/how-to-change-file-premissions-in-git.html" rel="noreferrer">http://blog.lesc.se/2011/11/how-to-change-file-premissions-in-git.html</a></p>
<p>For example following command adds user execute permission to ... | <p>I found the solution of how to change permissions (also) on Windows here: <a href="http://blog.lesc.se/2011/11/how-to-change-file-premissions-in-git.html" rel="noreferrer">http://blog.lesc.se/2011/11/how-to-change-file-premissions-in-git.html</a></p> <p>For example following command adds user execute permission to ... | 64, 119, 606, 2120 | diff, file-permissions, git, windows | <h1>Git file permissions on Windows</h1>
<p>I've read through a few questions regarding file permissions in Git and I'm still a bit confused. I've got a repo on GitHub forked from another. Post merge, they should be identical. However:</p>
<pre><code>$ git diff --summary origin/epsilon master/epsilon
mode change 1006... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,315 | git | # Git file permissions on Windows
I've read through a few questions regarding file permissions in Git and I'm still a bit confused. I've got a repo on GitHub forked from another. Post merge, they should be identical. However:
```
$ git diff --summary origin/epsilon master/epsilon
mode change 100644 => 100755 ants/di... | I found the solution of how to change permissions (also) on Windows here: <http://blog.lesc.se/2011/11/how-to-change-file-premissions-in-git.html>
For example following command adds user execute permission to an arbitrary file:
```
git update-index --chmod=+x <file>
``` |
41492254 | How can I delete the current Git branch? | 310 | 2017-01-05 18:35:24 | <p>I have a branch called <code>Test_Branch</code>. When I try to delete it using the recommend method, I get the following error:</p>
<blockquote>
<p>Cannot delete branch 'Test_Branch' checked out at '[directory
location]'.</p>
</blockquote>
<p>I get no other information besides that. I can blow away the remote branch... | 464,178 | 2,757,491 | 2024-03-04 20:29:18 | 41,492,295 | 510 | 2017-01-05 18:37:39 | 3,118,209 | 2017-01-05 18:45:14 | https://stackoverflow.com/q/41492254 | https://stackoverflow.com/a/41492295 | <p>Switch to some other branch and delete <code>Test_Branch</code>, as follows:</p>
<pre><code>$ git checkout master
$ git branch -d Test_Branch
</code></pre>
<p>If above command gives you error - <code>The branch 'Test_Branch' is not fully merged. If you are sure you want to delete it</code> and still you want to de... | <p>Switch to some other branch and delete <code>Test_Branch</code>, as follows:</p> <pre><code>$ git checkout master $ git branch -d Test_Branch </code></pre> <p>If above command gives you error - <code>The branch 'Test_Branch' is not fully merged. If you are sure you want to delete it</code> and still you want to de... | 119 | git | <h1>How can I delete the current Git branch?</h1>
<p>I have a branch called <code>Test_Branch</code>. When I try to delete it using the recommend method, I get the following error:</p>
<blockquote>
<p>Cannot delete branch 'Test_Branch' checked out at '[directory
location]'.</p>
</blockquote>
<p>I get no other informati... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,316 | git | # How can I delete the current Git branch?
I have a branch called `Test_Branch`. When I try to delete it using the recommend method, I get the following error:
> Cannot delete branch 'Test_Branch' checked out at '[directory
> location]'.
I get no other information besides that. I can blow away the remote branch easy... | Switch to some other branch and delete `Test_Branch`, as follows:
```
$ git checkout master
$ git branch -d Test_Branch
```
If above command gives you error - `The branch 'Test_Branch' is not fully merged. If you are sure you want to delete it` and still you want to delete it, then you can **force delete it using `-D... |
6794110 | git revert back to certain commit | 335 | 2011-07-22 17:57:06 | <p>how do i revert all my files on my local copy back to a certain commit?</p>
<pre><code>commit 4a155e5b3b4548f5f8139b5210b9bb477fa549de
Author: John Doe <Doe.John.10@gmail.com>
Date: Thu Jul 21 20:51:38 2011 -0500
</code></pre>
<p>This is the commit i'd like to revert back to. any help would be a lifesaver!... | 629,131 | 728,241 | 2019-12-07 10:06:08 | 6,794,290 | 508 | 2011-07-22 18:12:34 | 275,354 | 2011-07-22 18:12:34 | https://stackoverflow.com/q/6794110 | https://stackoverflow.com/a/6794290 | <p><code>git reset --hard 4a155e5</code> Will move the HEAD back to where you want to be. There may be other references ahead of that time that you would need to remove if you don't want anything to point to the history you just deleted.</p>
| <p><code>git reset --hard 4a155e5</code> Will move the HEAD back to where you want to be. There may be other references ahead of that time that you would need to remove if you don't want anything to point to the history you just deleted.</p> | 119, 5597, 12309 | commit, git, revert | <h1>git revert back to certain commit</h1>
<p>how do i revert all my files on my local copy back to a certain commit?</p>
<pre><code>commit 4a155e5b3b4548f5f8139b5210b9bb477fa549de
Author: John Doe <Doe.John.10@gmail.com>
Date: Thu Jul 21 20:51:38 2011 -0500
</code></pre>
<p>This is the commit i'd like to rev... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,317 | git | # git revert back to certain commit
how do i revert all my files on my local copy back to a certain commit?
```
commit 4a155e5b3b4548f5f8139b5210b9bb477fa549de
Author: John Doe <Doe.John.10@gmail.com>
Date: Thu Jul 21 20:51:38 2011 -0500
```
This is the commit i'd like to revert back to. any help would be a lifesa... | `git reset --hard 4a155e5` Will move the HEAD back to where you want to be. There may be other references ahead of that time that you would need to remove if you don't want anything to point to the history you just deleted. |
5098256 | How can I view prior commits with git blame? | 523 | 2011-02-23 22:50:49 | <p>Is it possible to see who edited a specific line <em>before</em> the commit reported by <code>git blame</code>, like a history of commits for a given line?</p>
<p>For example, I run the following (on the superb <code>uncrustify</code> project):</p>
<pre><code>$ git blame -L10,+1 src/options.cpp
^fe25b6d (Ben Gardn... | 162,878 | 216,724 | 2023-10-28 12:32:19 | 5,098,314 | 507 | 2011-02-23 22:55:18 | 148,870 | 2020-08-15 17:10:22 | https://stackoverflow.com/q/5098256 | https://stackoverflow.com/a/5098314 | <pre><code>git blame -L 10,+1 fe25b6d^ -- src/options.cpp
</code></pre>
<p>You can specify a revision for git blame to look back starting from (instead of the default of <code>HEAD</code>); <code>fe25b6d^</code> is the parent of <code>fe25b6d</code>.</p>
<hr />
<p>Edit: New to <a href="https://github.blog/2019-08-16-hi... | <pre><code>git blame -L 10,+1 fe25b6d^ -- src/options.cpp </code></pre> <p>You can specify a revision for git blame to look back starting from (instead of the default of <code>HEAD</code>); <code>fe25b6d^</code> is the parent of <code>fe25b6d</code>.</p> <hr /> <p>Edit: New to <a href="https://github.blog/2019-08-16-hi... | 119, 5597, 21455 | blame, commit, git | <h1>How can I view prior commits with git blame?</h1>
<p>Is it possible to see who edited a specific line <em>before</em> the commit reported by <code>git blame</code>, like a history of commits for a given line?</p>
<p>For example, I run the following (on the superb <code>uncrustify</code> project):</p>
<pre><code>$... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,318 | git | # How can I view prior commits with git blame?
Is it possible to see who edited a specific line *before* the commit reported by `git blame`, like a history of commits for a given line?
For example, I run the following (on the superb `uncrustify` project):
```
$ git blame -L10,+1 src/options.cpp
^fe25b6d (Ben Gardner... | ```
git blame -L 10,+1 fe25b6d^ -- src/options.cpp
```
You can specify a revision for git blame to look back starting from (instead of the default of `HEAD`); `fe25b6d^` is the parent of `fe25b6d`.
---
Edit: New to [Git 2.23](https://github.blog/2019-08-16-highlights-from-git-2-23/), we have the `--ignore-rev` optio... |
30443333 | Error with renamed repo in GitHub: "remote: This repository moved. Please use the new location" | 321 | 2015-05-25 17:33:08 | <p>I am receiving this notice when I push updates from my local instance to remote master on GitHub:</p>
<blockquote>
<p><code>remote: This repository moved. Please use the new location [new location]</code></p>
</blockquote>
<p>Is there a way to fix this?</p>
| 79,022 | 1,215,344 | 2023-08-21 10:21:11 | 30,443,593 | 507 | 2015-05-25 17:51:15 | 1,215,344 | 2021-01-23 03:52:04 | https://stackoverflow.com/q/30443333 | https://stackoverflow.com/a/30443593 | <p>The simple way is:</p>
<pre><code>git remote set-url origin [updated link url https://........git]
</code></pre>
<p>Alternatively, if you like the long way it is:</p>
<pre><code>git remote rm origin
git remote add origin [updated link]
</code></pre>
<p><a href="https://help.github.com/articles/changing-a-remote-s-ur... | <p>The simple way is:</p> <pre><code>git remote set-url origin [updated link url https://........git] </code></pre> <p>Alternatively, if you like the long way it is:</p> <pre><code>git remote rm origin git remote add origin [updated link] </code></pre> <p><a href="https://help.github.com/articles/changing-a-remote-s-ur... | 119 | git | <h1>Error with renamed repo in GitHub: "remote: This repository moved. Please use the new location"</h1>
<p>I am receiving this notice when I push updates from my local instance to remote master on GitHub:</p>
<blockquote>
<p><code>remote: This repository moved. Please use the new location [new location]</code></p>
</b... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,319 | git | # Error with renamed repo in GitHub: "remote: This repository moved. Please use the new location"
I am receiving this notice when I push updates from my local instance to remote master on GitHub:
> `remote: This repository moved. Please use the new location [new location]`
Is there a way to fix this? | The simple way is:
```
git remote set-url origin [updated link url https://........git]
```
Alternatively, if you like the long way it is:
```
git remote rm origin
git remote add origin [updated link]
```
[Changing a remote's URL](https://help.github.com/articles/changing-a-remote-s-url/) GitHub documentation goes ... |
3810348 | Setting git parent pointer to a different parent | 291 | 2010-09-28 06:52:51 | <p>If I have a commit in the past that points to one parent, but I want to change the parent that it points to, how would I go about doing that?</p>
| 145,724 | 460,274 | 2020-09-11 14:18:43 | 3,810,400 | 507 | 2010-09-28 07:01:57 | 148,870 | 2010-09-28 07:09:06 | https://stackoverflow.com/q/3810348 | https://stackoverflow.com/a/3810400 | <p>Using <a href="http://git-scm.com/docs/git-rebase" rel="noreferrer"><code>git rebase</code></a>. It's the generic "take commit(s) and plop it/them on a different parent (base)" command in Git.</p>
<p>Some things to know, however:</p>
<ol>
<li><p>Since commit SHAs involve their parents, when you change the parent o... | <p>Using <a href="http://git-scm.com/docs/git-rebase" rel="noreferrer"><code>git rebase</code></a>. It's the generic "take commit(s) and plop it/them on a different parent (base)" command in Git.</p> <p>Some things to know, however:</p> <ol> <li><p>Since commit SHAs involve their parents, when you change the parent o... | 119 | git | <h1>Setting git parent pointer to a different parent</h1>
<p>If I have a commit in the past that points to one parent, but I want to change the parent that it points to, how would I go about doing that?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,320 | git | # Setting git parent pointer to a different parent
If I have a commit in the past that points to one parent, but I want to change the parent that it points to, how would I go about doing that? | Using [`git rebase`](http://git-scm.com/docs/git-rebase). It's the generic "take commit(s) and plop it/them on a different parent (base)" command in Git.
Some things to know, however:
1. Since commit SHAs involve their parents, when you change the parent of a given commit, its SHA will change - as will the SHAs of *a... |
4330610 | Switch to another Git tag | 295 | 2010-12-02 00:37:36 | <p>How do I check out version version/tag 1.1.4 of the <a href="https://github.com/rspec/rspec-tmbundle" rel="noreferrer">rspec bundle</a>?</p>
<pre><code>cd ~/Library/Application\ Support/TextMate/Bundles/
git clone git://github.com/rspec/rspec-tmbundle.git RSpec.tmbundle
osascript -e 'tell app "TextMate" to reload b... | 437,201 | 68,751 | 2024-10-02 06:03:55 | 4,330,627 | 506 | 2010-12-02 00:40:32 | 138,290 | 2015-05-15 22:12:48 | https://stackoverflow.com/q/4330610 | https://stackoverflow.com/a/4330627 | <p>Clone the repository as normal:</p>
<pre><code>git clone git://github.com/rspec/rspec-tmbundle.git RSpec.tmbundle
</code></pre>
<p>Then checkout the tag you want like so:</p>
<pre><code>git checkout tags/1.1.4
</code></pre>
<p>This will checkout out the tag in a 'detached HEAD' state. In this state, "you can loo... | <p>Clone the repository as normal:</p> <pre><code>git clone git://github.com/rspec/rspec-tmbundle.git RSpec.tmbundle </code></pre> <p>Then checkout the tag you want like so:</p> <pre><code>git checkout tags/1.1.4 </code></pre> <p>This will checkout out the tag in a 'detached HEAD' state. In this state, "you can loo... | 119, 60718 | git, git-tag | <h1>Switch to another Git tag</h1>
<p>How do I check out version version/tag 1.1.4 of the <a href="https://github.com/rspec/rspec-tmbundle" rel="noreferrer">rspec bundle</a>?</p>
<pre><code>cd ~/Library/Application\ Support/TextMate/Bundles/
git clone git://github.com/rspec/rspec-tmbundle.git RSpec.tmbundle
osascript ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,321 | git | # Switch to another Git tag
How do I check out version version/tag 1.1.4 of the [rspec bundle](https://github.com/rspec/rspec-tmbundle)?
```
cd ~/Library/Application\ Support/TextMate/Bundles/
git clone git://github.com/rspec/rspec-tmbundle.git RSpec.tmbundle
osascript -e 'tell app "TextMate" to reload bundles'
``` | Clone the repository as normal:
```
git clone git://github.com/rspec/rspec-tmbundle.git RSpec.tmbundle
```
Then checkout the tag you want like so:
```
git checkout tags/1.1.4
```
This will checkout out the tag in a 'detached HEAD' state. In this state, "you can look around, make experimental changes and commit them... |
6990484 | How to checkout in Git by date? | 456 | 2011-08-09 01:29:03 | <p>I am working on a regression in the source code. I'd like to tell Git: "checkout the source based on a parameterized date/time". Is this possible? </p>
<p>I also have staged changes in my current view that I don't want to lose. Ideally, I would like to toggle back and forth between the current source, and some v... | 227,443 | 104,950 | 2022-02-16 22:06:22 | 6,990,682 | 505 | 2011-08-09 02:05:37 | 275,354 | 2019-01-30 14:10:14 | https://stackoverflow.com/q/6990484 | https://stackoverflow.com/a/6990682 | <h3>To keep your current changes</h3>
<p>You can keep your work stashed away, without commiting it, with <code>git stash</code>. You
would than use <code>git stash pop</code> to get it back. Or you can (as <em>carleeto</em> said) <code>git commit</code> it to a separate branch.</p>
<h3>Checkout by date using rev-pars... | <h3>To keep your current changes</h3> <p>You can keep your work stashed away, without commiting it, with <code>git stash</code>. You would than use <code>git stash pop</code> to get it back. Or you can (as <em>carleeto</em> said) <code>git commit</code> it to a separate branch.</p> <h3>Checkout by date using rev-pars... | 119, 37230 | git, git-checkout | <h1>How to checkout in Git by date?</h1>
<p>I am working on a regression in the source code. I'd like to tell Git: "checkout the source based on a parameterized date/time". Is this possible? </p>
<p>I also have staged changes in my current view that I don't want to lose. Ideally, I would like to toggle back and for... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,322 | git | # How to checkout in Git by date?
I am working on a regression in the source code. I'd like to tell Git: "checkout the source based on a parameterized date/time". Is this possible?
I also have staged changes in my current view that I don't want to lose. Ideally, I would like to toggle back and forth between the curre... | ### To keep your current changes
You can keep your work stashed away, without commiting it, with `git stash`. You
would than use `git stash pop` to get it back. Or you can (as *carleeto* said) `git commit` it to a separate branch.
### Checkout by date using rev-parse
You can checkout a commit by a specific date usin... |
5815448 | How to undo a git pull? | 331 | 2011-04-28 07:57:39 | <p>I would like to undo my git pull on account of unwanted commits on the remote origin, but I don't know to which revision I have to reset back to.</p>
<p>How can I just go back to the state before I did the git pull on the remote origin? </p>
| 438,349 | 573,881 | 2023-06-30 00:01:08 | 5,815,626 | 505 | 2011-04-28 08:13:52 | 85,371 | 2017-07-05 06:55:33 | https://stackoverflow.com/q/5815448 | https://stackoverflow.com/a/5815626 | <p>Or to make it more explicit than the other answer:</p>
<pre><code>git pull
</code></pre>
<p>whoops?</p>
<pre><code>git reset --keep HEAD@{1}
</code></pre>
<p>Versions of git older than 1.7.1 do not have <code>--keep</code>. If you use such version, you could use <code>--hard</code> - but that is a dangerous ope... | <p>Or to make it more explicit than the other answer:</p> <pre><code>git pull </code></pre> <p>whoops?</p> <pre><code>git reset --keep HEAD@{1} </code></pre> <p>Versions of git older than 1.7.1 do not have <code>--keep</code>. If you use such version, you could use <code>--hard</code> - but that is a dangerous ope... | 119, 4860, 5766 | git, pull, undo | <h1>How to undo a git pull?</h1>
<p>I would like to undo my git pull on account of unwanted commits on the remote origin, but I don't know to which revision I have to reset back to.</p>
<p>How can I just go back to the state before I did the git pull on the remote origin? </p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,323 | git | # How to undo a git pull?
I would like to undo my git pull on account of unwanted commits on the remote origin, but I don't know to which revision I have to reset back to.
How can I just go back to the state before I did the git pull on the remote origin? | Or to make it more explicit than the other answer:
```
git pull
```
whoops?
```
git reset --keep HEAD@{1}
```
Versions of git older than 1.7.1 do not have `--keep`. If you use such version, you could use `--hard` - but that is a dangerous operation because it loses any local changes.
---
[**To the commenter**](ht... |
3357280 | Print commit message of a given commit in git | 409 | 2010-07-28 20:36:45 | <p>I need a plumbing command to print the commit message of one given commit - nothing more, nothing less.</p>
| 230,860 | 80,410 | 2025-08-06 17:23:40 | 3,357,357 | 504 | 2010-07-28 20:47:09 | 28,804 | 2025-08-06 17:23:40 | https://stackoverflow.com/q/3357280 | https://stackoverflow.com/a/3357357 | <p>It's not "plumbing", but it'll do exactly what you want (<code>%B</code> represents the whole commit message):</p>
<pre><code>$ git log --format=%B -n 1 <commit>
</code></pre>
<p>If you absolutely need a "plumbing" command (not sure why that's a requirement), you can use <code>rev-list</cod... | <p>It's not "plumbing", but it'll do exactly what you want (<code>%B</code> represents the whole commit message):</p> <pre><code>$ git log --format=%B -n 1 <commit> </code></pre> <p>If you absolutely need a "plumbing" command (not sure why that's a requirement), you can use <code>rev-list</cod... | 119, 3809 | commit-message, git | <h1>Print commit message of a given commit in git</h1>
<p>I need a plumbing command to print the commit message of one given commit - nothing more, nothing less.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 14,324 | git | # Print commit message of a given commit in git
I need a plumbing command to print the commit message of one given commit - nothing more, nothing less. | It's not "plumbing", but it'll do exactly what you want (`%B` represents the whole commit message):
```
$ git log --format=%B -n 1 <commit>
```
If you absolutely need a "plumbing" command (not sure why that's a requirement), you can use `rev-list`:
```
$ git rev-list --format=%B --max-count=1 <commit>
```
Although ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.