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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
10491146 | In git, how do I sync my tags against a remote server? | 103 | 2012-05-08 00:59:44 | <p>Is there a way to keep my local git tags in lockstep with a remote's tags? That is -- not only get new tags when created (as usual, when <code>fetch</code>-ing/<code>pull</code>-ing), but also prune tags no longer on a remote and also delete existing tags when someone else <code>git push -f</code>'s a tag.
I know I ... | 75,260 | 1,380,835 | 2021-04-28 20:29:51 | 49,215,190 | 111 | 2018-03-10 23:46:37 | 6,309 | 2021-04-28 20:29:51 | https://stackoverflow.com/q/10491146 | https://stackoverflow.com/a/49215190 | <blockquote>
<p>...also prune tags no longer on a remote</p>
</blockquote>
<p><code>git fetch</code> gets with Git 2.17 (Q2 2018) an handy short-hand for getting
rid of stale tags that are locally held.</p>
<p>See <a href="https://github.com/git/git/commit/6317972cff9b4df7a6cc666b08be7133ba81617c" rel="noreferrer">comm... | <blockquote> <p>...also prune tags no longer on a remote</p> </blockquote> <p><code>git fetch</code> gets with Git 2.17 (Q2 2018) an handy short-hand for getting rid of stale tags that are locally held.</p> <p>See <a href="https://github.com/git/git/commit/6317972cff9b4df7a6cc666b08be7133ba81617c" rel="noreferrer">comm... | 119, 60718 | git, git-tag | <h1>In git, how do I sync my tags against a remote server?</h1>
<p>Is there a way to keep my local git tags in lockstep with a remote's tags? That is -- not only get new tags when created (as usual, when <code>fetch</code>-ing/<code>pull</code>-ing), but also prune tags no longer on a remote and also delete existing ta... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,813 | git | # In git, how do I sync my tags against a remote server?
Is there a way to keep my local git tags in lockstep with a remote's tags? That is -- not only get new tags when created (as usual, when `fetch`-ing/`pull`-ing), but also prune tags no longer on a remote and also delete existing tags when someone else `git push ... | > ...also prune tags no longer on a remote
`git fetch` gets with Git 2.17 (Q2 2018) an handy short-hand for getting
rid of stale tags that are locally held.
See [commit 6317972](https://github.com/git/git/commit/6317972cff9b4df7a6cc666b08be7133ba81617c), [commit 97716d2](https://github.com/git/git/commit/97716d217c1e... |
12626754 | Git cherry-pick syntax and merge branches | 99 | 2012-09-27 17:16:12 | <p>So I have done countless cherry picks before and it seems that I must fail at life with this right now, I am trying to cherry pick from one branch to another which should be easy, how ever I get an error about it being a merge but not -m was given?</p>
<pre><code>$ git cherry-pick a8c5ad438f6173dc34f6ec45bddcef2ab2... | 106,146 | 1,270,259 | 2021-02-18 14:11:50 | 12,628,579 | 111 | 2012-09-27 19:17:58 | 1,600,898 | 2013-04-17 20:53:41 | https://stackoverflow.com/q/12626754 | https://stackoverflow.com/a/12628579 | <p>You have to supply <code>-m</code> if the commit is a <em>merge commit</em>, i.e. a commit with more than one parent.</p>
<p>Normally, what <code>git cherry-pick REV</code> does can be described as:</p>
<ol>
<li><p>Take the changes between <em>rev</em> and its parent.</p></li>
<li><p>Apply these changes to the cur... | <p>You have to supply <code>-m</code> if the commit is a <em>merge commit</em>, i.e. a commit with more than one parent.</p> <p>Normally, what <code>git cherry-pick REV</code> does can be described as:</p> <ol> <li><p>Take the changes between <em>rev</em> and its parent.</p></li> <li><p>Apply these changes to the cur... | 119, 36489, 78810 | cherry-pick, git, git-cherry-pick | <h1>Git cherry-pick syntax and merge branches</h1>
<p>So I have done countless cherry picks before and it seems that I must fail at life with this right now, I am trying to cherry pick from one branch to another which should be easy, how ever I get an error about it being a merge but not -m was given?</p>
<pre><code>$... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,814 | git | # Git cherry-pick syntax and merge branches
So I have done countless cherry picks before and it seems that I must fail at life with this right now, I am trying to cherry pick from one branch to another which should be easy, how ever I get an error about it being a merge but not -m was given?
```
$ git cherry-pick a8c... | You have to supply `-m` if the commit is a *merge commit*, i.e. a commit with more than one parent.
Normally, what `git cherry-pick REV` does can be described as:
1. Take the changes between *rev* and its parent.
2. Apply these changes to the current HEAD and commit the result with *rev*'s commit message.
A merge co... |
11023194 | Automatically wrap long Git commit messages in Vim | 97 | 2012-06-13 20:59:34 | <p>Using Git, my editor for commits is Vim. I'm constantly doing a poor job of remembering to wrap lines and so I get long lines (see <a href="https://stackoverflow.com/a/2120040/748858">this answer</a> for example). Is there a way using some <code>git config</code> or <code>.vimrc</code> magic that I can get Vim to a... | 39,877 | 748,858 | 2020-12-25 03:58:49 | 11,023,282 | 111 | 2012-06-13 21:05:11 | 215,168 | 2019-04-01 17:09:22 | https://stackoverflow.com/q/11023194 | https://stackoverflow.com/a/11023282 | <p>Add this to your <code>.vimrc</code>:</p>
<pre><code>au FileType gitcommit setlocal tw=72
</code></pre>
| <p>Add this to your <code>.vimrc</code>:</p> <pre><code>au FileType gitcommit setlocal tw=72 </code></pre> | 119, 370, 3809, 19508 | commit-message, git, vim, word-wrap | <h1>Automatically wrap long Git commit messages in Vim</h1>
<p>Using Git, my editor for commits is Vim. I'm constantly doing a poor job of remembering to wrap lines and so I get long lines (see <a href="https://stackoverflow.com/a/2120040/748858">this answer</a> for example). Is there a way using some <code>git config... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,815 | git | # Automatically wrap long Git commit messages in Vim
Using Git, my editor for commits is Vim. I'm constantly doing a poor job of remembering to wrap lines and so I get long lines (see [this answer](https://stackoverflow.com/a/2120040/748858) for example). Is there a way using some `git config` or `.vimrc` magic that I... | Add this to your `.vimrc`:
```
au FileType gitcommit setlocal tw=72
``` |
1450348 | Git equivalents of most common Mercurial commands? | 96 | 2009-09-20 05:15:34 | <p>I've been using Mercurial but would like to do a quick demo of Git.</p>
<p>What are the Git equivalents of:</p>
<pre class="lang-bash prettyprint-override"><code>hg init . # start a project in the current directory
hg addremove # look for any added or deleted files
hg commit -m "comment" # commit any uncom... | 47,396 | 176,120 | 2024-02-10 17:07:50 | 1,450,420 | 111 | 2009-09-20 06:14:10 | 4,596 | 2020-06-01 10:55:52 | https://stackoverflow.com/q/1450348 | https://stackoverflow.com/a/1450420 | <p><a href="https://github.com/sympy/sympy/wiki/Git-hg-rosetta-stone" rel="noreferrer">The Git-HG rosetta stone is not bad</a></p>
<p>There are a few other gotchas between the two not mentioned there. This list was cribbed from my own blog post when I went the other way (git -> hg).</p>
<p><strong>Hg</strong> <code>.... | <p><a href="https://github.com/sympy/sympy/wiki/Git-hg-rosetta-stone" rel="noreferrer">The Git-HG rosetta stone is not bad</a></p> <p>There are a few other gotchas between the two not mentioned there. This list was cribbed from my own blog post when I went the other way (git -> hg).</p> <p><strong>Hg</strong> <code>.... | 119, 802 | git, mercurial | <h1>Git equivalents of most common Mercurial commands?</h1>
<p>I've been using Mercurial but would like to do a quick demo of Git.</p>
<p>What are the Git equivalents of:</p>
<pre class="lang-bash prettyprint-override"><code>hg init . # start a project in the current directory
hg addremove # look for any added or delet... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,816 | git | # Git equivalents of most common Mercurial commands?
I've been using Mercurial but would like to do a quick demo of Git.
What are the Git equivalents of:
```
hg init . # start a project in the current directory
hg addremove # look for any added or deleted files
hg commit -m "comment" # commit any uncomitted changes
... | [The Git-HG rosetta stone is not bad](https://github.com/sympy/sympy/wiki/Git-hg-rosetta-stone)
There are a few other gotchas between the two not mentioned there. This list was cribbed from my own blog post when I went the other way (git -> hg).
**Hg** `.hgignore`, syntax: glob is the same behaviour as git's .gitigno... |
14700835 | .gitignore a folder content | 90 | 2013-02-05 05:36:21 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/343646/ignoring-directories-in-git-repos-on-windows">Ignoring directories in Git repos on Windows</a> </p>
</blockquote>
<p>My web app has the following directory layout:</p>
<pre><code>myapp/
.gitignore
... | 140,773 | 85,443 | 2013-02-05 05:41:37 | 14,700,901 | 111 | 2013-02-05 05:41:37 | 1,710,229 | 2013-02-05 05:41:37 | https://stackoverflow.com/q/14700835 | https://stackoverflow.com/a/14700901 | <p>Just make the line in <code>.gitignore</code> as specific as you want it to be:</p>
<pre><code>ledgerware/static/*
</code></pre>
| <p>Just make the line in <code>.gitignore</code> as specific as you want it to be:</p> <pre><code>ledgerware/static/* </code></pre> | 119, 25056 | git, gitignore | <h1>.gitignore a folder content</h1>
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/343646/ignoring-directories-in-git-repos-on-windows">Ignoring directories in Git repos on Windows</a> </p>
</blockquote>
<p>My web app has the following directory layout:</p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,817 | git | # .gitignore a folder content
> **Possible Duplicate:**
> [Ignoring directories in Git repos on Windows](https://stackoverflow.com/questions/343646/ignoring-directories-in-git-repos-on-windows)
My web app has the following directory layout:
```
myapp/
.gitignore
.git/
...
static/
m... | Just make the line in `.gitignore` as specific as you want it to be:
```
ledgerware/static/*
``` |
3082445 | Where does Git store files? | 87 | 2010-06-21 06:06:47 | <p>I just ran the following commands on my <a href="http://en.wikipedia.org/wiki/Ruby_on_Rails" rel="noreferrer">Ruby on Rails</a> project:</p>
<pre><code>git init
git add .
git commit -a -m 'Initial'
</code></pre>
<p>Where does <a href="http://en.wikipedia.org/wiki/Git_%28software%29" rel="noreferrer">Git</a> actual... | 236,304 | 118,175 | 2021-03-19 01:34:14 | 3,082,452 | 111 | 2010-06-21 06:08:52 | 47,773 | 2010-06-21 06:08:52 | https://stackoverflow.com/q/3082445 | https://stackoverflow.com/a/3082452 | <p>It will create your repository in the <code>.git</code> folder in the current directory.</p>
| <p>It will create your repository in the <code>.git</code> folder in the current directory.</p> | 119 | git | <h1>Where does Git store files?</h1>
<p>I just ran the following commands on my <a href="http://en.wikipedia.org/wiki/Ruby_on_Rails" rel="noreferrer">Ruby on Rails</a> project:</p>
<pre><code>git init
git add .
git commit -a -m 'Initial'
</code></pre>
<p>Where does <a href="http://en.wikipedia.org/wiki/Git_%28softwar... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,818 | git | # Where does Git store files?
I just ran the following commands on my [Ruby on Rails](http://en.wikipedia.org/wiki/Ruby_on_Rails) project:
```
git init
git add .
git commit -a -m 'Initial'
```
Where does [Git](http://en.wikipedia.org/wiki/Git_%28software%29) actually store this repository? (It's on my local machine,... | It will create your repository in the `.git` folder in the current directory. |
45141188 | Git fatal: cannot lock ref | 85 | 2017-07-17 09:58:36 | <p>I'm trying to create a branch on the current branch on my Ubuntu guest.
Unfortunately I keep getting this error: </p>
<pre><code>git checkout -b origin/feature/IF-53-change-validation-window/Tommaso
fatal: cannot lock ref 'refs/heads/origin/feature/IF-53-change-validation-window/Tommaso':
'refs/heads/origin/branc... | 171,869 | 4,338,302 | 2023-12-07 02:29:53 | 45,141,395 | 111 | 2017-07-17 10:08:14 | 283,078 | 2023-08-31 13:27:13 | https://stackoverflow.com/q/45141188 | https://stackoverflow.com/a/45141395 | <p>It looks like the problem here was a branch <code>X</code> existed locally, and you tried to create a new branch <code>X/Y</code>. This won't work, because git creates a file at <code>.git/refs/heads/X</code>, so it can't create the folder X to contain the file Y.</p>
<p>However, it's worth adding that including &qu... | <p>It looks like the problem here was a branch <code>X</code> existed locally, and you tried to create a new branch <code>X/Y</code>. This won't work, because git creates a file at <code>.git/refs/heads/X</code>, so it can't create the folder X to contain the file Y.</p> <p>However, it's worth adding that including &qu... | 119 | git | <h1>Git fatal: cannot lock ref</h1>
<p>I'm trying to create a branch on the current branch on my Ubuntu guest.
Unfortunately I keep getting this error: </p>
<pre><code>git checkout -b origin/feature/IF-53-change-validation-window/Tommaso
fatal: cannot lock ref 'refs/heads/origin/feature/IF-53-change-validation-window... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,819 | git | # Git fatal: cannot lock ref
I'm trying to create a branch on the current branch on my Ubuntu guest.
Unfortunately I keep getting this error:
```
git checkout -b origin/feature/IF-53-change-validation-window/Tommaso
fatal: cannot lock ref 'refs/heads/origin/feature/IF-53-change-validation-window/Tommaso':
'refs/head... | It looks like the problem here was a branch `X` existed locally, and you tried to create a new branch `X/Y`. This won't work, because git creates a file at `.git/refs/heads/X`, so it can't create the folder X to contain the file Y.
However, it's worth adding that including "origin" in your branch name points to some c... |
8746631 | What happens when I do git pull origin master in the develop branch? | 81 | 2012-01-05 17:12:04 | <p>Let's say I have a private topic branch called develop with 2 commits ahead of master.</p>
<p>What does <code>git pull origin master</code> do?</p>
<p>Pull everything from the remote master in the local develop and merge it? Pull everything in the local master branch and merge it?</p>
<p>And is there a way to upd... | 118,192 | 9,951 | 2016-10-14 16:58:43 | 8,747,419 | 111 | 2012-01-05 18:04:18 | 1,022,987 | 2012-01-05 18:04:18 | https://stackoverflow.com/q/8746631 | https://stackoverflow.com/a/8747419 | <p><code>git pull origin master</code> pulls the master branch from the remote called origin into your current branch. <em>It only affects your current branch, not your local master branch.</em></p>
<p>It'll give you history looking something like this:</p>
<pre><code>- x - x - x - x (develop)
\ /
x - ... | <p><code>git pull origin master</code> pulls the master branch from the remote called origin into your current branch. <em>It only affects your current branch, not your local master branch.</em></p> <p>It'll give you history looking something like this:</p> <pre><code>- x - x - x - x (develop) \ / x - ... | 119, 4860 | git, pull | <h1>What happens when I do git pull origin master in the develop branch?</h1>
<p>Let's say I have a private topic branch called develop with 2 commits ahead of master.</p>
<p>What does <code>git pull origin master</code> do?</p>
<p>Pull everything from the remote master in the local develop and merge it? Pull everyth... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,820 | git | # What happens when I do git pull origin master in the develop branch?
Let's say I have a private topic branch called develop with 2 commits ahead of master.
What does `git pull origin master` do?
Pull everything from the remote master in the local develop and merge it? Pull everything in the local master branch and... | `git pull origin master` pulls the master branch from the remote called origin into your current branch. *It only affects your current branch, not your local master branch.*
It'll give you history looking something like this:
```
- x - x - x - x (develop)
\ /
x - x - x (origin/master)
```
Your local m... |
15884180 | How do I override Git configuration options by command line parameters? | 76 | 2013-04-08 16:21:10 | <p>I want to override certain Git configuration options (in my case <code>http.proxy</code>) when calling a Git command directly by using command line parameters. Is this possible?</p>
| 21,571 | 241,453 | 2025-01-04 21:10:11 | 15,884,261 | 111 | 2013-04-08 16:26:35 | 770,830 | 2013-04-08 16:26:35 | https://stackoverflow.com/q/15884180 | https://stackoverflow.com/a/15884261 | <p>Yes, you can pass it with <code>-c</code>, like:</p>
<pre><code>git -c http.proxy=someproxy clone https://github.com/user/repo.git
</code></pre>
| <p>Yes, you can pass it with <code>-c</code>, like:</p> <pre><code>git -c http.proxy=someproxy clone https://github.com/user/repo.git </code></pre> | 119, 3574 | config, git | <h1>How do I override Git configuration options by command line parameters?</h1>
<p>I want to override certain Git configuration options (in my case <code>http.proxy</code>) when calling a Git command directly by using command line parameters. Is this possible?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,821 | git | # How do I override Git configuration options by command line parameters?
I want to override certain Git configuration options (in my case `http.proxy`) when calling a Git command directly by using command line parameters. Is this possible? | Yes, you can pass it with `-c`, like:
```
git -c http.proxy=someproxy clone https://github.com/user/repo.git
``` |
18248177 | how to git commit a whole folder? | 68 | 2013-08-15 07:35:07 | <p>Here is a folder, which contains a lot of <code>.java</code> files.</p>
<p>How can I git commit this folder?</p>
<p>If I do the following commands</p>
<pre><code>git add folder_name
git commit folder_name -m "commit operation"
</code></pre>
<p>I will see the messages
nothing added to commit but untracked f... | 241,692 | 922,861 | 2022-05-06 18:10:53 | 18,248,209 | 111 | 2013-08-15 07:37:33 | 628,881 | 2013-08-15 07:37:33 | https://stackoverflow.com/q/18248177 | https://stackoverflow.com/a/18248209 | <p>You don't "commit the folder" - you add the folder, as you have done, and then simply commit all changes. The command should be:</p>
<pre><code>git add foldername
git commit -m "commit operation"
</code></pre>
| <p>You don't "commit the folder" - you add the folder, as you have done, and then simply commit all changes. The command should be:</p> <pre><code>git add foldername git commit -m "commit operation" </code></pre> | 119 | git | <h1>how to git commit a whole folder?</h1>
<p>Here is a folder, which contains a lot of <code>.java</code> files.</p>
<p>How can I git commit this folder?</p>
<p>If I do the following commands</p>
<pre><code>git add folder_name
git commit folder_name -m "commit operation"
</code></pre>
<p>I will see the messa... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,822 | git | # how to git commit a whole folder?
Here is a folder, which contains a lot of `.java` files.
How can I git commit this folder?
If I do the following commands
```
git add folder_name
git commit folder_name -m "commit operation"
```
I will see the messages
nothing added to commit but untracked files present (use "gi... | You don't "commit the folder" - you add the folder, as you have done, and then simply commit all changes. The command should be:
```
git add foldername
git commit -m "commit operation"
``` |
8845658 | Gerrit error when Change-Id in commit messages are missing | 65 | 2012-01-13 03:47:16 | <p>I set up a branch in the remote repository and made some commits on that branch.
Now I want to merge the remote branch to the remote master.</p>
<p>Basically follows are my operations:</p>
<ol>
<li>checkout branch</li>
<li>checkout master</li>
<li>merge branch and fix merging errors</li>
<li>commit</li>
<li>push o... | 219,439 | 1,035,133 | 2024-11-25 11:37:46 | 8,849,682 | 111 | 2012-01-13 11:13:03 | 13,767 | 2022-08-22 11:14:48 | https://stackoverflow.com/q/8845658 | https://stackoverflow.com/a/8849682 | <p>Check if your commits have <code>Change-Id: ...</code> in their descriptions. Every commit should have them.</p>
<p>If no, use <code>git rebase -i</code> to reword the commit messages and add proper Change-Ids (usually this is a SHA1 of the first version of the reviewed commit).</p>
<p>For the future, you should ins... | <p>Check if your commits have <code>Change-Id: ...</code> in their descriptions. Every commit should have them.</p> <p>If no, use <code>git rebase -i</code> to reword the commit messages and add proper Change-Ids (usually this is a SHA1 of the first version of the reviewed commit).</p> <p>For the future, you should ins... | 119, 52272 | gerrit, git | <h1>Gerrit error when Change-Id in commit messages are missing</h1>
<p>I set up a branch in the remote repository and made some commits on that branch.
Now I want to merge the remote branch to the remote master.</p>
<p>Basically follows are my operations:</p>
<ol>
<li>checkout branch</li>
<li>checkout master</li>
<li... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,823 | git | # Gerrit error when Change-Id in commit messages are missing
I set up a branch in the remote repository and made some commits on that branch.
Now I want to merge the remote branch to the remote master.
Basically follows are my operations:
1. checkout branch
2. checkout master
3. merge branch and fix merging errors
4... | Check if your commits have `Change-Id: ...` in their descriptions. Every commit should have them.
If no, use `git rebase -i` to reword the commit messages and add proper Change-Ids (usually this is a SHA1 of the first version of the reviewed commit).
For the future, you should install commit hook, which automatically... |
23673174 | How to ignore new changes to a tracked file with git? | 42 | 2014-05-15 08:38:10 | <p>When I run git status:</p>
<pre><code>$ git status
# On branch master
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: .gitignore
# ... | 33,330 | 2,118,666 | 2024-08-27 16:50:27 | 23,673,910 | 111 | 2014-05-15 09:12:18 | 2,082,964 | 2014-05-15 09:12:18 | https://stackoverflow.com/q/23673174 | https://stackoverflow.com/a/23673910 | <p>If I understand well you want <code>filename</code> to be in the git repository. However you don't want to be notified of new changes to <code>filename</code>. You can do this using this command:</p>
<pre><code>git update-index --assume-unchanged <filename>
</code></pre>
<p>If you wanna start tracking change... | <p>If I understand well you want <code>filename</code> to be in the git repository. However you don't want to be notified of new changes to <code>filename</code>. You can do this using this command:</p> <pre><code>git update-index --assume-unchanged <filename> </code></pre> <p>If you wanna start tracking change... | 119, 4333, 25056 | git, gitignore, ignore | <h1>How to ignore new changes to a tracked file with git?</h1>
<p>When I run git status:</p>
<pre><code>$ git status
# On branch master
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard chang... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,825 | git | # How to ignore new changes to a tracked file with git?
When I run git status:
```
$ git status
# On branch master
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: .git... | If I understand well you want `filename` to be in the git repository. However you don't want to be notified of new changes to `filename`. You can do this using this command:
```
git update-index --assume-unchanged <filename>
```
If you wanna start tracking changes again run the following command:
```
git update-inde... |
9844082 | how to create a new git repository from an existing one | 107 | 2012-03-23 17:48:41 | <p>I have a remote git repository that really replaced everything we had in another older SCM. Many projects and products have been added to the repository over the years.</p>
<p>There is a branch in this repo, corresponding to a product that I am interested in.
I want to make a brand new git repository from this bra... | 162,851 | 496,136 | 2024-06-20 15:12:56 | 14,959,879 | 110 | 2013-02-19 14:27:39 | 551,467 | 2018-08-21 12:18:53 | https://stackoverflow.com/q/9844082 | https://stackoverflow.com/a/14959879 | <p>In order to create a new Git repository from an existing repository one would typically create a new <em>bare</em> repository and push one or more branches from the existing to the new repository.</p>
<p>The following steps illustrates this:</p>
<ol>
<li><p>Create a new repository. It must be <em>bare</em> in orde... | <p>In order to create a new Git repository from an existing repository one would typically create a new <em>bare</em> repository and push one or more branches from the existing to the new repository.</p> <p>The following steps illustrates this:</p> <ol> <li><p>Create a new repository. It must be <em>bare</em> in orde... | 119 | git | <h1>how to create a new git repository from an existing one</h1>
<p>I have a remote git repository that really replaced everything we had in another older SCM. Many projects and products have been added to the repository over the years.</p>
<p>There is a branch in this repo, corresponding to a product that I am intere... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,828 | git | # how to create a new git repository from an existing one
I have a remote git repository that really replaced everything we had in another older SCM. Many projects and products have been added to the repository over the years.
There is a branch in this repo, corresponding to a product that I am interested in.
I want ... | In order to create a new Git repository from an existing repository one would typically create a new *bare* repository and push one or more branches from the existing to the new repository.
The following steps illustrates this:
1. Create a new repository. It must be *bare* in order for you to push to it.
```
$... |
7303687 | Why does Git use a colon (:<branch>) to delete remote branches? | 104 | 2011-09-05 03:36:53 | <p>Why does Git use</p>
<pre><code>git push <remote> :<branch>
</code></pre>
<p>as in</p>
<pre><code>git push origin :featureA
</code></pre>
<p>to delete the branch <code>featureA</code> from the remote server?</p>
<p>I am interested in why the colon was used as the delete flag.</p>
<p>It's so different fro... | 27,156 | 506,613 | 2022-05-06 18:10:41 | 7,303,710 | 110 | 2011-09-05 03:41:09 | 526,535 | 2011-09-05 03:41:09 | https://stackoverflow.com/q/7303687 | https://stackoverflow.com/a/7303710 | <p>It is not the meaning of the <code>:</code> per se, but what is present, or rather absent before it.</p>
<p>The refspec format is</p>
<pre><code><+><source>:<destination>
</code></pre>
<p>(optional + for non-fast forward)</p>
<p>So when you do something like <code>git push origin :featureA</cod... | <p>It is not the meaning of the <code>:</code> per se, but what is present, or rather absent before it.</p> <p>The refspec format is</p> <pre><code><+><source>:<destination> </code></pre> <p>(optional + for non-fast forward)</p> <p>So when you do something like <code>git push origin :featureA</cod... | 119 | git | <h1>Why does Git use a colon (:<branch>) to delete remote branches?</h1>
<p>Why does Git use</p>
<pre><code>git push <remote> :<branch>
</code></pre>
<p>as in</p>
<pre><code>git push origin :featureA
</code></pre>
<p>to delete the branch <code>featureA</code> from the remote server?</p>
<p>I am interested i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,829 | git | # Why does Git use a colon (:) to delete remote branches?
Why does Git use
```
git push <remote> :<branch>
```
as in
```
git push origin :featureA
```
to delete the branch `featureA` from the remote server?
I am interested in why the colon was used as the delete flag.
It's so different from `git branch -d <local... | It is not the meaning of the `:` per se, but what is present, or rather absent before it.
The refspec format is
```
<+><source>:<destination>
```
(optional + for non-fast forward)
So when you do something like `git push origin :featureA`, you are specifying an empty source ref and basically making the destination "... |
14308580 | Undo a fast-forward merge | 92 | 2013-01-13 21:48:58 | <p>I've made some changes to my git repo that I wish to undo.</p>
<p>My git repo looked like this:</p>
<pre><code>A-B---- master
\ /
C-D * develop
</code></pre>
<p>I was on the <code>develop</code> branch, forgot that it differed from the <code>master</code> branch, made a change on <code>develop</c... | 47,691 | 996,592 | 2020-04-07 15:42:52 | 14,308,631 | 110 | 2013-01-13 21:53:09 | 1,024,223 | 2013-01-13 21:53:09 | https://stackoverflow.com/q/14308580 | https://stackoverflow.com/a/14308631 | <p>If you reset the branch master, it won't touch develop branch. In order to reput all in order, you should do:</p>
<pre><code>git checkout master
git reset --hard sha-of-B
git checkout develop
git reset --hard sha-of-D
git checkout master
git merge develop --no-ff
</code></pre>
| <p>If you reset the branch master, it won't touch develop branch. In order to reput all in order, you should do:</p> <pre><code>git checkout master git reset --hard sha-of-B git checkout develop git reset --hard sha-of-D git checkout master git merge develop --no-ff </code></pre> | 119 | git | <h1>Undo a fast-forward merge</h1>
<p>I've made some changes to my git repo that I wish to undo.</p>
<p>My git repo looked like this:</p>
<pre><code>A-B---- master
\ /
C-D * develop
</code></pre>
<p>I was on the <code>develop</code> branch, forgot that it differed from the <code>master</code> branch... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,830 | git | # Undo a fast-forward merge
I've made some changes to my git repo that I wish to undo.
My git repo looked like this:
```
A-B---- master
\ /
C-D * develop
```
I was on the `develop` branch, forgot that it differed from the `master` branch, made a change on `develop`, merged it into `master`, and the... | If you reset the branch master, it won't touch develop branch. In order to reput all in order, you should do:
```
git checkout master
git reset --hard sha-of-B
git checkout develop
git reset --hard sha-of-D
git checkout master
git merge develop --no-ff
``` |
1662753 | Export subtree in Git with history | 83 | 2009-11-02 18:03:31 | <p>I have a folder in my Git repository that I'd like to move out in to its own repository. Is it possible to move the history of that folder along with the folder?</p>
<p>I've previously been doing just a <code>git rm -r --cached subfolder/</code> and then <code>git init</code> on the subfolder. However, the history ... | 15,854 | 51,021 | 2021-02-02 02:20:57 | 1,662,787 | 110 | 2009-11-02 18:10:46 | 198,244 | 2013-11-29 21:12:43 | https://stackoverflow.com/q/1662753 | https://stackoverflow.com/a/1662787 | <p>Quoting an example from <a href="https://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html" rel="noreferrer"><code>git-filter-branch(1)</code></a></p>
<blockquote>
<p>To rewrite the repository to look as if foodir/ has been its project root, and discard all other history:</p>
</blockquote>
<pre><co... | <p>Quoting an example from <a href="https://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html" rel="noreferrer"><code>git-filter-branch(1)</code></a></p> <blockquote> <p>To rewrite the repository to look as if foodir/ has been its project root, and discard all other history:</p> </blockquote> <pre><co... | 119, 432, 1318, 4167 | export, git, history, import | <h1>Export subtree in Git with history</h1>
<p>I have a folder in my Git repository that I'd like to move out in to its own repository. Is it possible to move the history of that folder along with the folder?</p>
<p>I've previously been doing just a <code>git rm -r --cached subfolder/</code> and then <code>git init</c... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,831 | git | # Export subtree in Git with history
I have a folder in my Git repository that I'd like to move out in to its own repository. Is it possible to move the history of that folder along with the folder?
I've previously been doing just a `git rm -r --cached subfolder/` and then `git init` on the subfolder. However, the hi... | Quoting an example from [`git-filter-branch(1)`](https://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html)
> To rewrite the repository to look as if foodir/ has been its project root, and discard all other history:
```
git filter-branch --subdirectory-filter foodir -- --all
```
> Thus you can, e.g., t... |
2498458 | Why did git set us on (no branch)? | 81 | 2010-03-23 08:35:00 | <p>This morning we pulled from our repo, and git put us on (no branch).</p>
<p>I don't understand this, why did this happen? And how to get out of it without losing our changes?</p>
| 90,621 | 9,951 | 2023-02-20 16:42:25 | 2,498,553 | 110 | 2010-03-23 08:57:30 | 19,750 | 2011-08-09 14:15:22 | https://stackoverflow.com/q/2498458 | https://stackoverflow.com/a/2498553 | <p>"Not currently on any branch" means you have a <a href="http://git-scm.com/docs/git-checkout#_detached_head" rel="noreferrer" title="git-checkout(1)">detached</a> <a href="http://sitaramc.github.com/concepts/detached-head.html" rel="noreferrer" title="detached HEAD explained">head</a>, i.e. your HEAD pointer is dire... | <p>"Not currently on any branch" means you have a <a href="http://git-scm.com/docs/git-checkout#_detached_head" rel="noreferrer" title="git-checkout(1)">detached</a> <a href="http://sitaramc.github.com/concepts/detached-head.html" rel="noreferrer" title="detached HEAD explained">head</a>, i.e. your HEAD pointer is dire... | 119 | git | <h1>Why did git set us on (no branch)?</h1>
<p>This morning we pulled from our repo, and git put us on (no branch).</p>
<p>I don't understand this, why did this happen? And how to get out of it without losing our changes?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,833 | git | # Why did git set us on (no branch)?
This morning we pulled from our repo, and git put us on (no branch).
I don't understand this, why did this happen? And how to get out of it without losing our changes? | "Not currently on any branch" means you have a [detached](http://git-scm.com/docs/git-checkout#_detached_head "git-checkout(1)") [head](http://sitaramc.github.com/concepts/detached-head.html "detached HEAD explained"), i.e. your HEAD pointer is directly referencing a commit instead of symbolically pointing at the name ... |
11676210 | git log the difference between 1 branch from another | 67 | 2012-07-26 18:58:22 | <p>I have 2 branches A and B.</p>
<p>Whenever I run a build, Branch A gets merged into Branch B. I want to be able to email out all the updates made in A, since the last time the build was ran. How can I use <code>git log</code> to be able to copy all the commits made in A since the last A -> B merge?</p>
| 28,021 | 823,118 | 2015-08-21 04:33:38 | 11,676,279 | 110 | 2012-07-26 19:02:13 | 7,806 | 2015-08-21 04:33:38 | https://stackoverflow.com/q/11676210 | https://stackoverflow.com/a/11676279 | <p>That'll be</p>
<pre><code>git log B..A
</code></pre>
<p>E.g. "display all commits that are in A but not in B" Or if you wish to do it against non local branches</p>
<pre><code>git log origin/B..origin/A
</code></pre>
| <p>That'll be</p> <pre><code>git log B..A </code></pre> <p>E.g. "display all commits that are in A but not in B" Or if you wish to do it against non local branches</p> <pre><code>git log origin/B..origin/A </code></pre> | 119, 28897, 47913 | git, git-log, git-merge | <h1>git log the difference between 1 branch from another</h1>
<p>I have 2 branches A and B.</p>
<p>Whenever I run a build, Branch A gets merged into Branch B. I want to be able to email out all the updates made in A, since the last time the build was ran. How can I use <code>git log</code> to be able to copy all the ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,834 | git | # git log the difference between 1 branch from another
I have 2 branches A and B.
Whenever I run a build, Branch A gets merged into Branch B. I want to be able to email out all the updates made in A, since the last time the build was ran. How can I use `git log` to be able to copy all the commits made in A since the ... | That'll be
```
git log B..A
```
E.g. "display all commits that are in A but not in B" Or if you wish to do it against non local branches
```
git log origin/B..origin/A
``` |
50736080 | Rebasing a local branch from develop | 45 | 2018-06-07 08:11:00 | <p>I want to rebase a feature branch from develop. I am using PhpStorm Git integration and I have 2 different develop branches:</p>
<pre><code>refs/remotes/origin/develop
refs/heads/develop
</code></pre>
<p>In order to do not mess up things, which one do I have to choose to rebase?</p>
| 121,870 | 7,972,985 | 2025-05-28 15:14:11 | 50,736,599 | 110 | 2018-06-07 08:36:09 | 1,836,143 | 2025-05-28 15:14:11 | https://stackoverflow.com/q/50736080 | https://stackoverflow.com/a/50736599 | <p>I don't know the phpstorm interface for Git, but in the command line I'd do the following:</p>
<ul>
<li><code>git checkout develop</code></li>
<li><code>git pull origin develop</code> -> this fetches the remote version of the develop branch and merges it (or rebases it, depending on your pull strategy) into/onto ... | <p>I don't know the phpstorm interface for Git, but in the command line I'd do the following:</p> <ul> <li><code>git checkout develop</code></li> <li><code>git pull origin develop</code> -> this fetches the remote version of the develop branch and merges it (or rebases it, depending on your pull strategy) into/onto ... | 119, 8974, 66821 | git, phpstorm, rebase | <h1>Rebasing a local branch from develop</h1>
<p>I want to rebase a feature branch from develop. I am using PhpStorm Git integration and I have 2 different develop branches:</p>
<pre><code>refs/remotes/origin/develop
refs/heads/develop
</code></pre>
<p>In order to do not mess up things, which one do I have to choose ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,836 | git | # Rebasing a local branch from develop
I want to rebase a feature branch from develop. I am using PhpStorm Git integration and I have 2 different develop branches:
```
refs/remotes/origin/develop
refs/heads/develop
```
In order to do not mess up things, which one do I have to choose to rebase? | I don't know the phpstorm interface for Git, but in the command line I'd do the following:
- `git checkout develop`
- `git pull origin develop` -> this fetches the remote version of the develop branch and merges it (or rebases it, depending on your pull strategy) into/onto your local branch. This way the local and the... |
44680028 | What's the difference between "git stash save" and "git stash push"? | 110 | 2017-06-21 15:14:33 | <p>When should I use <code>git stash save</code> instead of <code>git stash push</code> and vice-versa?</p>
| 51,702 | 385,655 | 2024-06-02 13:44:38 | 44,681,952 | 109 | 2017-06-21 16:50:44 | 7,976,758 | 2017-06-21 16:50:44 | https://stackoverflow.com/q/44680028 | https://stackoverflow.com/a/44681952 | <p><code>git stash save</code> accepts a single non-option argument — the stash message.</p>
<p><code>git stash push</code> accepts the message with option <code>-m</code> and accepts a list of files to stash as arguments.</p>
| <p><code>git stash save</code> accepts a single non-option argument — the stash message.</p> <p><code>git stash push</code> accepts the message with option <code>-m</code> and accepts a list of files to stash as arguments.</p> | 119, 13091 | git, git-stash | <h1>What's the difference between "git stash save" and "git stash push"?</h1>
<p>When should I use <code>git stash save</code> instead of <code>git stash push</code> and vice-versa?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,838 | git | # What's the difference between "git stash save" and "git stash push"?
When should I use `git stash save` instead of `git stash push` and vice-versa? | `git stash save` accepts a single non-option argument — the stash message.
`git stash push` accepts the message with option `-m` and accepts a list of files to stash as arguments. |
11563319 | git rebase basics | 99 | 2012-07-19 14:44:09 | <p>I have started using <code>git rebase</code> recently and am not 100% certain I'm doing it right. For the sake of the question, there are two branches in origin, <code>master</code> and <code>next</code>, which was branched from <code>master</code>.</p>
<p>Since last sync between the two, <code>master</code> had 2 ... | 112,006 | 172,609 | 2025-01-10 03:16:49 | 11,566,503 | 109 | 2012-07-19 17:48:47 | 149,170 | 2012-07-19 22:07:59 | https://stackoverflow.com/q/11563319 | https://stackoverflow.com/a/11566503 | <p>Let's start from the beginning. Here's a diagram of your original state:</p>
<pre>
A-B-C (master, origin/master)
\
D-E-F-G-H-I (next, origin/next)
</pre>
<p>When you checked out <code>next</code> and rebased <code>next</code> onto <code>origin/master</code>, it created 6 new commits after the two that are alr... | <p>Let's start from the beginning. Here's a diagram of your original state:</p> <pre> A-B-C (master, origin/master) \ D-E-F-G-H-I (next, origin/next) </pre> <p>When you checked out <code>next</code> and rebased <code>next</code> onto <code>origin/master</code>, it created 6 new commits after the two that are alr... | 119, 29934 | git, git-rebase | <h1>git rebase basics</h1>
<p>I have started using <code>git rebase</code> recently and am not 100% certain I'm doing it right. For the sake of the question, there are two branches in origin, <code>master</code> and <code>next</code>, which was branched from <code>master</code>.</p>
<p>Since last sync between the two,... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,840 | git | # git rebase basics
I have started using `git rebase` recently and am not 100% certain I'm doing it right. For the sake of the question, there are two branches in origin, `master` and `next`, which was branched from `master`.
Since last sync between the two, `master` had 2 commits and `next` 6:
```
$ git log --oneli... | Let's start from the beginning. Here's a diagram of your original state:
```
A-B-C (master, origin/master)
\
D-E-F-G-H-I (next, origin/next)
```
When you checked out `next` and rebased `next` onto `origin/master`, it created 6 new commits after the two that are already on `origin/master`. These new commits have ... |
10678495 | Where to find changes due to `git fetch` | 84 | 2012-05-21 00:56:04 | <p>I didn't want to lose some information after a <code>git pull</code>, so I did a <code>git fetch</code> before. Where can I read the new modifications after a <code>git fetch</code>? I went to the <code>FETCH_HEAD</code> file, but there was nothing more than a big number.</p>
| 54,788 | 1,275,959 | 2023-05-16 13:07:29 | 10,685,691 | 109 | 2012-05-21 12:57:29 | 720,999 | 2018-03-02 22:06:17 | https://stackoverflow.com/q/10678495 | https://stackoverflow.com/a/10685691 | <p><code>git fetch origin</code> by default fetches everything from the remote named "origin" and updates (or creates) the so-called "remote-tracking branches" for that remote. Say, for the remote named "origin" which contain branches named "master" and "feature", running <code>git fetch remote</code> will result in t... | <p><code>git fetch origin</code> by default fetches everything from the remote named "origin" and updates (or creates) the so-called "remote-tracking branches" for that remote. Say, for the remote named "origin" which contain branches named "master" and "feature", running <code>git fetch remote</code> will result in t... | 119, 4860, 33720 | git, git-fetch, pull | <h1>Where to find changes due to `git fetch`</h1>
<p>I didn't want to lose some information after a <code>git pull</code>, so I did a <code>git fetch</code> before. Where can I read the new modifications after a <code>git fetch</code>? I went to the <code>FETCH_HEAD</code> file, but there was nothing more than a big nu... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,841 | git | # Where to find changes due to `git fetch`
I didn't want to lose some information after a `git pull`, so I did a `git fetch` before. Where can I read the new modifications after a `git fetch`? I went to the `FETCH_HEAD` file, but there was nothing more than a big number. | `git fetch origin` by default fetches everything from the remote named "origin" and updates (or creates) the so-called "remote-tracking branches" for that remote. Say, for the remote named "origin" which contain branches named "master" and "feature", running `git fetch remote` will result in the remote-tracking branche... |
3142419 | How can I move a directory in a Git repo for all commits? | 79 | 2010-06-29 15:54:42 | <p>Let's say I have a repo that includes this directory structure:</p>
<pre><code>repo/
blog/
_posts/
some-post.html
another-file.txt
</code></pre>
<p>I want to move <code>_posts</code> to the top level of the repo, so the structure will look like this:</p>
<pre><code>repo/
_posts/
some-post.html... | 31,250 | 28,804 | 2022-07-06 07:41:10 | 3,142,821 | 109 | 2010-06-29 16:45:27 | 145,844 | 2015-11-05 21:38:51 | https://stackoverflow.com/q/3142419 | https://stackoverflow.com/a/3142821 | <p>You can use the subdirectory filter to achieve this</p>
<pre><code> $ git filter-branch --subdirectory-filter blog/ -- --all
</code></pre>
<p><strong>EDIT 1:</strong> If you don't want to effectively make <code>_posts</code> the root, use a tree-filter instead:</p>
<pre><code> $ git filter-branch --tree-filter 'm... | <p>You can use the subdirectory filter to achieve this</p> <pre><code> $ git filter-branch --subdirectory-filter blog/ -- --all </code></pre> <p><strong>EDIT 1:</strong> If you don't want to effectively make <code>_posts</code> the root, use a tree-filter instead:</p> <pre><code> $ git filter-branch --tree-filter 'm... | 119, 46509 | git, git-filter-branch | <h1>How can I move a directory in a Git repo for all commits?</h1>
<p>Let's say I have a repo that includes this directory structure:</p>
<pre><code>repo/
blog/
_posts/
some-post.html
another-file.txt
</code></pre>
<p>I want to move <code>_posts</code> to the top level of the repo, so the structure will... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,842 | git | # How can I move a directory in a Git repo for all commits?
Let's say I have a repo that includes this directory structure:
```
repo/
blog/
_posts/
some-post.html
another-file.txt
```
I want to move `_posts` to the top level of the repo, so the structure will look like this:
```
repo/
_posts/
so... | You can use the subdirectory filter to achieve this
```
$ git filter-branch --subdirectory-filter blog/ -- --all
```
**EDIT 1:** If you don't want to effectively make `_posts` the root, use a tree-filter instead:
```
$ git filter-branch --tree-filter 'mv blog/_posts .' HEAD
```
**EDIT 2:** If `blog/_posts` did no... |
30844254 | Undo changes made in a specific folder in Git | 74 | 2015-06-15 11:39:48 | <p>How I can undo changes made in a specific folder?</p>
<p>I've modified files from multiple folders like</p>
<pre><code>app/code/core/
app/code/local/
app/design/frontend/
</code></pre>
<p>I want to undo all the changes made in files present in <code>app/code/core/</code>, while keeping the changes modified in fil... | 81,589 | 1,728,526 | 2024-03-11 13:49:37 | 30,844,337 | 109 | 2015-06-15 11:43:51 | 724,411 | 2019-02-08 01:30:15 | https://stackoverflow.com/q/30844254 | https://stackoverflow.com/a/30844337 | <p>If you want to undo the changes, do <code>git checkout app/code/core/</code></p>
| <p>If you want to undo the changes, do <code>git checkout app/code/core/</code></p> | 119 | git | <h1>Undo changes made in a specific folder in Git</h1>
<p>How I can undo changes made in a specific folder?</p>
<p>I've modified files from multiple folders like</p>
<pre><code>app/code/core/
app/code/local/
app/design/frontend/
</code></pre>
<p>I want to undo all the changes made in files present in <code>app/code/... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,843 | git | # Undo changes made in a specific folder in Git
How I can undo changes made in a specific folder?
I've modified files from multiple folders like
```
app/code/core/
app/code/local/
app/design/frontend/
```
I want to undo all the changes made in files present in `app/code/core/`, while keeping the changes modified in... | If you want to undo the changes, do `git checkout app/code/core/` |
17868956 | Homebrew update fail: "Please, commit your changes or stash them before you can merge" | 72 | 2013-07-25 21:21:25 | <p>I am running:</p>
<pre><code>brew update
</code></pre>
<p>And I get an error:</p>
<pre><code>error: Your local changes to the following files would be overwritten by merge:
samtools.rb
Please, commit your changes or stash them before you can merge.
Aborting
</code></pre>
<p>It turns out this is a well known ... | 41,002 | 265,614 | 2024-12-06 19:46:28 | 17,869,504 | 109 | 2013-07-25 21:56:53 | 265,614 | 2013-07-25 21:56:53 | https://stackoverflow.com/q/17868956 | https://stackoverflow.com/a/17869504 | <p>I was able to resolve the issue myself.</p>
<p>What tipped me off is running "git status" did not show that file.</p>
<p>Instead of using the common solution:</p>
<pre><code>cd $(brew --repository)
git reset --hard FETCH_HEAD
</code></pre>
<p>I had to do:</p>
<pre><code>cd [directory of the file in question]
gi... | <p>I was able to resolve the issue myself.</p> <p>What tipped me off is running "git status" did not show that file.</p> <p>Instead of using the common solution:</p> <pre><code>cd $(brew --repository) git reset --hard FETCH_HEAD </code></pre> <p>I had to do:</p> <pre><code>cd [directory of the file in question] gi... | 119, 369, 1067 | git, homebrew, macos | <h1>Homebrew update fail: "Please, commit your changes or stash them before you can merge"</h1>
<p>I am running:</p>
<pre><code>brew update
</code></pre>
<p>And I get an error:</p>
<pre><code>error: Your local changes to the following files would be overwritten by merge:
samtools.rb
Please, commit your changes o... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,844 | git | # Homebrew update fail: "Please, commit your changes or stash them before you can merge"
I am running:
```
brew update
```
And I get an error:
```
error: Your local changes to the following files would be overwritten by merge:
samtools.rb
Please, commit your changes or stash them before you can merge.
Aborting
... | I was able to resolve the issue myself.
What tipped me off is running "git status" did not show that file.
Instead of using the common solution:
```
cd $(brew --repository)
git reset --hard FETCH_HEAD
```
I had to do:
```
cd [directory of the file in question]
git reset --hard FETCH_HEAD
```
That resolved the pro... |
12661306 | git rm --cached file vs git reset file | 72 | 2012-09-30 12:40:55 | <p>I'm trying to learn Git. I'm confused between </p>
<pre><code>git rm --cached file
</code></pre>
<p>and</p>
<pre><code>git reset file
</code></pre>
<p>both of the commands seem to take the file from staged to un-staged area. How do the commands differ?</p>
| 115,811 | 1,203,565 | 2024-11-27 19:00:24 | 12,661,344 | 109 | 2012-09-30 12:46:22 | 19,563 | 2012-09-30 12:46:22 | https://stackoverflow.com/q/12661306 | https://stackoverflow.com/a/12661344 | <p><code>git rm --cached <file></code> will completely remove the file's contents from the index. This means that on commit the file will be removed from the <code>HEAD</code> commit. (If the file was only added to the index and not yet tracked this is a "no-op".)</p>
<p><code>git reset -- <file></code> re... | <p><code>git rm --cached <file></code> will completely remove the file's contents from the index. This means that on commit the file will be removed from the <code>HEAD</code> commit. (If the file was only added to the index and not yet tracked this is a "no-op".)</p> <p><code>git reset -- <file></code> re... | 119, 51381, 112901 | git, git-reset, git-rm | <h1>git rm --cached file vs git reset file</h1>
<p>I'm trying to learn Git. I'm confused between </p>
<pre><code>git rm --cached file
</code></pre>
<p>and</p>
<pre><code>git reset file
</code></pre>
<p>both of the commands seem to take the file from staged to un-staged area. How do the commands differ?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,845 | git | # git rm --cached file vs git reset file
I'm trying to learn Git. I'm confused between
```
git rm --cached file
```
and
```
git reset file
```
both of the commands seem to take the file from staged to un-staged area. How do the commands differ? | `git rm --cached <file>` will completely remove the file's contents from the index. This means that on commit the file will be removed from the `HEAD` commit. (If the file was only added to the index and not yet tracked this is a "no-op".)
`git reset -- <file>` resets the contents of the file in the index to be the sa... |
18830659 | How to `git log` a tree-ish from another branch? | 71 | 2013-09-16 14:36:09 | <p>Let's say I have a Git repo with branch <code>A</code> and branch <code>B</code>.<br>
Branch <code>B</code> is currently checked out (i.e. <code>.git/HEAD</code> contains <code>refs/heads/B</code>).<br>
Now, <strong>without checking out branch <code>A</code></strong>, how to view the history (log) of <code>path/file... | 29,371 | 531,179 | 2020-02-12 08:38:22 | 18,830,778 | 109 | 2013-09-16 14:41:34 | 289,099 | 2013-09-16 14:41:34 | https://stackoverflow.com/q/18830659 | https://stackoverflow.com/a/18830778 | <p>Try this (without the angle brackets):</p>
<p><code>git log <branch> -- <path/to/file></code></p>
| <p>Try this (without the angle brackets):</p> <p><code>git log <branch> -- <path/to/file></code></p> | 119, 47913 | git, git-log | <h1>How to `git log` a tree-ish from another branch?</h1>
<p>Let's say I have a Git repo with branch <code>A</code> and branch <code>B</code>.<br>
Branch <code>B</code> is currently checked out (i.e. <code>.git/HEAD</code> contains <code>refs/heads/B</code>).<br>
Now, <strong>without checking out branch <code>A</code><... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,846 | git | # How to `git log` a tree-ish from another branch?
Let's say I have a Git repo with branch `A` and branch `B`.
Branch `B` is currently checked out (i.e. `.git/HEAD` contains `refs/heads/B`).
Now, **without checking out branch `A`**, how to view the history (log) of `path/file` in branch `A`?
Following `git help r... | Try this (without the angle brackets):
`git log <branch> -- <path/to/file>` |
41946475 | git: why can't I delete my branch after a squash merge? | 69 | 2017-01-30 22:24:05 | <p>I have a git repo with <code>mainline</code> (equivalent to <code>master</code>) and some local feature branches. For example:</p>
<pre><code>$ git branch
* mainline
feature1
feature2
feature3
</code></pre>
<p>When I do the following, I am able to squash merge all of my edits in a feature branch into one co... | 16,230 | 1,002,119 | 2020-03-03 07:01:00 | 41,947,745 | 109 | 2017-01-31 00:22:04 | 1,256,452 | 2017-01-31 02:08:17 | https://stackoverflow.com/q/41946475 | https://stackoverflow.com/a/41947745 | <p>This happens because Git doesn't know that the squash merge is "equivalent to" the various branch-specific commits. You must forcibly delete the branch, with <code>git branch -D</code> instead of <code>git branch -d</code>.</p>
<p>(The rest of this is merely about <em>why</em> this is the case.)</p>
<h3>Draw the ... | <p>This happens because Git doesn't know that the squash merge is "equivalent to" the various branch-specific commits. You must forcibly delete the branch, with <code>git branch -D</code> instead of <code>git branch -d</code>.</p> <p>(The rest of this is merely about <em>why</em> this is the case.)</p> <h3>Draw the ... | 119, 717, 28897 | git, git-merge, merge | <h1>git: why can't I delete my branch after a squash merge?</h1>
<p>I have a git repo with <code>mainline</code> (equivalent to <code>master</code>) and some local feature branches. For example:</p>
<pre><code>$ git branch
* mainline
feature1
feature2
feature3
</code></pre>
<p>When I do the following, I am abl... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,847 | git | # git: why can't I delete my branch after a squash merge?
I have a git repo with `mainline` (equivalent to `master`) and some local feature branches. For example:
```
$ git branch
* mainline
feature1
feature2
feature3
```
When I do the following, I am able to squash merge all of my edits in a feature branch in... | This happens because Git doesn't know that the squash merge is "equivalent to" the various branch-specific commits. You must forcibly delete the branch, with `git branch -D` instead of `git branch -d`.
(The rest of this is merely about *why* this is the case.)
### Draw the commit graph
Let's draw (part of) the commi... |
2700140 | How do I search git history for a disappeared line? | 58 | 2010-04-23 16:10:55 | <p>I need to search the history of a specific file in a git repository to find a line that is gone. The commit message will not have any relevant text to search on. What command do I use?</p>
<p>Further details: this is the history of my todo list out of our non-stellar task tracking software. I've been keeping it ... | 10,046 | 18,103 | 2021-11-04 17:37:31 | 2,700,156 | 109 | 2010-04-23 16:14:13 | 119,963 | 2021-11-04 17:37:31 | https://stackoverflow.com/q/2700140 | https://stackoverflow.com/a/2700156 | <p>This is a job for the pickaxe!</p>
<p>From the git-log manpage:</p>
<blockquote>
<p><code>-S<string></code></p>
<p>Look for differences that introduce or remove an instance of <code><string></code>. Note that this is different than the string simply appearing in diff output; see the pickaxe entry in gitd... | <p>This is a job for the pickaxe!</p> <p>From the git-log manpage:</p> <blockquote> <p><code>-S<string></code></p> <p>Look for differences that introduce or remove an instance of <code><string></code>. Note that this is different than the string simply appearing in diff output; see the pickaxe entry in gitd... | 119 | git | <h1>How do I search git history for a disappeared line?</h1>
<p>I need to search the history of a specific file in a git repository to find a line that is gone. The commit message will not have any relevant text to search on. What command do I use?</p>
<p>Further details: this is the history of my todo list out of o... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,850 | git | # How do I search git history for a disappeared line?
I need to search the history of a specific file in a git repository to find a line that is gone. The commit message will not have any relevant text to search on. What command do I use?
Further details: this is the history of my todo list out of our non-stellar tas... | This is a job for the pickaxe!
From the git-log manpage:
> `-S<string>`
>
> Look for differences that introduce or remove an instance of `<string>`. Note that this is different than the string simply appearing in diff output; see the pickaxe entry in gitdiffcore(7) for more details.
You can of course use further opt... |
68238912 | How to configure and use `git send-email` to work with gmail to email patches to developers | 49 | 2021-07-03 18:19:17 | <p>How do I configure <code>git send-email</code> to work with gmail?</p>
<hr />
<p>I'd like to contribute to <code>glibc</code> (the <a href="https://www.gnu.org/software/libc/" rel="noreferrer">GNU C Library</a>, not to be confused with <a href="https://gitlab.gnome.org/GNOME/glib" rel="noreferrer">GNOME's GLib</a> l... | 22,851 | 4,561,887 | 2025-12-12 16:40:56 | 68,238,913 | 109 | 2021-07-03 18:19:17 | 4,561,887 | 2025-12-12 16:40:56 | https://stackoverflow.com/q/68238912 | https://stackoverflow.com/a/68238913 | <p>Note to developers and maintainers of <strong>glibc</strong>, <strong>Buildroot</strong>, <strong>GNU Binutils</strong>, and other projects which require the use of <code>git send-email</code> to send patches: if I wasn't a professional developer, there's not a chance in heck I could submit a patch, even if I knew h... | <p>Note to developers and maintainers of <strong>glibc</strong>, <strong>Buildroot</strong>, <strong>GNU Binutils</strong>, and other projects which require the use of <code>git send-email</code> to send patches: if I wasn't a professional developer, there's not a chance in heck I could submit a patch, even if I knew h... | 119, 161973 | git, git-send-email | <h1>How to configure and use `git send-email` to work with gmail to email patches to developers</h1>
<p>How do I configure <code>git send-email</code> to work with gmail?</p>
<hr />
<p>I'd like to contribute to <code>glibc</code> (the <a href="https://www.gnu.org/software/libc/" rel="noreferrer">GNU C Library</a>, not ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,851 | git | # How to configure and use `git send-email` to work with gmail to email patches to developers
How do I configure `git send-email` to work with gmail?
---
I'd like to contribute to `glibc` (the [GNU C Library](https://www.gnu.org/software/libc/), not to be confused with [GNOME's GLib](https://gitlab.gnome.org/GNOME/g... | Note to developers and maintainers of **glibc**, **Buildroot**, **GNU Binutils**, and other projects which require the use of `git send-email` to send patches: if I wasn't a professional developer, there's not a chance in heck I could submit a patch, even if I knew how to expertly code and had important changes to make... |
17748223 | EGit and Eclipse modifies .gitignore file but it should not | 49 | 2013-07-19 14:10:01 | <p>I'm using Eclipse and EGit, but Eclipse modifies my <em>.gitignore</em> file without me asking to do so. As soon as I open Eclipse the <em>.gitignore</em> file is modified.</p>
<p>I've added some folders to <em>.gitignore</em> (through EGit) but removed them after, but Eclipse keeps adding removed lines to <em>.git... | 18,686 | 914,411 | 2016-11-23 10:02:09 | 17,749,054 | 109 | 2013-07-19 14:46:38 | 305,973 | 2016-11-23 10:02:09 | https://stackoverflow.com/q/17748223 | https://stackoverflow.com/a/17749054 | <p>By default, EGit automatically adds resources marked as "Derived" to <code>.gitignore</code>. A typical example is the <code>bin</code> folder in a Java project containing the compiled classes.</p>
<p>You can disable this by going to Window > Preferences > Team > Git > Projects and deselect "Automatically ignore de... | <p>By default, EGit automatically adds resources marked as "Derived" to <code>.gitignore</code>. A typical example is the <code>bin</code> folder in a Java project containing the compiled classes.</p> <p>You can disable this by going to Window > Preferences > Team > Git > Projects and deselect "Automatically ignore de... | 53, 119, 3885, 43702 | eclipse, eclipse-plugin, egit, git | <h1>EGit and Eclipse modifies .gitignore file but it should not</h1>
<p>I'm using Eclipse and EGit, but Eclipse modifies my <em>.gitignore</em> file without me asking to do so. As soon as I open Eclipse the <em>.gitignore</em> file is modified.</p>
<p>I've added some folders to <em>.gitignore</em> (through EGit) but r... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,852 | git | # EGit and Eclipse modifies .gitignore file but it should not
I'm using Eclipse and EGit, but Eclipse modifies my *.gitignore* file without me asking to do so. As soon as I open Eclipse the *.gitignore* file is modified.
I've added some folders to *.gitignore* (through EGit) but removed them after, but Eclipse keeps ... | By default, EGit automatically adds resources marked as "Derived" to `.gitignore`. A typical example is the `bin` folder in a Java project containing the compiled classes.
You can disable this by going to Window > Preferences > Team > Git > Projects and deselect "Automatically ignore derived resources by adding them t... |
14409639 | Unable to update Git on Ubuntu | 32 | 2013-01-19 00:04:19 | <p>I am trying to set up Git on an Ubuntu Machine (I'm using a Samsung Chromebook running Ubuntu 12.04). </p>
<p>When I entered "sudo apt-get install git" and it successfully installed Git 1.79</p>
<pre><code>user@ChrUbuntu:~$ git --version
git version 1.7.9.5
</code></pre>
<p>I can't figure out what I am doing wron... | 20,578 | 1,247,016 | 2015-02-18 10:40:57 | 17,312,327 | 109 | 2013-06-26 05:42:41 | 1,366,534 | 2014-01-29 00:34:11 | https://stackoverflow.com/q/14409639 | https://stackoverflow.com/a/17312327 | <p>For new installations of Ubuntu I would first try this to get the latest updates</p>
<pre><code>sudo apt-get dist-upgrade
</code></pre>
<p>For more info on this see <a href="https://askubuntu.com/questions/81585/what-is-dist-upgrade-and-why-does-it-upgrade-more-than-upgrade">https://askubuntu.com/questions/81585/w... | <p>For new installations of Ubuntu I would first try this to get the latest updates</p> <pre><code>sudo apt-get dist-upgrade </code></pre> <p>For more info on this see <a href="https://askubuntu.com/questions/81585/what-is-dist-upgrade-and-why-does-it-upgrade-more-than-upgrade">https://askubuntu.com/questions/81585/w... | 58, 119, 549 | git, linux, ubuntu | <h1>Unable to update Git on Ubuntu</h1>
<p>I am trying to set up Git on an Ubuntu Machine (I'm using a Samsung Chromebook running Ubuntu 12.04). </p>
<p>When I entered "sudo apt-get install git" and it successfully installed Git 1.79</p>
<pre><code>user@ChrUbuntu:~$ git --version
git version 1.7.9.5
</code></pre>
<p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,853 | git | # Unable to update Git on Ubuntu
I am trying to set up Git on an Ubuntu Machine (I'm using a Samsung Chromebook running Ubuntu 12.04).
When I entered "sudo apt-get install git" and it successfully installed Git 1.79
```
user@ChrUbuntu:~$ git --version
git version 1.7.9.5
```
I can't figure out what I am doing wrong... | For new installations of Ubuntu I would first try this to get the latest updates
```
sudo apt-get dist-upgrade
```
For more info on this see <https://askubuntu.com/questions/81585/what-is-dist-upgrade-and-why-does-it-upgrade-more-than-upgrade>
That should solve it but if not, add the repository from these guys <http... |
3442874 | In Git, how can I write the current commit hash to a file in the same commit | 186 | 2010-08-09 18:15:50 | <p>I'm trying to do a fancy stuff here with Git hooks, but I don't really know how to do it (or if it's possible).</p>
<p>What I need to do is: in every commit I want to take its hash and then update a file in the commit with this hash.</p>
<p>Any ideas?</p>
| 78,004 | 415,338 | 2023-06-15 07:15:56 | 3,443,485 | 108 | 2010-08-09 19:30:38 | 119,963 | 2010-08-09 19:30:38 | https://stackoverflow.com/q/3442874 | https://stackoverflow.com/a/3443485 | <p>I would recommend doing something similar to what you have in mind: placing the SHA1 in an <em>untracked</em> file, generated as part of the build/installation/deployment process. It's obviously easy to do (<code>git rev-parse HEAD > filename</code> or perhaps <code>git describe [--tags] > filename</code>), an... | <p>I would recommend doing something similar to what you have in mind: placing the SHA1 in an <em>untracked</em> file, generated as part of the build/installation/deployment process. It's obviously easy to do (<code>git rev-parse HEAD > filename</code> or perhaps <code>git describe [--tags] > filename</code>), an... | 119, 853 | git, hook | <h1>In Git, how can I write the current commit hash to a file in the same commit</h1>
<p>I'm trying to do a fancy stuff here with Git hooks, but I don't really know how to do it (or if it's possible).</p>
<p>What I need to do is: in every commit I want to take its hash and then update a file in the commit with this ha... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,854 | git | # In Git, how can I write the current commit hash to a file in the same commit
I'm trying to do a fancy stuff here with Git hooks, but I don't really know how to do it (or if it's possible).
What I need to do is: in every commit I want to take its hash and then update a file in the commit with this hash.
Any ideas? | I would recommend doing something similar to what you have in mind: placing the SHA1 in an *untracked* file, generated as part of the build/installation/deployment process. It's obviously easy to do (`git rev-parse HEAD > filename` or perhaps `git describe [--tags] > filename`), and it avoids doing anything crazy like ... |
4033009 | Git rebase: conflicts keep blocking progress | 125 | 2010-10-27 12:13:16 | <p>I have a git branch (called v4), that was made from master just yesterday. There were a couple of changes to master, that I want to get into v4. So, in v4, I tried to do a rebase from master, and one file keeps screwing things up: a one-line text file, that contains the version number. This file is <code>app/view... | 115,936 | 138,557 | 2014-09-26 08:41:35 | 4,851,776 | 108 | 2011-01-31 14:06:02 | 5,353 | 2013-02-07 18:49:54 | https://stackoverflow.com/q/4033009 | https://stackoverflow.com/a/4851776 | <p>I encountered a similar problem with a rebase. My problem was caused because one of my commit only changed a file, and when resolving, I discarded the change introduced in this commit. I was able to solve my problem by skipping the corresponding commit (<code>git rebase --skip</code>).</p>
<p>You can reproduce this... | <p>I encountered a similar problem with a rebase. My problem was caused because one of my commit only changed a file, and when resolving, I discarded the change introduced in this commit. I was able to solve my problem by skipping the corresponding commit (<code>git rebase --skip</code>).</p> <p>You can reproduce this... | 119, 8974 | git, rebase | <h1>Git rebase: conflicts keep blocking progress</h1>
<p>I have a git branch (called v4), that was made from master just yesterday. There were a couple of changes to master, that I want to get into v4. So, in v4, I tried to do a rebase from master, and one file keeps screwing things up: a one-line text file, that con... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,855 | git | # Git rebase: conflicts keep blocking progress
I have a git branch (called v4), that was made from master just yesterday. There were a couple of changes to master, that I want to get into v4. So, in v4, I tried to do a rebase from master, and one file keeps screwing things up: a one-line text file, that contains the v... | I encountered a similar problem with a rebase. My problem was caused because one of my commit only changed a file, and when resolving, I discarded the change introduced in this commit. I was able to solve my problem by skipping the corresponding commit (`git rebase --skip`).
You can reproduce this problem in a test re... |
7318918 | fatal: does not appear to be a git repository | 123 | 2011-09-06 11:09:30 | <p>Why am I getting this error when my Git repository URL is correct?</p>
<pre><code>fatal: 'git@skarp.beanstalkapp.com/gittest.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
</code></pre>
<p>See it in context below, or <a href="https://i.sstatic.net/vy0JX.jpg" rel="noreferrer">a... | 370,267 | 84,201 | 2022-05-31 18:27:13 | 7,319,177 | 108 | 2011-09-06 11:30:33 | 223,092 | 2013-02-18 08:22:36 | https://stackoverflow.com/q/7318918 | https://stackoverflow.com/a/7319177 | <p>You've got the syntax for the <code>scp</code>-style way of specifying a repository slightly wrong - it has to be:</p>
<pre><code>[user@]host.xz:path/to/repo.git/
</code></pre>
<p>... as you can see in the <a href="http://git-scm.com/docs/git-clone#URLS" rel="noreferrer">git clone</a> documentation. You should us... | <p>You've got the syntax for the <code>scp</code>-style way of specifying a repository slightly wrong - it has to be:</p> <pre><code>[user@]host.xz:path/to/repo.git/ </code></pre> <p>... as you can see in the <a href="http://git-scm.com/docs/git-clone#URLS" rel="noreferrer">git clone</a> documentation. You should us... | 119, 41346 | git, git-remote | <h1>fatal: does not appear to be a git repository</h1>
<p>Why am I getting this error when my Git repository URL is correct?</p>
<pre><code>fatal: 'git@skarp.beanstalkapp.com/gittest.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
</code></pre>
<p>See it in context below, or <a hr... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,856 | git | # fatal: does not appear to be a git repository
Why am I getting this error when my Git repository URL is correct?
```
fatal: 'git@skarp.beanstalkapp.com/gittest.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
```
See it in context below, or [as a screenshot](https://i.sstatic.... | You've got the syntax for the `scp`-style way of specifying a repository slightly wrong - it has to be:
```
[user@]host.xz:path/to/repo.git/
```
... as you can see in the [git clone](http://git-scm.com/docs/git-clone#URLS) documentation. You should use instead the URL:
```
git@skarp.beanstalkapp.com:/gittest.git
```... |
8773422 | How can I add Git tags in Bitbucket? | 99 | 2012-01-07 21:55:26 | <p>I'm hosting my code on Bitbucket using Git. My local client is EGit (eclipse plugin). I created a tag locally (Team -> Advanced -> Tag) and then pushed it to remote repository. But when I open my repository page, I can't find tags there. I'm pretty sure the tag can be seen locally.</p>
<p>I'm not a Git expert.... | 148,720 | 464,956 | 2023-06-28 10:36:56 | 8,773,471 | 108 | 2012-01-07 22:03:21 | 159,874 | 2012-01-07 22:03:21 | https://stackoverflow.com/q/8773422 | https://stackoverflow.com/a/8773471 | <p>Did you click the button "Add All Tags Spec" in Push Wizard in Eclipse? If not, try it.
Or if you have access to console version of git just perform:</p>
<pre><code>git push --tags
</code></pre>
| <p>Did you click the button "Add All Tags Spec" in Push Wizard in Eclipse? If not, try it. Or if you have access to console version of git just perform:</p> <pre><code>git push --tags </code></pre> | 115, 119, 8337 | bitbucket, git, tags | <h1>How can I add Git tags in Bitbucket?</h1>
<p>I'm hosting my code on Bitbucket using Git. My local client is EGit (eclipse plugin). I created a tag locally (Team -> Advanced -> Tag) and then pushed it to remote repository. But when I open my repository page, I can't find tags there. I'm pretty sure the tag can... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,857 | git | # How can I add Git tags in Bitbucket?
I'm hosting my code on Bitbucket using Git. My local client is EGit (eclipse plugin). I created a tag locally (Team -> Advanced -> Tag) and then pushed it to remote repository. But when I open my repository page, I can't find tags there. I'm pretty sure the tag can be seen locall... | Did you click the button "Add All Tags Spec" in Push Wizard in Eclipse? If not, try it.
Or if you have access to console version of git just perform:
```
git push --tags
``` |
3162444 | git count files in the staged index | 90 | 2010-07-01 23:46:38 | <p>I'm trying to figure out how to easily count the files in my uncommitted index.</p>
<p>I've tried:</p>
<pre><code>git status | grep '#' | wc -l
</code></pre>
<p>but there are a few lines that start with <code>#</code> that don't represent changed files. Anyone got anything better? Figured there had to be a flag f... | 43,467 | 379,282 | 2024-03-13 16:44:14 | 3,162,492 | 108 | 2010-07-02 00:03:11 | 369,986 | 2010-07-02 00:03:11 | https://stackoverflow.com/q/3162444 | https://stackoverflow.com/a/3162492 | <p>If you want something a script can use:</p>
<p><code>git diff --cached --numstat | wc -l</code></p>
<p>If you want something human readable:</p>
<p><code>git diff --cached --stat</code></p>
| <p>If you want something a script can use:</p> <p><code>git diff --cached --numstat | wc -l</code></p> <p>If you want something human readable:</p> <p><code>git diff --cached --stat</code></p> | 119 | git | <h1>git count files in the staged index</h1>
<p>I'm trying to figure out how to easily count the files in my uncommitted index.</p>
<p>I've tried:</p>
<pre><code>git status | grep '#' | wc -l
</code></pre>
<p>but there are a few lines that start with <code>#</code> that don't represent changed files. Anyone got anyt... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,859 | git | # git count files in the staged index
I'm trying to figure out how to easily count the files in my uncommitted index.
I've tried:
```
git status | grep '#' | wc -l
```
but there are a few lines that start with `#` that don't represent changed files. Anyone got anything better? Figured there had to be a flag for `gi... | If you want something a script can use:
`git diff --cached --numstat | wc -l`
If you want something human readable:
`git diff --cached --stat` |
3867619 | How to get last Git tag matching regex criteria | 83 | 2010-10-05 20:50:56 | <p>I need Git command to <strong>get/find last tag starting with</strong> 'v' to get last versioning commit (I am using tags with v letter at the beginning to tag next application version (<strong>example: v0.9.1beta</strong>).</p>
<p>Is there any way to do it?</p>
| 79,535 | 229,229 | 2025-10-29 16:44:39 | 3,867,811 | 108 | 2010-10-05 21:17:33 | 221,213 | 2023-05-20 00:38:11 | https://stackoverflow.com/q/3867619 | https://stackoverflow.com/a/3867811 | <p>Use the following command:</p>
<pre><code>git describe --tags --match="v[0-9]*" HEAD
</code></pre>
<p>It will also modify the version if you did something with the source tree since your last versioned tag.</p>
<p><strong>NOTE:</strong> <code>--match</code> accepts a glob, <em>not</em> a regex, and therefo... | <p>Use the following command:</p> <pre><code>git describe --tags --match="v[0-9]*" HEAD </code></pre> <p>It will also modify the version if you did something with the source tree since your last versioned tag.</p> <p><strong>NOTE:</strong> <code>--match</code> accepts a glob, <em>not</em> a regex, and therefo... | 18, 119, 60718, 80455 | git, git-describe, git-tag, regex | <h1>How to get last Git tag matching regex criteria</h1>
<p>I need Git command to <strong>get/find last tag starting with</strong> 'v' to get last versioning commit (I am using tags with v letter at the beginning to tag next application version (<strong>example: v0.9.1beta</strong>).</p>
<p>Is there any way to do it?<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,860 | git | # How to get last Git tag matching regex criteria
I need Git command to **get/find last tag starting with** 'v' to get last versioning commit (I am using tags with v letter at the beginning to tag next application version (**example: v0.9.1beta**).
Is there any way to do it? | Use the following command:
```
git describe --tags --match="v[0-9]*" HEAD
```
It will also modify the version if you did something with the source tree since your last versioned tag.
**NOTE:** `--match` accepts a glob, *not* a regex, and therefore the command shown may match other tags, e.g. `v1234_this_matches_too`... |
7005513 | Pass an argument to a Git alias command | 80 | 2011-08-10 03:20:32 | <p>Can I pass arguments to the alias of a Git command?</p>
<p>I have some alias in Git config, like so:</p>
<pre><code>rb1 = rebase -i HEAD~1
rb2 = rebase -i HEAD~2
rb3 = rebase -i HEAD~3
rb4 = rebase -i HEAD~4
....
</code></pre>
<p>Is it possible to make an <code>rb</code> alias so that <code>git rb <x></code... | 28,236 | 631,613 | 2021-01-26 19:13:37 | 7,005,698 | 108 | 2011-08-10 03:54:25 | 6,309 | 2014-08-21 13:22:05 | https://stackoverflow.com/q/7005513 | https://stackoverflow.com/a/7005698 | <p>If you consider the <a href="https://git.wiki.kernel.org/index.php/Aliases#Advanced_aliases_with_arguments" rel="noreferrer">Git Faq section "Git Aliases with argument"</a>, you could do it, but by calling git through a shell:</p>
<pre><code>[alias]
rb = "!sh -c \"git rebase -i HEAD~$1\" -"
</code></pre>
<... | <p>If you consider the <a href="https://git.wiki.kernel.org/index.php/Aliases#Advanced_aliases_with_arguments" rel="noreferrer">Git Faq section "Git Aliases with argument"</a>, you could do it, but by calling git through a shell:</p> <pre><code>[alias] rb = "!sh -c \"git rebase -i HEAD~$1\" -" </code></pre> <... | 119, 32868, 79211 | git, git-alias, git-config | <h1>Pass an argument to a Git alias command</h1>
<p>Can I pass arguments to the alias of a Git command?</p>
<p>I have some alias in Git config, like so:</p>
<pre><code>rb1 = rebase -i HEAD~1
rb2 = rebase -i HEAD~2
rb3 = rebase -i HEAD~3
rb4 = rebase -i HEAD~4
....
</code></pre>
<p>Is it possible to make an <code>rb<... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,861 | git | # Pass an argument to a Git alias command
Can I pass arguments to the alias of a Git command?
I have some alias in Git config, like so:
```
rb1 = rebase -i HEAD~1
rb2 = rebase -i HEAD~2
rb3 = rebase -i HEAD~3
rb4 = rebase -i HEAD~4
....
```
Is it possible to make an `rb` alias so that `git rb <x>` works for any `<x... | If you consider the [Git Faq section "Git Aliases with argument"](https://git.wiki.kernel.org/index.php/Aliases#Advanced_aliases_with_arguments), you could do it, but by calling git through a shell:
```
[alias]
rb = "!sh -c \"git rebase -i HEAD~$1\" -"
```
I haven't tested it yet, but if you can pass an argum... |
6070179 | Switching branches without touching the working tree? | 78 | 2011-05-20 09:50:00 | <p>I am currently on a debug branch, and would like to switch to the master branch, without modifying the working tree (leave it the way it is in the debug branch), so I can commit some of the changes into the master branch.</p>
<p>Is there a way to do this?</p>
| 18,980 | 164,171 | 2020-06-03 03:28:31 | 15,993,574 | 108 | 2013-04-13 22:20:55 | 1,347,968 | 2020-06-03 03:28:31 | https://stackoverflow.com/q/6070179 | https://stackoverflow.com/a/15993574 | <p>You can do the following:</p>
<pre><code>git checkout --detach
git reset --soft master
git checkout master
</code></pre>
<hr>
<p>Explanation:</p>
<p>If you are on the <code>debug</code> branch and would do <code>git reset --soft master</code> you would leave your working tree and index untouched and move to the ... | <p>You can do the following:</p> <pre><code>git checkout --detach git reset --soft master git checkout master </code></pre> <hr> <p>Explanation:</p> <p>If you are on the <code>debug</code> branch and would do <code>git reset --soft master</code> you would leave your working tree and index untouched and move to the ... | 119, 456, 1879 | branch, git, version-control | <h1>Switching branches without touching the working tree?</h1>
<p>I am currently on a debug branch, and would like to switch to the master branch, without modifying the working tree (leave it the way it is in the debug branch), so I can commit some of the changes into the master branch.</p>
<p>Is there a way to do thi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,862 | git | # Switching branches without touching the working tree?
I am currently on a debug branch, and would like to switch to the master branch, without modifying the working tree (leave it the way it is in the debug branch), so I can commit some of the changes into the master branch.
Is there a way to do this? | You can do the following:
```
git checkout --detach
git reset --soft master
git checkout master
```
---
Explanation:
If you are on the `debug` branch and would do `git reset --soft master` you would leave your working tree and index untouched and move to the commit `master` points to. The problem is, `debug` will b... |
11778413 | Is there a command to undo git-flow feature start? | 74 | 2012-08-02 13:26:18 | <p>I'm inexperienced with git-flow.</p>
<p>Is there a command to undo <code>git-flow feature start</code>?</p>
| 43,347 | 537,353 | 2015-03-02 13:39:07 | 11,778,496 | 108 | 2012-08-02 13:30:49 | 356,942 | 2014-06-26 21:04:32 | https://stackoverflow.com/q/11778413 | https://stackoverflow.com/a/11778496 | <p>Since git-flow just wraps regular git functionality, how about simply deleting the new branch (assuming you have no changes in there you want saved)?</p>
<pre><code>$ git checkout master
Switched to branch 'master'
$ git branch -d feature/your-feature-name-here
</code></pre>
| <p>Since git-flow just wraps regular git functionality, how about simply deleting the new branch (assuming you have no changes in there you want saved)?</p> <pre><code>$ git checkout master Switched to branch 'master' $ git branch -d feature/your-feature-name-here </code></pre> | 119, 64339 | git, git-flow | <h1>Is there a command to undo git-flow feature start?</h1>
<p>I'm inexperienced with git-flow.</p>
<p>Is there a command to undo <code>git-flow feature start</code>?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,865 | git | # Is there a command to undo git-flow feature start?
I'm inexperienced with git-flow.
Is there a command to undo `git-flow feature start`? | Since git-flow just wraps regular git functionality, how about simply deleting the new branch (assuming you have no changes in there you want saved)?
```
$ git checkout master
Switched to branch 'master'
$ git branch -d feature/your-feature-name-here
``` |
9939952 | Create a patch including specific files in git | 69 | 2012-03-30 09:03:05 | <p>Let's say that I am 7 commits ahead of the origin/master repo. I would like to create a patch that includes in the patch specific files that were changed, not all the files. Or equivalent exclude specific files from the patch that were changed. How can I achieve that?</p>
| 52,143 | 1,291,118 | 2021-01-22 19:11:17 | 9,940,045 | 108 | 2012-03-30 09:09:00 | 223,092 | 2021-01-22 19:11:17 | https://stackoverflow.com/q/9939952 | https://stackoverflow.com/a/9940045 | <p>You can create a patch file by restricting the output of <code>git diff</code> by listing paths at the end of the command (after a <code>--</code> to avoid any potential clashes between path names and branch names).</p>
<p>For example, you could do the following:</p>
<pre><code>git diff origin/master HEAD -- app/mod... | <p>You can create a patch file by restricting the output of <code>git diff</code> by listing paths at the end of the command (after a <code>--</code> to avoid any potential clashes between path names and branch names).</p> <p>For example, you could do the following:</p> <pre><code>git diff origin/master HEAD -- app/mod... | 119, 2132, 5310 | file, git, patch | <h1>Create a patch including specific files in git</h1>
<p>Let's say that I am 7 commits ahead of the origin/master repo. I would like to create a patch that includes in the patch specific files that were changed, not all the files. Or equivalent exclude specific files from the patch that were changed. How can I achiev... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,866 | git | # Create a patch including specific files in git
Let's say that I am 7 commits ahead of the origin/master repo. I would like to create a patch that includes in the patch specific files that were changed, not all the files. Or equivalent exclude specific files from the patch that were changed. How can I achieve that? | You can create a patch file by restricting the output of `git diff` by listing paths at the end of the command (after a `--` to avoid any potential clashes between path names and branch names).
For example, you could do the following:
```
git diff origin/master HEAD -- app/models/region.rb doc/ > changes.patch
```
A... |
1016798 | Excluding files from git-diff | 67 | 2009-06-19 07:47:06 | <p>I am tracking a project with Git. There are some <a href="https://en.wikipedia.org/wiki/Xcode" rel="nofollow noreferrer">Xcode</a> project files in the working copy that I want to keep tracking, but I do not want to see in diffs, because there are always dozens of changed lines that I am never interested in. Is ther... | 24,569 | 17,279 | 2025-05-31 19:25:44 | 1,017,676 | 108 | 2009-06-19 12:23:20 | 19,563 | 2024-05-29 20:19:15 | https://stackoverflow.com/q/1016798 | https://stackoverflow.com/a/1017676 | <p>The problem is that <code>/bin/true</code> will return immediately without reading its input. <code>git diff</code> therefore thinks, quite reasonably, that it has died prematurely.</p>
<p>You really want to unset the diff attribute, not set it to a bogus command. Try this in your <code>.gitattributes</code>:</p>
<p... | <p>The problem is that <code>/bin/true</code> will return immediately without reading its input. <code>git diff</code> therefore thinks, quite reasonably, that it has died prematurely.</p> <p>You really want to unset the diff attribute, not set it to a bogus command. Try this in your <code>.gitattributes</code>:</p> <p... | 119, 9033, 164678 | git, git-diff, git-pathspec | <h1>Excluding files from git-diff</h1>
<p>I am tracking a project with Git. There are some <a href="https://en.wikipedia.org/wiki/Xcode" rel="nofollow noreferrer">Xcode</a> project files in the working copy that I want to keep tracking, but I do not want to see in diffs, because there are always dozens of changed lines... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,867 | git | # Excluding files from git-diff
I am tracking a project with Git. There are some [Xcode](https://en.wikipedia.org/wiki/Xcode) project files in the working copy that I want to keep tracking, but I do not want to see in diffs, because there are always dozens of changed lines that I am never interested in. Is there a sim... | The problem is that `/bin/true` will return immediately without reading its input. `git diff` therefore thinks, quite reasonably, that it has died prematurely.
You really want to unset the diff attribute, not set it to a bogus command. Try this in your `.gitattributes`:
```
Project.xcodeproj/* -diff
``` |
4460202 | How to set patience as default git diff algorithm | 61 | 2010-12-16 11:19:48 | <p>In .git/config I tried:</p>
<pre><code>[diff]
patience = true
</code></pre>
<p>But no luck</p>
<p>Do I have to do:</p>
<pre><code>git diff --patience
git show --patience HEAD
</code></pre>
<p>etc., every time?</p>
| 12,308 | 6,691 | 2013-04-11 07:33:14 | 13,689,062 | 108 | 2012-12-03 18:03:13 | 229,753 | 2013-04-11 07:33:14 | https://stackoverflow.com/q/4460202 | https://stackoverflow.com/a/13689062 | <p>Since <a href="https://git-htmldocs.googlecode.com/git/RelNotes/1.8.2.txt" rel="noreferrer" title="released 2013-03-13">Git 1.8.2</a>, Git will use <code>diff.algorithm</code>:</p>
<pre><code>git config --global diff.algorithm patience
</code></pre>
<p>It took a few iterations:</p>
<blockquote>
<p><a href="http://co... | <p>Since <a href="https://git-htmldocs.googlecode.com/git/RelNotes/1.8.2.txt" rel="noreferrer" title="released 2013-03-13">Git 1.8.2</a>, Git will use <code>diff.algorithm</code>:</p> <pre><code>git config --global diff.algorithm patience </code></pre> <p>It took a few iterations:</p> <blockquote> <p><a href="http://co... | 119, 606 | diff, git | <h1>How to set patience as default git diff algorithm</h1>
<p>In .git/config I tried:</p>
<pre><code>[diff]
patience = true
</code></pre>
<p>But no luck</p>
<p>Do I have to do:</p>
<pre><code>git diff --patience
git show --patience HEAD
</code></pre>
<p>etc., every time?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,868 | git | # How to set patience as default git diff algorithm
In .git/config I tried:
```
[diff]
patience = true
```
But no luck
Do I have to do:
```
git diff --patience
git show --patience HEAD
```
etc., every time? | Since [Git 1.8.2](https://git-htmldocs.googlecode.com/git/RelNotes/1.8.2.txt "released 2013-03-13"), Git will use `diff.algorithm`:
```
git config --global diff.algorithm patience
```
It took a few iterations:
> [[PATCH v3 0/3] Rework git-diff algorithm selection](http://comments.gmane.org/gmane.comp.version-control... |
32407634 | When to use git subtree? | 159 | 2015-09-04 22:54:01 | <p>What problem does <code>git subtree</code> solve?
When and why should I use that feature?</p>
<p>I've read that it is <a href="https://makingsoftware.wordpress.com/2013/02/16/using-git-subtrees-for-repository-separation/">used for repository separation</a>. But why would I not just create two independent repositori... | 95,629 | 33,311 | 2026-01-12 13:18:28 | 33,579,069 | 107 | 2015-11-07 04:16:55 | 2,105,636 | 2026-01-12 13:18:28 | https://stackoverflow.com/q/32407634 | https://stackoverflow.com/a/33579069 | <p>You should be careful to note explicitly what you are talking about when you use the term <strong>'subtree'</strong> in the context of <code>git</code> as there are actually two separate but related topics here:</p>
<p><a href="https://github.com/git/git/blob/master/contrib/subtree/git-subtree.adoc" rel="nofollow no... | <p>You should be careful to note explicitly what you are talking about when you use the term <strong>'subtree'</strong> in the context of <code>git</code> as there are actually two separate but related topics here:</p> <p><a href="https://github.com/git/git/blob/master/contrib/subtree/git-subtree.adoc" rel="nofollow no... | 119, 68200 | git, git-subtree | <h1>When to use git subtree?</h1>
<p>What problem does <code>git subtree</code> solve?
When and why should I use that feature?</p>
<p>I've read that it is <a href="https://makingsoftware.wordpress.com/2013/02/16/using-git-subtrees-for-repository-separation/">used for repository separation</a>. But why would I not just... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,869 | git | # When to use git subtree?
What problem does `git subtree` solve?
When and why should I use that feature?
I've read that it is [used for repository separation](https://makingsoftware.wordpress.com/2013/02/16/using-git-subtrees-for-repository-separation/). But why would I not just create two independent repositories i... | You should be careful to note explicitly what you are talking about when you use the term **'subtree'** in the context of `git` as there are actually two separate but related topics here:
[git-subtree](https://github.com/git/git/blob/master/contrib/subtree/git-subtree.adoc) and [git subtree merge strategy](https://www... |
7130850 | How can I move all git content one-level up in the folder hierarchy? | 122 | 2011-08-20 09:14:43 | <p>I have a git repository whose structure looks like:</p>
<pre><code>+--repo.git
|
+----+bootstrap.py
+----+buildout.cfg
+----+.gitignore
+----+webapp
|
+---------+manage.py
+---------+modules
+---------+templates
+---------+static
+---------+...
+---------+...
</code></pre>
<p>I would like to move the contents of t... | 108,475 | 304,151 | 2022-08-14 18:49:44 | 19,464,714 | 107 | 2013-10-19 09:55:07 | 80,426 | 2020-11-02 19:50:11 | https://stackoverflow.com/q/7130850 | https://stackoverflow.com/a/19464714 | <p>The right way to do this is:</p>
<pre class="lang-sh prettyprint-override"><code>git mv repo.git/webapp/* repo.git/.
git rm repo.git/webapp
git add *
git commit -m "Folders moved out of webapp directory :-)"
</code></pre>
| <p>The right way to do this is:</p> <pre class="lang-sh prettyprint-override"><code>git mv repo.git/webapp/* repo.git/. git rm repo.git/webapp git add * git commit -m "Folders moved out of webapp directory :-)" </code></pre> | 119, 218 | directory, git | <h1>How can I move all git content one-level up in the folder hierarchy?</h1>
<p>I have a git repository whose structure looks like:</p>
<pre><code>+--repo.git
|
+----+bootstrap.py
+----+buildout.cfg
+----+.gitignore
+----+webapp
|
+---------+manage.py
+---------+modules
+---------+templates
+---------+static
+-------... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,872 | git | # How can I move all git content one-level up in the folder hierarchy?
I have a git repository whose structure looks like:
```
+--repo.git
|
+----+bootstrap.py
+----+buildout.cfg
+----+.gitignore
+----+webapp
|
+---------+manage.py
+---------+modules
+---------+templates
+---------+static
+---------+...
+---------+..... | The right way to do this is:
```
git mv repo.git/webapp/* repo.git/.
git rm repo.git/webapp
git add *
git commit -m "Folders moved out of webapp directory :-)"
``` |
33739400 | How do I refresh branches (local/remote) in Visual Studio when using Git? | 99 | 2015-11-16 15:52:49 | <h3>Update</h3>
<p>Upgrading to Visual Studio 2019 16.8.X has a new git workflow. This also includes a fetch button.</p>
<p><a href="https://i.sstatic.net/zj5cq.png" rel="noreferrer"><img src="https://i.sstatic.net/zj5cq.png" alt="enter image description here" /></a></p>
<h3>Summary</h3>
<p>I am learning how to use Git... | 64,508 | 1,558,269 | 2021-12-01 18:55:39 | 33,868,140 | 107 | 2015-11-23 09:59:35 | 6,309 | 2021-12-01 18:55:39 | https://stackoverflow.com/q/33739400 | https://stackoverflow.com/a/33868140 | <p>If the branch has been deleted on the server side, try in command line (since such a "button" doesn't seem to exist directly in Visual Studio):</p>
<pre><code>git remote prune origin --dry-run
</code></pre>
<p>(remove the <code>--dry-run</code> option to actually delete the local branches)</p>
<p>Delete th... | <p>If the branch has been deleted on the server side, try in command line (since such a "button" doesn't seem to exist directly in Visual Studio):</p> <pre><code>git remote prune origin --dry-run </code></pre> <p>(remove the <code>--dry-run</code> option to actually delete the local branches)</p> <p>Delete th... | 119, 33953, 135964 | git, visual-studio, visual-studio-2019 | <h1>How do I refresh branches (local/remote) in Visual Studio when using Git?</h1>
<h3>Update</h3>
<p>Upgrading to Visual Studio 2019 16.8.X has a new git workflow. This also includes a fetch button.</p>
<p><a href="https://i.sstatic.net/zj5cq.png" rel="noreferrer"><img src="https://i.sstatic.net/zj5cq.png" alt="enter ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,874 | git | # How do I refresh branches (local/remote) in Visual Studio when using Git?
### Update
Upgrading to Visual Studio 2019 16.8.X has a new git workflow. This also includes a fetch button.
[](https://i.sstatic.net/zj5cq.png)
### Summary
I am learning how ... | If the branch has been deleted on the server side, try in command line (since such a "button" doesn't seem to exist directly in Visual Studio):
```
git remote prune origin --dry-run
```
(remove the `--dry-run` option to actually delete the local branches)
Delete the corresponding local branch as well `git branch -d ... |
32365271 | What's the difference between `git diff --patience` and `git diff --histogram`? | 99 | 2015-09-03 00:36:00 | <p><a href="https://stackoverflow.com/questions/19949526/examples-of-different-results-produced-by-the-standard-myers-minimal-patienc">This earlier question</a> asked for the differences between 4 different Git diff strategies, but the only difference that was explained was the difference between <code>myers</code> and... | 33,340 | 34,799 | 2025-03-03 02:52:00 | 32,367,597 | 107 | 2015-09-03 05:27:31 | 6,309 | 2022-03-30 08:20:29 | https://stackoverflow.com/q/32365271 | https://stackoverflow.com/a/32367597 | <p>This histogram strategy was introduced in <a href="https://github.com/git/git/blob/77bd3ea9f54f1584147b594abc04c26ca516d987/Documentation/RelNotes/1.7.7.txt#L68-L70" rel="noreferrer">git 1.7.7 (Sept 2011)</a>, with the following description (as mentioned by the OP)</p>
<blockquote>
<p>"<code>git diff</code>&quo... | <p>This histogram strategy was introduced in <a href="https://github.com/git/git/blob/77bd3ea9f54f1584147b594abc04c26ca516d987/Documentation/RelNotes/1.7.7.txt#L68-L70" rel="noreferrer">git 1.7.7 (Sept 2011)</a>, with the following description (as mentioned by the OP)</p> <blockquote> <p>"<code>git diff</code>&quo... | 119, 248, 606, 9033 | algorithm, diff, git, git-diff | <h1>What's the difference between `git diff --patience` and `git diff --histogram`?</h1>
<p><a href="https://stackoverflow.com/questions/19949526/examples-of-different-results-produced-by-the-standard-myers-minimal-patienc">This earlier question</a> asked for the differences between 4 different Git diff strategies, but... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,875 | git | # What's the difference between `git diff --patience` and `git diff --histogram`?
[This earlier question](https://stackoverflow.com/questions/19949526/examples-of-different-results-produced-by-the-standard-myers-minimal-patienc) asked for the differences between 4 different Git diff strategies, but the only difference... | This histogram strategy was introduced in [git 1.7.7 (Sept 2011)](https://github.com/git/git/blob/77bd3ea9f54f1584147b594abc04c26ca516d987/Documentation/RelNotes/1.7.7.txt#L68-L70), with the following description (as mentioned by the OP)
> "`git diff`" learned a "`--histogram`" option to use a different diff generatio... |
1335302 | Add newly created specific folder to .gitignore in Git | 98 | 2009-08-26 14:52:58 | <p>I had a clean working directory and brought in a clone from a Git repo last night.
But now my local server created and contains a stats folder which I want to ignore. </p>
<p>I can't seem to get Git to ignore this folder when I run a git status.</p>
<pre><code>On branch master
Your branch is ahead of 'origin/mast... | 195,871 | 99,877 | 2019-09-06 09:14:30 | 1,335,337 | 107 | 2009-08-26 14:56:35 | 95,382 | 2009-08-26 15:05:42 | https://stackoverflow.com/q/1335302 | https://stackoverflow.com/a/1335337 | <p>Try <code>/public_html/stats/*</code> ?</p>
<p>But since the files in <code>git status</code> reported as <em>to be commited</em> that means you've already added them manually. In which case, of course, it's a bit too late to ignore. You can <code>git rm --cache</code> them (IIRC).</p>
| <p>Try <code>/public_html/stats/*</code> ?</p> <p>But since the files in <code>git status</code> reported as <em>to be commited</em> that means you've already added them manually. In which case, of course, it's a bit too late to ignore. You can <code>git rm --cache</code> them (IIRC).</p> | 119, 25056 | git, gitignore | <h1>Add newly created specific folder to .gitignore in Git</h1>
<p>I had a clean working directory and brought in a clone from a Git repo last night.
But now my local server created and contains a stats folder which I want to ignore. </p>
<p>I can't seem to get Git to ignore this folder when I run a git status.</p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,876 | git | # Add newly created specific folder to .gitignore in Git
I had a clean working directory and brought in a clone from a Git repo last night.
But now my local server created and contains a stats folder which I want to ignore.
I can't seem to get Git to ignore this folder when I run a git status.
```
On branch master
Y... | Try `/public_html/stats/*` ?
But since the files in `git status` reported as *to be commited* that means you've already added them manually. In which case, of course, it's a bit too late to ignore. You can `git rm --cache` them (IIRC). |
4873976 | How to commit only modified (and not new or deleted) files? | 76 | 2011-02-02 11:36:30 | <p><code>git status</code> shows a bunch of files which were modified and some which were deleted. I want to first commit the modified files and then the deleted ones. I don't see any option in <code>git add</code> that enables me to do this. How can I do it?</p>
<p><strong>EDIT</strong>: As pointed out, <code>git add... | 123,437 | 106,281 | 2021-05-27 13:29:06 | 12,000,642 | 107 | 2012-08-17 06:12:31 | 1,270,741 | 2014-02-19 09:08:17 | https://stackoverflow.com/q/4873976 | https://stackoverflow.com/a/12000642 | <p>The following command should do the trick:</p>
<pre><code>git commit -a
</code></pre>
<p>or</p>
<pre><code>git commit -am "commit message"
</code></pre>
<p>From the <a href="http://git-scm.com/book">Pro Git</a> book:</p>
<blockquote>
<p>Providing the -a option to the git commit command makes Git automatically... | <p>The following command should do the trick:</p> <pre><code>git commit -a </code></pre> <p>or</p> <pre><code>git commit -am "commit message" </code></pre> <p>From the <a href="http://git-scm.com/book">Pro Git</a> book:</p> <blockquote> <p>Providing the -a option to the git commit command makes Git automatically... | 119, 456 | git, version-control | <h1>How to commit only modified (and not new or deleted) files?</h1>
<p><code>git status</code> shows a bunch of files which were modified and some which were deleted. I want to first commit the modified files and then the deleted ones. I don't see any option in <code>git add</code> that enables me to do this. How can ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,877 | git | # How to commit only modified (and not new or deleted) files?
`git status` shows a bunch of files which were modified and some which were deleted. I want to first commit the modified files and then the deleted ones. I don't see any option in `git add` that enables me to do this. How can I do it?
**EDIT**: As pointed ... | The following command should do the trick:
```
git commit -a
```
or
```
git commit -am "commit message"
```
From the [Pro Git](http://git-scm.com/book) book:
> Providing the -a option to the git commit command makes Git automatically stage every file that is already tracked before doing the commit |
15536639 | git: checkout files from another branch into current branch (don't switch HEAD to the other branch) | 73 | 2013-03-20 23:20:18 | <p>I want to load a different version of the files that exist in another branch into my current branch.</p>
<p><code>git help checkout</code> says:</p>
<pre><code>DESCRIPTION
Updates files in the working tree to match the version in the index or
the specified tree. If no paths are given, git checkout will also
... | 33,644 | 234,593 | 2021-06-08 06:05:55 | 15,536,640 | 107 | 2013-03-20 23:20:18 | 234,593 | 2017-07-18 23:31:15 | https://stackoverflow.com/q/15536639 | https://stackoverflow.com/a/15536640 | <p>checkout by providing the current path, <code>.</code>:</p>
<p><code>git checkout other-branch-name -- .</code></p>
<p>This operation is similar to <a href="https://stackoverflow.com/questions/1282639/switch-git-branch-without-files-checkout">switching HEAD to another branch without checking out files</a>, but jus... | <p>checkout by providing the current path, <code>.</code>:</p> <p><code>git checkout other-branch-name -- .</code></p> <p>This operation is similar to <a href="https://stackoverflow.com/questions/1282639/switch-git-branch-without-files-checkout">switching HEAD to another branch without checking out files</a>, but jus... | 119, 1879, 37230 | branch, git, git-checkout | <h1>git: checkout files from another branch into current branch (don't switch HEAD to the other branch)</h1>
<p>I want to load a different version of the files that exist in another branch into my current branch.</p>
<p><code>git help checkout</code> says:</p>
<pre><code>DESCRIPTION
Updates files in the working tr... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,878 | git | # git: checkout files from another branch into current branch (don't switch HEAD to the other branch)
I want to load a different version of the files that exist in another branch into my current branch.
`git help checkout` says:
```
DESCRIPTION
Updates files in the working tree to match the version in the index o... | checkout by providing the current path, `.`:
`git checkout other-branch-name -- .`
This operation is similar to [switching HEAD to another branch without checking out files](https://stackoverflow.com/questions/1282639/switch-git-branch-without-files-checkout), but just from the "other direction".
As @김민준 mentions, t... |
7048763 | How to stop git from making files non-executable on cygwin? | 59 | 2011-08-13 01:14:31 | <p>I use git on Windows via cygwin and soon decided to use <code>filemode=false</code> (since otherwise I've got a lot of changes after the initial git clone). I'm definitely not interested in tracking permission at all, the only think I need is for some files to be executable. From time to time, I find that the <code>... | 26,761 | 581,205 | 2022-06-24 05:54:40 | 7,048,915 | 107 | 2011-08-13 06:03:02 | 389,146 | 2011-08-13 06:03:02 | https://stackoverflow.com/q/7048763 | https://stackoverflow.com/a/7048915 | <p>I believe you want <code>git update-index --chmod=+x <file></code>, followed by a commit. </p>
| <p>I believe you want <code>git update-index --chmod=+x <file></code>, followed by a commit. </p> | 119, 359, 1731 | cygwin, git, permissions | <h1>How to stop git from making files non-executable on cygwin?</h1>
<p>I use git on Windows via cygwin and soon decided to use <code>filemode=false</code> (since otherwise I've got a lot of changes after the initial git clone). I'm definitely not interested in tracking permission at all, the only think I need is for s... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,879 | git | # How to stop git from making files non-executable on cygwin?
I use git on Windows via cygwin and soon decided to use `filemode=false` (since otherwise I've got a lot of changes after the initial git clone). I'm definitely not interested in tracking permission at all, the only think I need is for some files to be exec... | I believe you want `git update-index --chmod=+x <file>`, followed by a commit. |
33911379 | git rebase fatal: Needed a single revision invalid upstream –i | 58 | 2015-11-25 08:13:10 | <p>I am trying to squanshing several commits together. When I used</p>
<pre><code>git rebase –i HEAD~8
</code></pre>
<p>I got a fatal:</p>
<pre><code>fatal: Needed a single revision
invalid upstream –i
</code></pre>
<p>Here is a part of commit logs:
<a href="https://i.sstatic.net/5wF8A.png" rel="noreferrer">git log... | 84,503 | 5,594,638 | 2021-03-04 06:10:57 | 33,911,409 | 107 | 2015-11-25 08:15:03 | 1,755,598 | 2021-03-04 06:10:57 | https://stackoverflow.com/q/33911379 | https://stackoverflow.com/a/33911409 | <p>Several options:</p>
<ul>
<li><p>You are not on a branch (<code>Detached head</code>) or maybe you are trying to <code>rebase</code> or the wrong branch.<br />
Checkout the branch you want to <code>rebase</code> and try again.</p>
</li>
<li><p>you don't have 8 commits in your history (you have 7 or less)</p>
</li>
<... | <p>Several options:</p> <ul> <li><p>You are not on a branch (<code>Detached head</code>) or maybe you are trying to <code>rebase</code> or the wrong branch.<br /> Checkout the branch you want to <code>rebase</code> and try again.</p> </li> <li><p>you don't have 8 commits in your history (you have 7 or less)</p> </li> <... | 119 | git | <h1>git rebase fatal: Needed a single revision invalid upstream –i</h1>
<p>I am trying to squanshing several commits together. When I used</p>
<pre><code>git rebase –i HEAD~8
</code></pre>
<p>I got a fatal:</p>
<pre><code>fatal: Needed a single revision
invalid upstream –i
</code></pre>
<p>Here is a part of commit ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,880 | git | # git rebase fatal: Needed a single revision invalid upstream –i
I am trying to squanshing several commits together. When I used
```
git rebase –i HEAD~8
```
I got a fatal:
```
fatal: Needed a single revision
invalid upstream –i
```
Here is a part of commit logs:
[git log](https://i.sstatic.net/5wF8A.png)
All of ... | Several options:
- You are not on a branch (`Detached head`) or maybe you are trying to `rebase` or the wrong branch.
Checkout the branch you want to `rebase` and try again.
- you don't have 8 commits in your history (you have 7 or less)
- try: `git rebase -i --root`
Here is the documentation for the `--root` fla... |
29937195 | How to diff ansible vault changes? | 48 | 2015-04-29 07:35:41 | <p>I'd like to see the actual git commit changes in the ansible vault file.</p>
<p>Is there an easy way how to achieve this?</p>
| 16,001 | 955,422 | 2021-04-04 16:04:01 | 39,511,274 | 107 | 2016-09-15 12:38:19 | 223,092 | 2016-12-15 17:13:42 | https://stackoverflow.com/q/29937195 | https://stackoverflow.com/a/39511274 | <p>You can do this very neatly, so that the normal git tools like <code>git log</code> and <code>git diff</code> can see inside the vaulted files, using a custom git diff driver and <code>.gitattributes</code>.</p>
<ul>
<li>Make sure that your vault password is in <code>.vault_password</code> and that that file is <em... | <p>You can do this very neatly, so that the normal git tools like <code>git log</code> and <code>git diff</code> can see inside the vaulted files, using a custom git diff driver and <code>.gitattributes</code>.</p> <ul> <li>Make sure that your vault password is in <code>.vault_password</code> and that that file is <em... | 119, 606, 86394, 111912 | ansible, ansible-vault, diff, git | <h1>How to diff ansible vault changes?</h1>
<p>I'd like to see the actual git commit changes in the ansible vault file.</p>
<p>Is there an easy way how to achieve this?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,882 | git | # How to diff ansible vault changes?
I'd like to see the actual git commit changes in the ansible vault file.
Is there an easy way how to achieve this? | You can do this very neatly, so that the normal git tools like `git log` and `git diff` can see inside the vaulted files, using a custom git diff driver and `.gitattributes`.
- Make sure that your vault password is in `.vault_password` and that that file is *not* committed - you should also add it to `.gitignore`.
- A... |
3133449 | Why does git-rebase give me merge conflicts when all I'm doing is squashing commits? | 236 | 2010-06-28 14:54:13 | <p>We have a Git repository with over 400 commits, the first couple dozen of which were a lot of trial-and-error. We want to clean up these commits by squashing many down into a single commit. Naturally, git-rebase seems the way to go. My problem is that it ends up with merge conflicts, and these conflicts are not easy... | 88,893 | 293,511 | 2021-02-16 23:01:46 | 3,143,485 | 106 | 2010-06-29 18:09:22 | 119,963 | 2010-06-29 19:03:48 | https://stackoverflow.com/q/3133449 | https://stackoverflow.com/a/3143485 | <p>All right, I'm confident enough to throw out an answer. Maybe will have to edit it, but I believe I know what your problem is.</p>
<p>Your toy repo test case has a merge in it - worse, it has a merge with conflicts. And you're rebasing across the merge. Without <code>-p</code> (which doesn't totally work with <code... | <p>All right, I'm confident enough to throw out an answer. Maybe will have to edit it, but I believe I know what your problem is.</p> <p>Your toy repo test case has a merge in it - worse, it has a merge with conflicts. And you're rebasing across the merge. Without <code>-p</code> (which doesn't totally work with <code... | 119, 28897, 29934, 37230, 76220 | git, git-branch, git-checkout, git-merge, git-rebase | <h1>Why does git-rebase give me merge conflicts when all I'm doing is squashing commits?</h1>
<p>We have a Git repository with over 400 commits, the first couple dozen of which were a lot of trial-and-error. We want to clean up these commits by squashing many down into a single commit. Naturally, git-rebase seems the w... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,883 | git | # Why does git-rebase give me merge conflicts when all I'm doing is squashing commits?
We have a Git repository with over 400 commits, the first couple dozen of which were a lot of trial-and-error. We want to clean up these commits by squashing many down into a single commit. Naturally, git-rebase seems the way to go.... | All right, I'm confident enough to throw out an answer. Maybe will have to edit it, but I believe I know what your problem is.
Your toy repo test case has a merge in it - worse, it has a merge with conflicts. And you're rebasing across the merge. Without `-p` (which doesn't totally work with `-i`), the merges are igno... |
12514197 | Convert a Git folder to a submodule retrospectively? | 160 | 2012-09-20 13:55:38 | <p>Quite often it is the case that you're writing a project of some kind, and after a while it becomes clear that some component of the project is actually useful as a standalone component (a library, perhaps). If you've had that idea from early on, then there's a fair chance that most of that code is in its own folder... | 42,667 | 210,945 | 2024-08-03 21:03:55 | 12,515,629 | 106 | 2012-09-20 15:13:38 | 112,968 | 2012-09-20 15:13:38 | https://stackoverflow.com/q/12514197 | https://stackoverflow.com/a/12515629 | <p>To isolate a subdirectory into its own repository, use <code>filter-branch</code> on a clone of the original repository:</p>
<pre><code>git clone <your_project> <your_submodule>
cd <your_submodule>
git filter-branch --subdirectory-filter 'path/to/your/submodule' --prune-empty -- --all
</code></pre... | <p>To isolate a subdirectory into its own repository, use <code>filter-branch</code> on a clone of the original repository:</p> <pre><code>git clone <your_project> <your_submodule> cd <your_submodule> git filter-branch --subdirectory-filter 'path/to/your/submodule' --prune-empty -- --all </code></pre... | 119, 41612 | git, git-submodules | <h1>Convert a Git folder to a submodule retrospectively?</h1>
<p>Quite often it is the case that you're writing a project of some kind, and after a while it becomes clear that some component of the project is actually useful as a standalone component (a library, perhaps). If you've had that idea from early on, then the... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,884 | git | # Convert a Git folder to a submodule retrospectively?
Quite often it is the case that you're writing a project of some kind, and after a while it becomes clear that some component of the project is actually useful as a standalone component (a library, perhaps). If you've had that idea from early on, then there's a fa... | To isolate a subdirectory into its own repository, use `filter-branch` on a clone of the original repository:
```
git clone <your_project> <your_submodule>
cd <your_submodule>
git filter-branch --subdirectory-filter 'path/to/your/submodule' --prune-empty -- --all
```
It's then nothing more than deleting your original... |
7938582 | How does git detect similar files for its rename detection? | 119 | 2011-10-29 11:22:17 | <p>Wikipedia explains the automatic rename detection:</p>
<blockquote>
<p>Briefly, given a file in revision N, a file of the same name in
revision N−1 is its default ancestor. However, when there is no
like-named file in revision N−1, Git searches for a file that existed
only in revision N−1 and is <strong>ver... | 31,874 | 18,706 | 2024-02-22 01:03:35 | 7,941,544 | 106 | 2011-10-29 20:41:21 | 526,535 | 2018-01-19 07:11:43 | https://stackoverflow.com/q/7938582 | https://stackoverflow.com/a/7941544 | <p>Git tracks file contents, not filenames. So renaming a file without changing its content is easy for git to detect. (Git does not track, but performs <strong><em>detection</em></strong>; using <code>git mv</code> or <code>git rm</code> and <code>git add</code> is effectively the same.)</p>
<p>When a file is added t... | <p>Git tracks file contents, not filenames. So renaming a file without changing its content is easy for git to detect. (Git does not track, but performs <strong><em>detection</em></strong>; using <code>git mv</code> or <code>git rm</code> and <code>git add</code> is effectively the same.)</p> <p>When a file is added t... | 119 | git | <h1>How does git detect similar files for its rename detection?</h1>
<p>Wikipedia explains the automatic rename detection:</p>
<blockquote>
<p>Briefly, given a file in revision N, a file of the same name in
revision N−1 is its default ancestor. However, when there is no
like-named file in revision N−1, Git searc... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,886 | git | # How does git detect similar files for its rename detection?
Wikipedia explains the automatic rename detection:
> Briefly, given a file in revision N, a file of the same name in
> revision N−1 is its default ancestor. However, when there is no
> like-named file in revision N−1, Git searches for a file that existed
>... | Git tracks file contents, not filenames. So renaming a file without changing its content is easy for git to detect. (Git does not track, but performs ***detection***; using `git mv` or `git rm` and `git add` is effectively the same.)
When a file is added to the repository, the filename is in the tree object. The actua... |
61002 | How can I generate a git diff of what's changed since the last time I pulled? | 87 | 2008-09-14 00:02:41 | <p>I'd like to script, preferably in rake, the following actions into a single command:</p>
<ol>
<li>Get the version of my local git repository.</li>
<li>Git pull the latest code.</li>
<li>Git diff from the version I extracted in step #1 to what is now in my local repository.</li>
</ol>
<p>In other words, I want to g... | 55,235 | 4,061 | 2010-05-14 00:31:19 | 62,303 | 106 | 2008-09-15 12:21:01 | 582 | 2008-09-15 12:21:01 | https://stackoverflow.com/q/61002 | https://stackoverflow.com/a/62303 | <p>You could do this fairly simply with refspecs.</p>
<pre><code>git pull origin
git diff @{1}..
</code></pre>
<p>That will give you a diff of the current branch as it existed before and after the pull. Note that if the pull doesn't actually update the current branch, the diff will give you the wrong results. Another... | <p>You could do this fairly simply with refspecs.</p> <pre><code>git pull origin git diff @{1}.. </code></pre> <p>That will give you a diff of the current branch as it existed before and after the pull. Note that if the pull doesn't actually update the current branch, the diff will give you the wrong results. Another... | 119, 606, 650, 4860 | diff, git, pull, rake | <h1>How can I generate a git diff of what's changed since the last time I pulled?</h1>
<p>I'd like to script, preferably in rake, the following actions into a single command:</p>
<ol>
<li>Get the version of my local git repository.</li>
<li>Git pull the latest code.</li>
<li>Git diff from the version I extracted in st... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,888 | git | # How can I generate a git diff of what's changed since the last time I pulled?
I'd like to script, preferably in rake, the following actions into a single command:
1. Get the version of my local git repository.
2. Git pull the latest code.
3. Git diff from the version I extracted in step #1 to what is now in my loca... | You could do this fairly simply with refspecs.
```
git pull origin
git diff @{1}..
```
That will give you a diff of the current branch as it existed before and after the pull. Note that if the pull doesn't actually update the current branch, the diff will give you the wrong results. Another option is to explicitly re... |
2390199 | Finding the date/time a file was first added to a Git repository | 83 | 2010-03-05 21:54:14 | <p>Is there a simple <a href="http://en.wikipedia.org/wiki/Git_%28software%29" rel="noreferrer">Git</a> command to determine the "creation date" of a file in a repository, i.e. the date it was first added?</p>
<p>It would be best if it can determine this even through file renames/moves. I'd like it to be a computer-re... | 40,522 | 118,160 | 2022-04-22 16:45:49 | 2,390,382 | 106 | 2010-03-05 22:29:11 | 285,289 | 2022-04-22 16:45:49 | https://stackoverflow.com/q/2390199 | https://stackoverflow.com/a/2390382 | <p><code>git log --follow --format=%ad --date default <FILE> | tail -1</code></p>
<p>With this command you can out all date about this file and extract the last</p>
<p>The option <code>%ad</code> shows the date in the format specified by the --date setting, one of <code>relative</code>, <code>local</code>, <code>... | <p><code>git log --follow --format=%ad --date default <FILE> | tail -1</code></p> <p>With this command you can out all date about this file and extract the last</p> <p>The option <code>%ad</code> shows the date in the format specified by the --date setting, one of <code>relative</code>, <code>local</code>, <code>... | 119 | git | <h1>Finding the date/time a file was first added to a Git repository</h1>
<p>Is there a simple <a href="http://en.wikipedia.org/wiki/Git_%28software%29" rel="noreferrer">Git</a> command to determine the "creation date" of a file in a repository, i.e. the date it was first added?</p>
<p>It would be best if it can deter... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,889 | git | # Finding the date/time a file was first added to a Git repository
Is there a simple [Git](http://en.wikipedia.org/wiki/Git_%28software%29) command to determine the "creation date" of a file in a repository, i.e. the date it was first added?
It would be best if it can determine this even through file renames/moves. I... | `git log --follow --format=%ad --date default <FILE> | tail -1`
With this command you can out all date about this file and extract the last
The option `%ad` shows the date in the format specified by the --date setting, one of `relative`, `local`, `iso`, `iso-strict`, `rfc`, `short`, `raw`, `human`, `unix`, `format:<s... |
9914216 | How do I separate an integer into separate digits in an array in JavaScript? | 79 | 2012-03-28 19:17:14 | <p>This is my code so far:</p>
<pre><code>var n = 123456789;
var d = n.toString().length;
var digits = [];
var squaredDigits = [];
for (i = d; i >= 1; i--) {
var j = k / 10;
var r = (n % k / j) - 0.5;
var k = Math.pow(10, i);
var result = r.toFixed();
digits.push(result);
}
console.log(digits)... | 238,138 | 1,299,061 | 2023-07-31 13:43:45 | 9,914,249 | 106 | 2012-03-28 19:18:44 | 507,674 | 2012-03-28 19:18:44 | https://stackoverflow.com/q/9914216 | https://stackoverflow.com/a/9914249 | <p>Why not just do this?</p>
<pre><code>var n = 123456789;
var digits = (""+n).split("");
</code></pre>
| <p>Why not just do this?</p> <pre><code>var n = 123456789; var digits = (""+n).split(""); </code></pre> | 3, 114, 9914 | arrays, digits, javascript | <h1>How do I separate an integer into separate digits in an array in JavaScript?</h1>
<p>This is my code so far:</p>
<pre><code>var n = 123456789;
var d = n.toString().length;
var digits = [];
var squaredDigits = [];
for (i = d; i >= 1; i--) {
var j = k / 10;
var r = (n % k / j) - 0.5;
var k = Math.pow(... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,890 | git | # How do I separate an integer into separate digits in an array in JavaScript?
This is my code so far:
```
var n = 123456789;
var d = n.toString().length;
var digits = [];
var squaredDigits = [];
for (i = d; i >= 1; i--) {
var j = k / 10;
var r = (n % k / j) - 0.5;
var k = Math.pow(10, i);
var result ... | Why not just do this?
```
var n = 123456789;
var digits = (""+n).split("");
``` |
9832348 | git push rejected: error: failed to push some refs | 70 | 2012-03-23 00:03:25 | <p>I know people have asked similar questions, but I believe the causes of their problems to be different. I did a hard reset because I had messed up my code pretty bad</p>
<pre><code> git reset --hard 41651df8fc9
</code></pre>
<p>I've made quite some changes, I've made some commits and now that I'm trying to push a... | 284,913 | 697,664 | 2023-03-27 13:35:42 | 9,832,377 | 106 | 2012-03-23 00:06:31 | 14,200 | 2015-07-07 04:22:12 | https://stackoverflow.com/q/9832348 | https://stackoverflow.com/a/9832377 | <p><code>git push -f</code> if you have permission, but that will screw up anyone else who pulls from that repo, so be careful.</p>
<p>If that is denied, and you have access to the server, as canzar says below, you can allow this on the server with</p>
<pre><code>git config receive.denyNonFastForwards false
</code></... | <p><code>git push -f</code> if you have permission, but that will screw up anyone else who pulls from that repo, so be careful.</p> <p>If that is denied, and you have access to the server, as canzar says below, you can allow this on the server with</p> <pre><code>git config receive.denyNonFastForwards false </code></... | 119, 28896, 28898 | git, git-pull, git-push | <h1>git push rejected: error: failed to push some refs</h1>
<p>I know people have asked similar questions, but I believe the causes of their problems to be different. I did a hard reset because I had messed up my code pretty bad</p>
<pre><code> git reset --hard 41651df8fc9
</code></pre>
<p>I've made quite some chang... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,891 | git | # git push rejected: error: failed to push some refs
I know people have asked similar questions, but I believe the causes of their problems to be different. I did a hard reset because I had messed up my code pretty bad
```
git reset --hard 41651df8fc9
```
I've made quite some changes, I've made some commits and now... | `git push -f` if you have permission, but that will screw up anyone else who pulls from that repo, so be careful.
If that is denied, and you have access to the server, as canzar says below, you can allow this on the server with
```
git config receive.denyNonFastForwards false
``` |
22108391 | Git - Checkout a remote tag when two remotes have the same tag name | 62 | 2014-03-01 00:28:31 | <p>I had hoped this would work:</p>
<pre><code>git checkout remote/tag_name
</code></pre>
<p>but it doesn't. This does:</p>
<pre><code>git checkout tags/tag_name
</code></pre>
<p>but I'm doing something weird where I have a lot of remotes, and I'm worried about what happens if two remotes have the same tag. Is ther... | 104,675 | 171,916 | 2018-09-03 12:46:09 | 22,120,725 | 106 | 2014-03-01 21:40:47 | 1,256,452 | 2017-01-22 22:30:27 | https://stackoverflow.com/q/22108391 | https://stackoverflow.com/a/22120725 | <h2>Executive summary: what you want to achieve is possible, but first you must invent remote tags.</h2>
<p>You do this with a series of refspecs, one for each remote. The rest of this is about what these are, how they work, and so on.</p>
<hr>
<p>Your question asks about checking out a "remote tag", but Git does n... | <h2>Executive summary: what you want to achieve is possible, but first you must invent remote tags.</h2> <p>You do this with a series of refspecs, one for each remote. The rest of this is about what these are, how they work, and so on.</p> <hr> <p>Your question asks about checking out a "remote tag", but Git does n... | 119, 41346, 60718 | git, git-remote, git-tag | <h1>Git - Checkout a remote tag when two remotes have the same tag name</h1>
<p>I had hoped this would work:</p>
<pre><code>git checkout remote/tag_name
</code></pre>
<p>but it doesn't. This does:</p>
<pre><code>git checkout tags/tag_name
</code></pre>
<p>but I'm doing something weird where I have a lot of remotes,... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,893 | git | # Git - Checkout a remote tag when two remotes have the same tag name
I had hoped this would work:
```
git checkout remote/tag_name
```
but it doesn't. This does:
```
git checkout tags/tag_name
```
but I'm doing something weird where I have a lot of remotes, and I'm worried about what happens if two remotes have t... | ## Executive summary: what you want to achieve is possible, but first you must invent remote tags.
You do this with a series of refspecs, one for each remote. The rest of this is about what these are, how they work, and so on.
---
Your question asks about checking out a "remote tag", but Git does not *have* remote t... |
14220929 | Git clone with custom SSH using GIT_SSH error | 61 | 2013-01-08 17:41:07 | <p>I am trying to clone a Git repo using a custom SSH command. I set the SSH command in the GIT_SSH environmental variably be running </p>
<p><code>export GIT_SSH="/usr/bin/ssh -o StrictHostKeyChecking=no -i /home/me/my_private_key"</code>. </p>
<p>But when, after the previous command I run </p>
<p><code>git clone g... | 81,501 | 577,598 | 2023-01-07 08:37:59 | 14,221,028 | 106 | 2013-01-08 17:47:17 | 147,356 | 2013-07-23 19:49:05 | https://stackoverflow.com/q/14220929 | https://stackoverflow.com/a/14221028 | <p>You cannot provide options in the <code>GIT_SSH</code> environment variable; from the <code>git</code> man page:</p>
<pre><code> GIT_SSH
If this environment variable is set then git fetch and git push will use this command instead of ssh when they need to connect
to a remote system. The $GIT_SSH com... | <p>You cannot provide options in the <code>GIT_SSH</code> environment variable; from the <code>git</code> man page:</p> <pre><code> GIT_SSH If this environment variable is set then git fetch and git push will use this command instead of ssh when they need to connect to a remote system. The $GIT_SSH com... | 119, 386, 3050, 9013, 34099 | clone, environment-variables, git, git-clone, ssh | <h1>Git clone with custom SSH using GIT_SSH error</h1>
<p>I am trying to clone a Git repo using a custom SSH command. I set the SSH command in the GIT_SSH environmental variably be running </p>
<p><code>export GIT_SSH="/usr/bin/ssh -o StrictHostKeyChecking=no -i /home/me/my_private_key"</code>. </p>
<p>But when, afte... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,894 | git | # Git clone with custom SSH using GIT_SSH error
I am trying to clone a Git repo using a custom SSH command. I set the SSH command in the GIT_SSH environmental variably be running
`export GIT_SSH="/usr/bin/ssh -o StrictHostKeyChecking=no -i /home/me/my_private_key"`.
But when, after the previous command I run
`git c... | You cannot provide options in the `GIT_SSH` environment variable; from the `git` man page:
```
GIT_SSH
If this environment variable is set then git fetch and git push will use this command instead of ssh when they need to connect
to a remote system. The $GIT_SSH command will be given exactly two argum... |
26462667 | Git completion not working in zsh on OS X Yosemite with Homebrew | 59 | 2014-10-20 09:45:14 | <p>I cannot get git completion to work on my freshly installed OS X Yosemite in the zsh shell. I've installed both git and zsh using homebrew:</p>
<pre><code>brew install zsh git
</code></pre>
<p>When installing git via homebrew, it should setup tab-completion for you, but when I <code>git <tab></code>, it just... | 30,090 | 149,868 | 2024-02-19 08:40:00 | 26,479,426 | 106 | 2014-10-21 05:24:52 | 149,868 | 2014-10-21 05:24:52 | https://stackoverflow.com/q/26462667 | https://stackoverflow.com/a/26479426 | <p>I just stumbled upon the answer!</p>
<p>In my case I was missing a few important pieces in my <code>.zshrc</code> file. But first a little background:</p>
<p>What I'm trying to do is setup the "<a href="http://www.csse.uwa.edu.au/programming/linux/zsh-doc/zsh_23.html">zsh Completion System</a>". It comes with a lo... | <p>I just stumbled upon the answer!</p> <p>In my case I was missing a few important pieces in my <code>.zshrc</code> file. But first a little background:</p> <p>What I'm trying to do is setup the "<a href="http://www.csse.uwa.edu.au/programming/linux/zsh-doc/zsh_23.html">zsh Completion System</a>". It comes with a lo... | 119, 1067, 3791 | git, homebrew, zsh | <h1>Git completion not working in zsh on OS X Yosemite with Homebrew</h1>
<p>I cannot get git completion to work on my freshly installed OS X Yosemite in the zsh shell. I've installed both git and zsh using homebrew:</p>
<pre><code>brew install zsh git
</code></pre>
<p>When installing git via homebrew, it should setu... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,896 | git | # Git completion not working in zsh on OS X Yosemite with Homebrew
I cannot get git completion to work on my freshly installed OS X Yosemite in the zsh shell. I've installed both git and zsh using homebrew:
```
brew install zsh git
```
When installing git via homebrew, it should setup tab-completion for you, but whe... | I just stumbled upon the answer!
In my case I was missing a few important pieces in my `.zshrc` file. But first a little background:
What I'm trying to do is setup the "[zsh Completion System](http://www.csse.uwa.edu.au/programming/linux/zsh-doc/zsh_23.html)". It comes with a lot of commands all named something with ... |
2839253 | Git history - find lost line by keyword | 53 | 2010-05-15 07:10:52 | <p>I had somewhere in my Git repository a line containing the word "Foo" a couple of hundreds of commits before.</p>
<p>If there is any way to find its revision number where it was the last time?</p>
| 11,898 | 74,089 | 2021-08-02 16:30:46 | 2,839,319 | 106 | 2010-05-15 07:38:36 | 6,309 | 2014-10-07 07:39:10 | https://stackoverflow.com/q/2839253 | https://stackoverflow.com/a/2839319 | <p>That may be addressed by the <strong>pickaxe</strong> (<code>-S</code>) option of <a href="http://git-scm.com/docs/git-log" rel="noreferrer"><code>gitlog</code></a></p>
<pre><code> git log -SFoo -- path_containing_change
</code></pre>
<p>(you can even add a time range: <code>--since=2009.1.1 --until=2010.1.1</code... | <p>That may be addressed by the <strong>pickaxe</strong> (<code>-S</code>) option of <a href="http://git-scm.com/docs/git-log" rel="noreferrer"><code>gitlog</code></a></p> <pre><code> git log -SFoo -- path_containing_change </code></pre> <p>(you can even add a time range: <code>--since=2009.1.1 --until=2010.1.1</code... | 119, 456 | git, version-control | <h1>Git history - find lost line by keyword</h1>
<p>I had somewhere in my Git repository a line containing the word "Foo" a couple of hundreds of commits before.</p>
<p>If there is any way to find its revision number where it was the last time?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,897 | git | # Git history - find lost line by keyword
I had somewhere in my Git repository a line containing the word "Foo" a couple of hundreds of commits before.
If there is any way to find its revision number where it was the last time? | That may be addressed by the **pickaxe** (`-S`) option of [`gitlog`](http://git-scm.com/docs/git-log)
```
git log -SFoo -- path_containing_change
```
(you can even add a time range: `--since=2009.1.1 --until=2010.1.1`)
```
-S<string>
```
> Look for differences that introduce or remove an instance of `<string>`.
... |
19875104 | How to find out in which commit a particular code was added? | 162 | 2013-11-09 10:54:39 | <p>I want to find out in which commit did I add the code given below: </p>
<pre><code>if (getListView().getChildCount() == 0)
getActivity().findViewById(android.R.id.empty).setVisibility(View.VISIBLE);
</code></pre>
<p>How do I achieve this?</p>
| 74,725 | 1,117,531 | 2020-08-01 16:04:49 | 19,875,124 | 105 | 2013-11-09 10:56:47 | 2,441,252 | 2013-11-09 11:02:56 | https://stackoverflow.com/q/19875104 | https://stackoverflow.com/a/19875124 | <p>Run <code>git blame</code> on the file. It'll show you the commit ID, the date and time, and who committed it- for each line. Then just copy out the commit identifier and you can use it in <code>git log <commit></code> or <code>git show <commit></code>.</p>
<p>For example, I've got a file, called test.t... | <p>Run <code>git blame</code> on the file. It'll show you the commit ID, the date and time, and who committed it- for each line. Then just copy out the commit identifier and you can use it in <code>git log <commit></code> or <code>git show <commit></code>.</p> <p>For example, I've got a file, called test.t... | 119, 53850 | git, git-commit | <h1>How to find out in which commit a particular code was added?</h1>
<p>I want to find out in which commit did I add the code given below: </p>
<pre><code>if (getListView().getChildCount() == 0)
getActivity().findViewById(android.R.id.empty).setVisibility(View.VISIBLE);
</code></pre>
<p>How do I achi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,899 | git | # How to find out in which commit a particular code was added?
I want to find out in which commit did I add the code given below:
```
if (getListView().getChildCount() == 0)
getActivity().findViewById(android.R.id.empty).setVisibility(View.VISIBLE);
```
How do I achieve this? | Run `git blame` on the file. It'll show you the commit ID, the date and time, and who committed it- for each line. Then just copy out the commit identifier and you can use it in `git log <commit>` or `git show <commit>`.
For example, I've got a file, called test.txt, with lines added on different commits:
```
$ cat t... |
6485508 | Git interactive rebase no commits to pick | 137 | 2011-06-26 17:26:27 | <p>I'm on master and I did <code>rebase -i <my_branch></code></p>
<p>Got this:</p>
<pre><code>noop
# Rebase c947bec..7e259d3 onto c947bec
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but me... | 84,245 | 363,282 | 2023-09-01 08:32:44 | 6,485,591 | 105 | 2011-06-26 17:40:00 | 19,563 | 2013-10-19 13:09:32 | https://stackoverflow.com/q/6485508 | https://stackoverflow.com/a/6485591 | <p>Like a non-interactive rebase, you have to rebase onto a particular commit.</p>
<p>With a non-interactive rebase, if you supply a direct ancestor of the current commit then you aren't changing anything; with an interactive rebase you can edit commits after the commit that you are rebasing onto, even if the commit i... | <p>Like a non-interactive rebase, you have to rebase onto a particular commit.</p> <p>With a non-interactive rebase, if you supply a direct ancestor of the current commit then you aren't changing anything; with an interactive rebase you can edit commits after the commit that you are rebasing onto, even if the commit i... | 119, 8974 | git, rebase | <h1>Git interactive rebase no commits to pick</h1>
<p>I'm on master and I did <code>rebase -i <my_branch></code></p>
<p>Got this:</p>
<pre><code>noop
# Rebase c947bec..7e259d3 onto c947bec
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,900 | git | # Git interactive rebase no commits to pick
I'm on master and I did `rebase -i <my_branch>`
Got this:
```
noop
# Rebase c947bec..7e259d3 onto c947bec
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit,... | Like a non-interactive rebase, you have to rebase onto a particular commit.
With a non-interactive rebase, if you supply a direct ancestor of the current commit then you aren't changing anything; with an interactive rebase you can edit commits after the commit that you are rebasing onto, even if the commit is a direct... |
33159394 | Ignore *all* whitespace changes with git-diff between commits | 116 | 2015-10-15 22:13:03 | <p>I'm going through a codebase and fixing whitespace oddities and generally correcting indentation and such things, and I want to make sure I haven't inadvertently made any other changes, so I'm doing <code>git diff -w</code> to display differences in all changed files while ignoring whitespace differences. The probl... | 79,044 | 241,142 | 2023-03-21 10:55:13 | 33,159,593 | 105 | 2015-10-15 22:28:18 | 241,142 | 2020-06-15 17:51:41 | https://stackoverflow.com/q/33159394 | https://stackoverflow.com/a/33159593 | <p>Perhaps there is a better answer, but the best solution I've found so far is this.</p>
<p>First, you must control the definition of "whitespace" that Git is currently using.</p>
<pre class="lang-sh prettyprint-override"><code>git config core.whitespace '-trailing-space,-indent-with-non-tab,-tab-in-indent'
</code><... | <p>Perhaps there is a better answer, but the best solution I've found so far is this.</p> <p>First, you must control the definition of "whitespace" that Git is currently using.</p> <pre class="lang-sh prettyprint-override"><code>git config core.whitespace '-trailing-space,-indent-with-non-tab,-tab-in-indent' </code><... | 119, 606, 9033 | diff, git, git-diff | <h1>Ignore *all* whitespace changes with git-diff between commits</h1>
<p>I'm going through a codebase and fixing whitespace oddities and generally correcting indentation and such things, and I want to make sure I haven't inadvertently made any other changes, so I'm doing <code>git diff -w</code> to display differences... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,901 | git | # Ignore *all* whitespace changes with git-diff between commits
I'm going through a codebase and fixing whitespace oddities and generally correcting indentation and such things, and I want to make sure I haven't inadvertently made any other changes, so I'm doing `git diff -w` to display differences in all changed file... | Perhaps there is a better answer, but the best solution I've found so far is this.
First, you must control the definition of "whitespace" that Git is currently using.
```
git config core.whitespace '-trailing-space,-indent-with-non-tab,-tab-in-indent'
```
Next, you must control the definition of a word used. Instead... |
9725531 | show commits since branch creation | 110 | 2012-03-15 18:03:48 | <p>Is there a way to see with <code>git log</code> or some other command only the commits that were added after branch creation?</p>
<pre><code>usage: git log [<options>] [<since>..<until>] [[--] <path>...]
or: git show [options] <object>...
--quiet suppress diff out... | 41,588 | 170,521 | 2022-03-09 00:28:31 | 24,769,534 | 105 | 2014-07-15 22:57:57 | 1,822,379 | 2021-08-31 20:15:15 | https://stackoverflow.com/q/9725531 | https://stackoverflow.com/a/24769534 | <p>Full documentation is here: <a href="https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html" rel="noreferrer">https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html</a></p>
<p>Suppose you have a repo that looks like this:</p>
<pre><code>base - A - B - C - D (master)
... | <p>Full documentation is here: <a href="https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html" rel="noreferrer">https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html</a></p> <p>Suppose you have a repo that looks like this:</p> <pre><code>base - A - B - C - D (master) ... | 119, 47913 | git, git-log | <h1>show commits since branch creation</h1>
<p>Is there a way to see with <code>git log</code> or some other command only the commits that were added after branch creation?</p>
<pre><code>usage: git log [<options>] [<since>..<until>] [[--] <path>...]
or: git show [options] <object>...
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,902 | git | # show commits since branch creation
Is there a way to see with `git log` or some other command only the commits that were added after branch creation?
```
usage: git log [<options>] [<since>..<until>] [[--] <path>...]
or: git show [options] <object>...
--quiet suppress diff output
--source ... | Full documentation is here: <https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html>
Suppose you have a repo that looks like this:
```
base - A - B - C - D (master)
\
\- X - Y - Z (myBranch)
```
Verify the repo status:
```
> git checkout master
Already o... |
6052005 | How can you git pull only the current branch? | 105 | 2011-05-18 23:03:32 | <p>Is there a config way to set this up without having to specify which branch?</p>
| 117,709 | 177,389 | 2025-01-15 10:13:52 | 6,052,036 | 105 | 2011-05-18 23:07:42 | 719,673 | 2023-03-04 03:05:01 | https://stackoverflow.com/q/6052005 | https://stackoverflow.com/a/6052036 | <p>Git already only pulls the current branch. If you have branch set up as a tracking branch, you do not need to specify the remote branch. <code>git branch --set-upstream-to=reponame/remotebranch localbranch</code> will set up the tracking relationship. You then issue <code>git pull [--rebase]</code> and only that ... | <p>Git already only pulls the current branch. If you have branch set up as a tracking branch, you do not need to specify the remote branch. <code>git branch --set-upstream-to=reponame/remotebranch localbranch</code> will set up the tracking relationship. You then issue <code>git pull [--rebase]</code> and only that ... | 119, 3574, 4860 | config, git, pull | <h1>How can you git pull only the current branch?</h1>
<p>Is there a config way to set this up without having to specify which branch?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,903 | git | # How can you git pull only the current branch?
Is there a config way to set this up without having to specify which branch? | Git already only pulls the current branch. If you have branch set up as a tracking branch, you do not need to specify the remote branch. `git branch --set-upstream-to=reponame/remotebranch localbranch` will set up the tracking relationship. You then issue `git pull [--rebase]` and only that branch will be updated.
Of ... |
17152171 | git cannot apply binary patch *** without full index line | 100 | 2013-06-17 16:16:08 | <p>When I try to apply a patch from a file, I see</p>
<pre>
error: cannot apply binary patch to 'my/resource.png' without full index line
error: my/resource.png: patch does not apply
</pre>
<p>I added <code>my/resource.png</code> in the commit from which I made the patch. How can I enabled full-index support?</p>
| 50,941 | 365,298 | 2019-12-04 14:02:58 | 17,152,242 | 105 | 2013-06-17 16:20:30 | 365,298 | 2015-09-08 22:54:11 | https://stackoverflow.com/q/17152171 | https://stackoverflow.com/a/17152242 | <p>Checkout the branch from which you want to create the patch. Run this command:</p>
<pre><code>git diff-index 79fd4d7 --binary > ~/Desktop/my-patch
</code></pre>
<p>Where <code>79fd4d7</code> is a placeholder for the commit that came right before the range of commits you want to diff. (e.g. I want a patch that c... | <p>Checkout the branch from which you want to create the patch. Run this command:</p> <pre><code>git diff-index 79fd4d7 --binary > ~/Desktop/my-patch </code></pre> <p>Where <code>79fd4d7</code> is a placeholder for the commit that came right before the range of commits you want to diff. (e.g. I want a patch that c... | 119 | git | <h1>git cannot apply binary patch *** without full index line</h1>
<p>When I try to apply a patch from a file, I see</p>
<pre>
error: cannot apply binary patch to 'my/resource.png' without full index line
error: my/resource.png: patch does not apply
</pre>
<p>I added <code>my/resource.png</code> in the commit from wh... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,904 | git | # git cannot apply binary patch *** without full index line
When I try to apply a patch from a file, I see
```
error: cannot apply binary patch to 'my/resource.png' without full index line
error: my/resource.png: patch does not apply
```
I added `my/resource.png` in the commit from which I made the patch. How can I ... | Checkout the branch from which you want to create the patch. Run this command:
```
git diff-index 79fd4d7 --binary > ~/Desktop/my-patch
```
Where `79fd4d7` is a placeholder for the commit that came right before the range of commits you want to diff. (e.g. I want a patch that contains the first three commits below:
`... |
22889837 | Rebase a branch without checking it out | 94 | 2014-04-06 04:00:54 | <p>So I'm working on a project that sometimes has long build times, and the build is clobbered very often. If I have an older branch with some work going on (which has been committed, but is based on an older parent), running <code>git checkout oldbranch</code> changes the working dir to represent all the old code, whi... | 26,936 | 1,198,729 | 2025-11-15 10:38:29 | 56,840,200 | 105 | 2019-07-01 17:49:06 | 767,383 | 2019-07-01 17:49:06 | https://stackoverflow.com/q/22889837 | https://stackoverflow.com/a/56840200 | <p>Going through the same right now I learned <code>git rebase</code> allows you to specify two branches in one go, essentially making it <code>git rebase <remote> <local></code>, eg.</p>
<pre><code>git rebase origin/master dev
</code></pre>
<p>This performs a more efficient rebase where your files don't ... | <p>Going through the same right now I learned <code>git rebase</code> allows you to specify two branches in one go, essentially making it <code>git rebase <remote> <local></code>, eg.</p> <pre><code>git rebase origin/master dev </code></pre> <p>This performs a more efficient rebase where your files don't ... | 119, 8974 | git, rebase | <h1>Rebase a branch without checking it out</h1>
<p>So I'm working on a project that sometimes has long build times, and the build is clobbered very often. If I have an older branch with some work going on (which has been committed, but is based on an older parent), running <code>git checkout oldbranch</code> changes t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,907 | git | # Rebase a branch without checking it out
So I'm working on a project that sometimes has long build times, and the build is clobbered very often. If I have an older branch with some work going on (which has been committed, but is based on an older parent), running `git checkout oldbranch` changes the working dir to re... | Going through the same right now I learned `git rebase` allows you to specify two branches in one go, essentially making it `git rebase <remote> <local>`, eg.
```
git rebase origin/master dev
```
This performs a more efficient rebase where your files don't get all re-written (which is the case if you checkout the bra... |
17131690 | Magit revert single file | 91 | 2013-06-16 09:04:22 | <p><em>The question is about Magit major mode for Emacs function and less so about how to do this via command line interface.</em></p>
<p>I only have a local Git repository. How would I restore a selected file to its previous version? I believe that the Git command for this must be something like <code>git checkout HE... | 27,449 | null | 2024-03-21 07:34:25 | 17,133,980 | 105 | 2013-06-16 13:47:12 | 14,090 | 2024-03-21 07:34:25 | https://stackoverflow.com/q/17131690 | https://stackoverflow.com/a/17133980 | <p>To discard a modification in magit you just have to go on the hunk or file you want to revert, and use <code>M-x magit-discard</code> which is bound to <code>k</code> with the default keybindings. See the relevant documentation at <a href="https://magit.vc/manual/magit/Applying.html" rel="nofollow noreferrer">https:... | <p>To discard a modification in magit you just have to go on the hunk or file you want to revert, and use <code>M-x magit-discard</code> which is bound to <code>k</code> with the default keybindings. See the relevant documentation at <a href="https://magit.vc/manual/magit/Applying.html" rel="nofollow noreferrer">https:... | 119, 371, 41829 | emacs, git, magit | <h1>Magit revert single file</h1>
<p><em>The question is about Magit major mode for Emacs function and less so about how to do this via command line interface.</em></p>
<p>I only have a local Git repository. How would I restore a selected file to its previous version? I believe that the Git command for this must be so... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,908 | git | # Magit revert single file
*The question is about Magit major mode for Emacs function and less so about how to do this via command line interface.*
I only have a local Git repository. How would I restore a selected file to its previous version? I believe that the Git command for this must be something like `git check... | To discard a modification in magit you just have to go on the hunk or file you want to revert, and use `M-x magit-discard` which is bound to `k` with the default keybindings. See the relevant documentation at <https://magit.vc/manual/magit/Applying.html> for more detail. |
21616463 | .gitignore file in Sourcetree not working | 86 | 2014-02-06 23:41:45 | <p>I am working on a maven project and I want to ignore the files generated and stored in the /target folder of my project (Evaluation) root folder.In the root of my git repository I have a .gitignore file with the following entries (backend is just a folder which contains the eclipse project Evaluation)</p>
<pre><cod... | 120,851 | 1,995,316 | 2019-07-29 19:48:19 | 21,629,646 | 105 | 2014-02-07 13:57:26 | 147,356 | 2014-06-17 14:46:01 | https://stackoverflow.com/q/21616463 | https://stackoverflow.com/a/21629646 | <p>Let's say we have a file that was inadvertently added to our repository:</p>
<pre><code>stackoverflow$ echo this file is important > junkfile
stackoverflow$ git add junkfile
stackoverflow$ git ci -m 'added a file'
</code></pre>
<p>At some point, we realize that the file is unimportant so we add it to our <code>... | <p>Let's say we have a file that was inadvertently added to our repository:</p> <pre><code>stackoverflow$ echo this file is important > junkfile stackoverflow$ git add junkfile stackoverflow$ git ci -m 'added a file' </code></pre> <p>At some point, we realize that the file is unimportant so we add it to our <code>... | 119, 90056, 115976 | atlassian-sourcetree, git, sourcetree | <h1>.gitignore file in Sourcetree not working</h1>
<p>I am working on a maven project and I want to ignore the files generated and stored in the /target folder of my project (Evaluation) root folder.In the root of my git repository I have a .gitignore file with the following entries (backend is just a folder which cont... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,909 | git | # .gitignore file in Sourcetree not working
I am working on a maven project and I want to ignore the files generated and stored in the /target folder of my project (Evaluation) root folder.In the root of my git repository I have a .gitignore file with the following entries (backend is just a folder which contains the ... | Let's say we have a file that was inadvertently added to our repository:
```
stackoverflow$ echo this file is important > junkfile
stackoverflow$ git add junkfile
stackoverflow$ git ci -m 'added a file'
```
At some point, we realize that the file is unimportant so we add it to our `.gitignore` file:
```
stackoverflo... |
12752288 | Git merge doesn't use default merge message, opens editor with default message | 86 | 2012-10-05 18:48:02 | <p>How can I force <code>git merge</code> to use the default merge message instead of loading my editor with said message?</p>
<p>I have no editor listed in <code>git config -l</code>, so I'm not sure why it opens an editor.</p>
| 21,356 | 471,947 | 2021-07-28 18:40:28 | 12,752,379 | 105 | 2012-10-05 18:54:17 | 471,947 | 2016-08-03 22:08:46 | https://stackoverflow.com/q/12752288 | https://stackoverflow.com/a/12752379 | <p>Found the answer after some digging</p>
<p>EDIT: As per Mark's suggestion, this is the best way to do so: </p>
<pre><code>git config --global core.mergeoptions --no-edit
</code></pre>
| <p>Found the answer after some digging</p> <p>EDIT: As per Mark's suggestion, this is the best way to do so: </p> <pre><code>git config --global core.mergeoptions --no-edit </code></pre> | 119, 28897 | git, git-merge | <h1>Git merge doesn't use default merge message, opens editor with default message</h1>
<p>How can I force <code>git merge</code> to use the default merge message instead of loading my editor with said message?</p>
<p>I have no editor listed in <code>git config -l</code>, so I'm not sure why it opens an editor.</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,910 | git | # Git merge doesn't use default merge message, opens editor with default message
How can I force `git merge` to use the default merge message instead of loading my editor with said message?
I have no editor listed in `git config -l`, so I'm not sure why it opens an editor. | Found the answer after some digging
EDIT: As per Mark's suggestion, this is the best way to do so:
```
git config --global core.mergeoptions --no-edit
``` |
8544211 | 'git diff' doesn't give any output | 82 | 2011-12-17 10:52:31 | <p>If I run <code>git diff</code> I would expect to see a list of changes of my working directory relative to whatever had been committed before (or a list of the working directory contents if it's a new repository with no commits). Try this example:</p>
<pre><code>$ mkdir temp
$ cd temp
$ git init
$ echo "first line"... | 76,077 | 268,075 | 2025-03-11 12:04:44 | 8,547,159 | 105 | 2011-12-17 18:56:45 | 305,264 | 2020-06-12 22:20:37 | https://stackoverflow.com/q/8544211 | https://stackoverflow.com/a/8547159 | <h2>Why do you get no <code>git diff</code> output before adding?</h2>
<p>Git does not treat files in the filesystem as automatically included in the version control system. You have to add things explicitly into the Git repository (as you are doing by adding the current directory with <code>git add .</code>).</p>
<p... | <h2>Why do you get no <code>git diff</code> output before adding?</h2> <p>Git does not treat files in the filesystem as automatically included in the version control system. You have to add things explicitly into the Git repository (as you are doing by adding the current directory with <code>git add .</code>).</p> <p... | 119 | git | <h1>'git diff' doesn't give any output</h1>
<p>If I run <code>git diff</code> I would expect to see a list of changes of my working directory relative to whatever had been committed before (or a list of the working directory contents if it's a new repository with no commits). Try this example:</p>
<pre><code>$ mkdir t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,911 | git | # 'git diff' doesn't give any output
If I run `git diff` I would expect to see a list of changes of my working directory relative to whatever had been committed before (or a list of the working directory contents if it's a new repository with no commits). Try this example:
```
$ mkdir temp
$ cd temp
$ git init
$ echo... | ## Why do you get no `git diff` output before adding?
Git does not treat files in the filesystem as automatically included in the version control system. You have to add things explicitly into the Git repository (as you are doing by adding the current directory with `git add .`).
There is no output to `git diff` beca... |
11722830 | git gui not working after installing in Mac (e.g. Mountain Lion) | 74 | 2012-07-30 13:44:19 | <p>When I ran <code>git gui</code>, I got this:</p>
<pre><code>$ git gui
git: 'gui' is not a git command. See 'git --help'.
Did you mean one of these?
grep
init
pull
push
</code></pre>
<p>But I ran other git commands fine, including <code>gitk</code>. How can I fix this?</p>
<p>Thanks.</p>
| 51,572 | 492,767 | 2021-05-13 07:06:09 | 12,608,076 | 105 | 2012-09-26 18:25:57 | 217,965 | 2020-12-25 17:01:43 | https://stackoverflow.com/q/11722830 | https://stackoverflow.com/a/12608076 | <p>Edit your git config to an add an entry for gui in the alias section</p>
<pre><code>nano ~/.gitconfig
</code></pre>
<blockquote>
<p>[alias]</p>
<p>gui = !sh -c '/usr/local/git/libexec/git-core/git-gui'</p>
</blockquote>
<h2>Edit 2020</h2>
<p>It looks like the path in the original answer is now obsolete. Updated inst... | <p>Edit your git config to an add an entry for gui in the alias section</p> <pre><code>nano ~/.gitconfig </code></pre> <blockquote> <p>[alias]</p> <p>gui = !sh -c '/usr/local/git/libexec/git-core/git-gui'</p> </blockquote> <h2>Edit 2020</h2> <p>It looks like the path in the original answer is now obsolete. Updated inst... | 119 | git | <h1>git gui not working after installing in Mac (e.g. Mountain Lion)</h1>
<p>When I ran <code>git gui</code>, I got this:</p>
<pre><code>$ git gui
git: 'gui' is not a git command. See 'git --help'.
Did you mean one of these?
grep
init
pull
push
</code></pre>
<p>But I ran other git commands fine, incl... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,914 | git | # git gui not working after installing in Mac (e.g. Mountain Lion)
When I ran `git gui`, I got this:
```
$ git gui
git: 'gui' is not a git command. See 'git --help'.
Did you mean one of these?
grep
init
pull
push
```
But I ran other git commands fine, including `gitk`. How can I fix this?
Thanks. | Edit your git config to an add an entry for gui in the alias section
```
nano ~/.gitconfig
```
> [alias]
>
> gui = !sh -c '/usr/local/git/libexec/git-core/git-gui'
## Edit 2020
It looks like the path in the original answer is now obsolete. Updated instructions:
> [alias]
>
> gui = !sh -c '/usr/local/opt/git/bin/gi... |
5032374 | Accidentally pushed commit: change git commit message | 70 | 2011-02-17 17:29:52 | <p>In my local repo I have one commit with an incorrect commit message.</p>
<p>I've already published the incorrect commit message with <code>git push</code>.</p>
<p>Now the remote repo (which is GitHub-hosted) has the incorrect commit message, too.</p>
<p>I've already tried <code>git commit --amend</code>, but foun... | 57,744 | 72,530 | 2016-08-11 13:25:42 | 5,032,614 | 105 | 2011-02-17 17:50:47 | 95,706 | 2014-04-07 11:31:29 | https://stackoverflow.com/q/5032374 | https://stackoverflow.com/a/5032614 | <p>Easiest solution (<strong>but please read this whole answer before doing this</strong>):</p>
<ol>
<li><code>git rebase -i <hash-of-commit-preceding-the-incorrect-one></code></li>
<li>In the editor that opens, change <code>pick</code> to <code>reword</code> on the line for the incorrect commit.</li>
<li>Save t... | <p>Easiest solution (<strong>but please read this whole answer before doing this</strong>):</p> <ol> <li><code>git rebase -i <hash-of-commit-preceding-the-incorrect-one></code></li> <li>In the editor that opens, change <code>pick</code> to <code>reword</code> on the line for the incorrect commit.</li> <li>Save t... | 119, 30968, 53850 | git, git-amend, git-commit | <h1>Accidentally pushed commit: change git commit message</h1>
<p>In my local repo I have one commit with an incorrect commit message.</p>
<p>I've already published the incorrect commit message with <code>git push</code>.</p>
<p>Now the remote repo (which is GitHub-hosted) has the incorrect commit message, too.</p>
... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,915 | git | # Accidentally pushed commit: change git commit message
In my local repo I have one commit with an incorrect commit message.
I've already published the incorrect commit message with `git push`.
Now the remote repo (which is GitHub-hosted) has the incorrect commit message, too.
I've already tried `git commit --amend... | Easiest solution (**but please read this whole answer before doing this**):
1. `git rebase -i <hash-of-commit-preceding-the-incorrect-one>`
2. In the editor that opens, change `pick` to `reword` on the line for the incorrect commit.
3. Save the file and close the editor.
4. The editor will open again with the incorrec... |
23892037 | Push all local branches to origin in git | 48 | 2014-05-27 14:24:07 | <p>Let's say that I have A LOT of local branches in my git not pushed on the remote repository. </p>
<p>How can I push all of them to origin with a single command?</p>
| 30,198 | 208,623 | 2018-08-28 09:11:32 | 23,892,232 | 105 | 2014-05-27 14:33:27 | 829,676 | 2014-05-27 14:33:27 | https://stackoverflow.com/q/23892037 | https://stackoverflow.com/a/23892232 | <p>Have you tried </p>
<pre><code>git push --all -u
</code></pre>
<p>The git man states </p>
<blockquote>
<p>--all </p>
<p>Instead of naming each ref to push, specifies that all refs under refs/heads/ be pushed.</p>
<p>-u, --set-upstream </p>
<p>For every branch that is up to date or successfully p... | <p>Have you tried </p> <pre><code>git push --all -u </code></pre> <p>The git man states </p> <blockquote> <p>--all </p> <p>Instead of naming each ref to push, specifies that all refs under refs/heads/ be pushed.</p> <p>-u, --set-upstream </p> <p>For every branch that is up to date or successfully p... | 119 | git | <h1>Push all local branches to origin in git</h1>
<p>Let's say that I have A LOT of local branches in my git not pushed on the remote repository. </p>
<p>How can I push all of them to origin with a single command?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,917 | git | # Push all local branches to origin in git
Let's say that I have A LOT of local branches in my git not pushed on the remote repository.
How can I push all of them to origin with a single command? | Have you tried
```
git push --all -u
```
The git man states
> --all
>
> Instead of naming each ref to push, specifies that all refs under refs/heads/ be pushed.
>
> -u, --set-upstream
>
> For every branch that is up to date or successfully pushed, add upstream (tracking) reference,
the `-u` is useful if you intent ... |
21025314 | Who is "us" and who is "them" according to Git? | 272 | 2014-01-09 16:09:14 | <p>After a Git rebase, and in other circumstances, you can find some files marked as <em>deleted by us</em> in the <code>git status</code> report. Who is <em>us</em> according to Git and why?</p>
<p>Is it referring to me sitting on this branch and it working for me? Or is it referring to itself and the folks working o... | 42,530 | 393,758 | 2023-08-03 14:12:58 | 63,911,630 | 104 | 2020-09-16 00:46:55 | 4,561,887 | 2023-08-03 14:12:58 | https://stackoverflow.com/q/21025314 | https://stackoverflow.com/a/63911630 | <h2>Who is "us"/"ours" and "them"/"theirs" according to Git?</h2>
<p>(This also answers the question: "How does a git rebase work and what exactly is happening with it?")</p>
<p>When you have conflicts in the middle of a git <code>merge</code>, <code>cherry-pick</code>... | <h2>Who is "us"/"ours" and "them"/"theirs" according to Git?</h2> <p>(This also answers the question: "How does a git rebase work and what exactly is happening with it?")</p> <p>When you have conflicts in the middle of a git <code>merge</code>, <code>cherry-pick</code>... | 119 | git | <h1>Who is "us" and who is "them" according to Git?</h1>
<p>After a Git rebase, and in other circumstances, you can find some files marked as <em>deleted by us</em> in the <code>git status</code> report. Who is <em>us</em> according to Git and why?</p>
<p>Is it referring to me sitting on this branch and it working for... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,918 | git | # Who is "us" and who is "them" according to Git?
After a Git rebase, and in other circumstances, you can find some files marked as *deleted by us* in the `git status` report. Who is *us* according to Git and why?
Is it referring to me sitting on this branch and it working for me? Or is it referring to itself and the... | ## Who is "us"/"ours" and "them"/"theirs" according to Git?
(This also answers the question: "How does a git rebase work and what exactly is happening with it?")
When you have conflicts in the middle of a git `merge`, `cherry-pick`, `rebase`, or `revert`, you may need to pick a side to choose to keep *conflicting* co... |
13208734 | Get the time and date of git tags | 167 | 2012-11-03 11:30:02 | <p>I have a project that is using git and have tagged all the releases with a tag.</p>
<pre><code>$ git tag
v1.0.0
v1.0.1
v1.0.2
v1.0.3
v1.1.0
</code></pre>
<p>My goal is to list the releases and release dates in a web interface (tag/commit date = release date). Currently we list all the releases by using <code>git t... | 100,804 | 298,195 | 2025-03-13 08:03:48 | 13,208,830 | 104 | 2012-11-03 11:43:40 | 1,600,898 | 2015-10-20 15:04:03 | https://stackoverflow.com/q/13208734 | https://stackoverflow.com/a/13208830 | <p>Use the <code>--format</code> argument to <code>git log</code>:</p>
<pre><code>git log -1 --format=%ai MY_TAG_NAME
</code></pre>
| <p>Use the <code>--format</code> argument to <code>git log</code>:</p> <pre><code>git log -1 --format=%ai MY_TAG_NAME </code></pre> | 119, 603, 5002, 60718 | date, git, git-tag, time | <h1>Get the time and date of git tags</h1>
<p>I have a project that is using git and have tagged all the releases with a tag.</p>
<pre><code>$ git tag
v1.0.0
v1.0.1
v1.0.2
v1.0.3
v1.1.0
</code></pre>
<p>My goal is to list the releases and release dates in a web interface (tag/commit date = release date). Currently we... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,919 | git | # Get the time and date of git tags
I have a project that is using git and have tagged all the releases with a tag.
```
$ git tag
v1.0.0
v1.0.1
v1.0.2
v1.0.3
v1.1.0
```
My goal is to list the releases and release dates in a web interface (tag/commit date = release date). Currently we list all the releases by using `... | Use the `--format` argument to `git log`:
```
git log -1 --format=%ai MY_TAG_NAME
``` |
4076239 | Finding out the name of the original repository you cloned from in Git | 157 | 2010-11-02 09:12:56 | <p>When you do your first clone using the syntax</p>
<pre><code>git clone username@server:gitRepo.git
</code></pre>
<p>Is it possible using your local repository to find the name of that initial clone?</p>
<p>(So in the above example, find <code>gitRepo.git</code>.)</p>
| 189,899 | 197,302 | 2022-08-11 16:54:04 | 4,076,322 | 104 | 2010-11-02 09:25:31 | 319,719 | 2019-10-09 12:43:35 | https://stackoverflow.com/q/4076239 | https://stackoverflow.com/a/4076322 | <p>In the repository root, the <code>.git/config</code> file holds all information about remote repositories and branches. In your example, you should look for something like:</p>
<pre><code>[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = server:gitRepo.git
</code></pre>
<p>Also, the Git c... | <p>In the repository root, the <code>.git/config</code> file holds all information about remote repositories and branches. In your example, you should look for something like:</p> <pre><code>[remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = server:gitRepo.git </code></pre> <p>Also, the Git c... | 119, 456, 9084 | configuration-files, git, version-control | <h1>Finding out the name of the original repository you cloned from in Git</h1>
<p>When you do your first clone using the syntax</p>
<pre><code>git clone username@server:gitRepo.git
</code></pre>
<p>Is it possible using your local repository to find the name of that initial clone?</p>
<p>(So in the above example, fi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,920 | git | # Finding out the name of the original repository you cloned from in Git
When you do your first clone using the syntax
```
git clone username@server:gitRepo.git
```
Is it possible using your local repository to find the name of that initial clone?
(So in the above example, find `gitRepo.git`.) | In the repository root, the `.git/config` file holds all information about remote repositories and branches. In your example, you should look for something like:
```
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = server:gitRepo.git
```
Also, the Git command `git remote -v` shows the remot... |
15143042 | can't push to branch after rebase | 151 | 2013-02-28 18:34:41 | <p>We use git and have a master branch and developer branches. I need to add a new feature and then rebase the commits to master, then push master to CI server.</p>
<p>The problem is that if I have conflicts during rebase I cannot push to my remote developer branch (on Github) after the rebase is complete, until I pul... | 124,417 | 321,975 | 2023-03-23 21:10:18 | 15,144,275 | 104 | 2013-02-28 19:44:13 | 591,166 | 2013-02-28 20:00:37 | https://stackoverflow.com/q/15143042 | https://stackoverflow.com/a/15144275 | <p>First, you and those you're working with need to agree whether a topic/devel branch is for shared development or just your own. Other developers know not to merge on my development branches because they'll be rebased at any time. Usually the workflow is as follows:</p>
<pre><code>o-----o-----o-----o-----o-----o ... | <p>First, you and those you're working with need to agree whether a topic/devel branch is for shared development or just your own. Other developers know not to merge on my development branches because they'll be rebased at any time. Usually the workflow is as follows:</p> <pre><code>o-----o-----o-----o-----o-----o ... | 119, 717, 8974, 28897, 29934 | git, git-merge, git-rebase, merge, rebase | <h1>can't push to branch after rebase</h1>
<p>We use git and have a master branch and developer branches. I need to add a new feature and then rebase the commits to master, then push master to CI server.</p>
<p>The problem is that if I have conflicts during rebase I cannot push to my remote developer branch (on Github... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,921 | git | # can't push to branch after rebase
We use git and have a master branch and developer branches. I need to add a new feature and then rebase the commits to master, then push master to CI server.
The problem is that if I have conflicts during rebase I cannot push to my remote developer branch (on Github) after the reba... | First, you and those you're working with need to agree whether a topic/devel branch is for shared development or just your own. Other developers know not to merge on my development branches because they'll be rebased at any time. Usually the workflow is as follows:
```
o-----o-----o-----o-----o-----o master
\
... |
3044684 | How do you revert a git file to its staging area version? | 99 | 2010-06-15 11:28:47 | <p>Let's say I have a file named <code>a.txt</code>. I add it to the staging area, and then I modify it. How could I return it to the way it was when I added it?</p>
| 33,939 | 31,610 | 2024-04-10 14:30:23 | 3,044,694 | 104 | 2010-06-15 11:30:48 | 573 | 2020-08-31 11:02:30 | https://stackoverflow.com/q/3044684 | https://stackoverflow.com/a/3044694 | <ul>
<li>Prior to Git 2.23: <code>git checkout a.txt</code></li>
<li>Starting from Git 2.23: <code>git restore a.txt</code></li>
</ul>
<p>Git tells you this if you type <code>git status</code>.</p>
<p>Prior to Git 2.23:</p>
<pre><code># On branch master
# Changes to be committed:
# (use "git reset HEAD <file&... | <ul> <li>Prior to Git 2.23: <code>git checkout a.txt</code></li> <li>Starting from Git 2.23: <code>git restore a.txt</code></li> </ul> <p>Git tells you this if you type <code>git status</code>.</p> <p>Prior to Git 2.23:</p> <pre><code># On branch master # Changes to be committed: # (use "git reset HEAD <file&... | 119 | git | <h1>How do you revert a git file to its staging area version?</h1>
<p>Let's say I have a file named <code>a.txt</code>. I add it to the staging area, and then I modify it. How could I return it to the way it was when I added it?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,923 | git | # How do you revert a git file to its staging area version?
Let's say I have a file named `a.txt`. I add it to the staging area, and then I modify it. How could I return it to the way it was when I added it? | - Prior to Git 2.23: `git checkout a.txt`
- Starting from Git 2.23: `git restore a.txt`
Git tells you this if you type `git status`.
Prior to Git 2.23:
```
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: a
#
# Changed but not updated:
# (use "git add <f... |
5235010 | How do I prevent an automerge using Git? | 93 | 2011-03-08 16:04:57 | <p>I am trying to merge a local branch into the master branch without having Git to do an automerge. I would like to “hand pick” what I would like to be merged into master.</p>
<p>When I use Git’s difftool command, I am able to diff and select what I want to be added into the master branch. But then when I do a merge,... | 110,422 | 648,789 | 2019-12-16 22:19:44 | 20,256,067 | 104 | 2013-11-28 01:13:31 | 175,169 | 2018-06-19 03:06:28 | https://stackoverflow.com/q/5235010 | https://stackoverflow.com/a/20256067 | <p>You are trying to bypass Git from getting involved in the merge process and to hand-pick each line of each modified file to be merged. This not the same as <code>git cherry-pick</code>. Neither will <code>git merge --no-commit</code>, etc. help. You will need to do:</p>
<pre><code>$ git checkout master
$ git diffto... | <p>You are trying to bypass Git from getting involved in the merge process and to hand-pick each line of each modified file to be merged. This not the same as <code>git cherry-pick</code>. Neither will <code>git merge --no-commit</code>, etc. help. You will need to do:</p> <pre><code>$ git checkout master $ git diffto... | 119 | git | <h1>How do I prevent an automerge using Git?</h1>
<p>I am trying to merge a local branch into the master branch without having Git to do an automerge. I would like to “hand pick” what I would like to be merged into master.</p>
<p>When I use Git’s difftool command, I am able to diff and select what I want to be added i... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,924 | git | # How do I prevent an automerge using Git?
I am trying to merge a local branch into the master branch without having Git to do an automerge. I would like to “hand pick” what I would like to be merged into master.
When I use Git’s difftool command, I am able to diff and select what I want to be added into the master b... | You are trying to bypass Git from getting involved in the merge process and to hand-pick each line of each modified file to be merged. This not the same as `git cherry-pick`. Neither will `git merge --no-commit`, etc. help. You will need to do:
```
$ git checkout master
$ git difftool -t kdiff3 local-branch HEAD
```
... |
15160978 | Is there a way to use wildcards with git checkout? | 89 | 2013-03-01 15:16:31 | <p>What I would like to do is to checkout a single file or a set of files with a common name part like this</p>
<p><code>git checkout myBranch */myFile.md</code> and</p>
<p><code>git checkout myBranch -- */*Test*</code> (not sure about the '--' part)</p>
<p>instead of </p>
<p><code>git checkout myBranch src/main/j... | 40,457 | 216,021 | 2022-02-28 22:51:07 | 33,306,066 | 104 | 2015-10-23 15:24:47 | 124,319 | 2017-08-07 07:16:54 | https://stackoverflow.com/q/15160978 | https://stackoverflow.com/a/33306066 | <p>Git <strong>does</strong> deal with wildcards, using <a href="http://man7.org/linux/man-pages/man3/fnmatch.3.html" rel="noreferrer">fnmatch(3)</a>. See the <em>pathspec</em> entry in <a href="http://git-scm.com/docs/gitglossary.html#def_pathspec" rel="noreferrer">Git glossary</a>.</p>
<p>But to be sure that git can... | <p>Git <strong>does</strong> deal with wildcards, using <a href="http://man7.org/linux/man-pages/man3/fnmatch.3.html" rel="noreferrer">fnmatch(3)</a>. See the <em>pathspec</em> entry in <a href="http://git-scm.com/docs/gitglossary.html#def_pathspec" rel="noreferrer">Git glossary</a>.</p> <p>But to be sure that git can... | 119, 5997, 37230 | git, git-checkout, wildcard | <h1>Is there a way to use wildcards with git checkout?</h1>
<p>What I would like to do is to checkout a single file or a set of files with a common name part like this</p>
<p><code>git checkout myBranch */myFile.md</code> and</p>
<p><code>git checkout myBranch -- */*Test*</code> (not sure about the '--' part)</p>
<p... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,925 | git | # Is there a way to use wildcards with git checkout?
What I would like to do is to checkout a single file or a set of files with a common name part like this
`git checkout myBranch */myFile.md` and
`git checkout myBranch -- */*Test*` (not sure about the '--' part)
instead of
`git checkout myBranch src/main/java/a/... | Git **does** deal with wildcards, using [fnmatch(3)](http://man7.org/linux/man-pages/man3/fnmatch.3.html). See the *pathspec* entry in [Git glossary](http://git-scm.com/docs/gitglossary.html#def_pathspec).
But to be sure that git can see the wildcards, they must be escaped otherwise your *shell* will expand them first... |
60184159 | Yarn v2 gitignore | 77 | 2020-02-12 08:35:52 | <p>I upgraded yarn from v1.22.0 to v2.0.0-rc.29. It generated <em>.yarn</em> folder with:</p>
<ul>
<li>folders: <em>cache</em>, <em>releases</em>, <em>unplugged</em></li>
<li>files: <em>build-state.yml</em></li>
</ul>
<p>Should I add whole .yarn folder to <em>.gitignore</em>? Or maybe some nested folders in there like ... | 55,896 | 10,059,226 | 2023-09-14 06:53:13 | 60,184,331 | 104 | 2020-02-12 08:46:27 | 14,637 | 2023-09-14 06:53:13 | https://stackoverflow.com/q/60184159 | https://stackoverflow.com/a/60184331 | <p>See the <a href="https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored" rel="noreferrer">Questions & Answers section of the documentation</a>. <strong>It has changed several times, so for the most up to date answer just click that link!</strong></p>
<p>But in the StackOverflow spirit of "n... | <p>See the <a href="https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored" rel="noreferrer">Questions & Answers section of the documentation</a>. <strong>It has changed several times, so for the most up to date answer just click that link!</strong></p> <p>But in the StackOverflow spirit of "n... | 119, 25056, 122493, 144792 | git, gitignore, yarnpkg, yarnpkg-v2 | <h1>Yarn v2 gitignore</h1>
<p>I upgraded yarn from v1.22.0 to v2.0.0-rc.29. It generated <em>.yarn</em> folder with:</p>
<ul>
<li>folders: <em>cache</em>, <em>releases</em>, <em>unplugged</em></li>
<li>files: <em>build-state.yml</em></li>
</ul>
<p>Should I add whole .yarn folder to <em>.gitignore</em>? Or maybe some ne... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,927 | git | # Yarn v2 gitignore
I upgraded yarn from v1.22.0 to v2.0.0-rc.29. It generated *.yarn* folder with:
- folders: *cache*, *releases*, *unplugged*
- files: *build-state.yml*
Should I add whole .yarn folder to *.gitignore*? Or maybe some nested folders in there like *.yarn/cache*?
Also, what to do with *.pnp.js*. Do I ... | See the [Questions & Answers section of the documentation](https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored). **It has changed several times, so for the most up to date answer just click that link!**
But in the StackOverflow spirit of "no link-only answers" here's a snapshot:
> ## Which files s... |
18500016 | Undo a git rerere resolution that was done in a rebase | 73 | 2013-08-28 23:36:59 | <p>Okay, so I really like the <code>git rerere</code> command, although I haven't really used it that much other than letting it auto-magically record my conflicts and resolve them for me. However, I did mess up one of my conflict resolutions during quite a large rebase (rebasing a really stale feature branch with the... | 32,759 | 995,617 | 2022-09-30 03:08:00 | 21,635,422 | 104 | 2014-02-07 18:43:50 | 994,153 | 2018-08-02 06:04:02 | https://stackoverflow.com/q/18500016 | https://stackoverflow.com/a/21635422 | <p>To simply remove all previous <code>rerere</code> resolutions, run <code>rm -rf .git/rr-cache</code> to remove the cache.</p>
<p>For a specific merge, you can tell <code>rerere</code> to forget the recorded resolution by re-executing the merge and allowing <code>rerere</code> to apply its recorded resolution in the... | <p>To simply remove all previous <code>rerere</code> resolutions, run <code>rm -rf .git/rr-cache</code> to remove the cache.</p> <p>For a specific merge, you can tell <code>rerere</code> to forget the recorded resolution by re-executing the merge and allowing <code>rerere</code> to apply its recorded resolution in the... | 119, 29934, 83367 | git, git-rebase, git-rerere | <h1>Undo a git rerere resolution that was done in a rebase</h1>
<p>Okay, so I really like the <code>git rerere</code> command, although I haven't really used it that much other than letting it auto-magically record my conflicts and resolve them for me. However, I did mess up one of my conflict resolutions during quite... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,928 | git | # Undo a git rerere resolution that was done in a rebase
Okay, so I really like the `git rerere` command, although I haven't really used it that much other than letting it auto-magically record my conflicts and resolve them for me. However, I did mess up one of my conflict resolutions during quite a large rebase (reba... | To simply remove all previous `rerere` resolutions, run `rm -rf .git/rr-cache` to remove the cache.
For a specific merge, you can tell `rerere` to forget the recorded resolution by re-executing the merge and allowing `rerere` to apply its recorded resolution in the work tree.
You can check out `a'` and then do a `git... |
52538920 | Terraform modules using a git branch as a source | 62 | 2018-09-27 14:05:00 | <p>Using Terraform modules with a git branch as a source,<br>
I am referring to:</p>
<pre><code>git::ssh://private_server:myport/kbf/my_repository.git//ecs-cluster?ref=v0.0.1
</code></pre>
<p>In my module source parameter, this works great and provides me with my module at tag <code>v0.0.1</code> on master.</p>
<p>H... | 165,612 | 134,848 | 2024-08-09 16:18:00 | 55,100,821 | 104 | 2019-03-11 11:26:14 | 4,970,598 | 2020-05-19 12:51:49 | https://stackoverflow.com/q/52538920 | https://stackoverflow.com/a/55100821 | <p>As mentioned in the Terraform documentation <a href="https://www.terraform.io/docs/modules/sources.html#selecting-a-revision" rel="noreferrer">here</a>:</p>
<pre><code>git::ssh://private_server:myport/kbf/my_repository.git//ecs-cluster?ref=myBranch
</code></pre>
| <p>As mentioned in the Terraform documentation <a href="https://www.terraform.io/docs/modules/sources.html#selecting-a-revision" rel="noreferrer">here</a>:</p> <pre><code>git::ssh://private_server:myport/kbf/my_repository.git//ecs-cluster?ref=myBranch </code></pre> | 119, 110634 | git, terraform | <h1>Terraform modules using a git branch as a source</h1>
<p>Using Terraform modules with a git branch as a source,<br>
I am referring to:</p>
<pre><code>git::ssh://private_server:myport/kbf/my_repository.git//ecs-cluster?ref=v0.0.1
</code></pre>
<p>In my module source parameter, this works great and provides me with... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,930 | git | # Terraform modules using a git branch as a source
Using Terraform modules with a git branch as a source,
I am referring to:
```
git::ssh://private_server:myport/kbf/my_repository.git//ecs-cluster?ref=v0.0.1
```
In my module source parameter, this works great and provides me with my module at tag `v0.0.1` on maste... | As mentioned in the Terraform documentation [here](https://www.terraform.io/docs/modules/sources.html#selecting-a-revision):
```
git::ssh://private_server:myport/kbf/my_repository.git//ecs-cluster?ref=myBranch
``` |
3998883 | git how to find commit hash where branch originated from | 113 | 2010-10-22 16:26:41 | <p>Pretend I branched from my master branch to a topic branch, and then I did a few commits on my topic branch. Is there a command that tells me the commit hash on the master branch that my topic branch originated from?</p>
<p>Ideally, I wouldn't have to know how many commits I've made ( trying to avoid HEAD^5 ).</p>
... | 53,051 | 366,464 | 2025-03-10 18:10:28 | 3,999,084 | 103 | 2010-10-22 16:50:40 | 112,968 | 2025-03-10 18:10:28 | https://stackoverflow.com/q/3998883 | https://stackoverflow.com/a/3999084 | <p>Use <code>git merge-base master your-branch</code> to find the best common ancestor between two branches (usually, but not necessarily, the branching point).</p>
| <p>Use <code>git merge-base master your-branch</code> to find the best common ancestor between two branches (usually, but not necessarily, the branching point).</p> | 119, 76220 | git, git-branch | <h1>git how to find commit hash where branch originated from</h1>
<p>Pretend I branched from my master branch to a topic branch, and then I did a few commits on my topic branch. Is there a command that tells me the commit hash on the master branch that my topic branch originated from?</p>
<p>Ideally, I wouldn't have t... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,933 | git | # git how to find commit hash where branch originated from
Pretend I branched from my master branch to a topic branch, and then I did a few commits on my topic branch. Is there a command that tells me the commit hash on the master branch that my topic branch originated from?
Ideally, I wouldn't have to know how many ... | Use `git merge-base master your-branch` to find the best common ancestor between two branches (usually, but not necessarily, the branching point). |
7624790 | What is the git equivalent of of hg outgoing (hg out) or hg incoming (hg in)? | 100 | 2011-10-02 05:31:13 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/1331385/how-can-i-see-incoming-commits-in-git">How can I see incoming commits in git?</a> </p>
</blockquote>
<p>What is the git equivalent of of "hg outgoing" or "hg incoming"?</p>
<p>In Mercurial, <code>hg ou... | 30,422 | 895,795 | 2014-06-18 13:12:42 | 7,625,074 | 103 | 2011-10-02 07:15:12 | 27,835 | 2011-10-02 07:15:12 | https://stackoverflow.com/q/7624790 | https://stackoverflow.com/a/7625074 | <p>If you want to list commits that are on branch <code>B</code> but not on branch <code>A</code>, do <code>git log A..B</code>.</p>
<p>If you want to list commits that are on your local branch <code>dev</code>, but not the the remote branch <code>origin/dev</code>, do:</p>
<pre><code>git fetch origin # U... | <p>If you want to list commits that are on branch <code>B</code> but not on branch <code>A</code>, do <code>git log A..B</code>.</p> <p>If you want to list commits that are on your local branch <code>dev</code>, but not the the remote branch <code>origin/dev</code>, do:</p> <pre><code>git fetch origin # U... | 119, 802 | git, mercurial | <h1>What is the git equivalent of of hg outgoing (hg out) or hg incoming (hg in)?</h1>
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/1331385/how-can-i-see-incoming-commits-in-git">How can I see incoming commits in git?</a> </p>
</blockquote>
<p>What is the... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,934 | git | # What is the git equivalent of of hg outgoing (hg out) or hg incoming (hg in)?
> **Possible Duplicate:**
> [How can I see incoming commits in git?](https://stackoverflow.com/questions/1331385/how-can-i-see-incoming-commits-in-git)
What is the git equivalent of of "hg outgoing" or "hg incoming"?
In Mercurial, `hg ... | If you want to list commits that are on branch `B` but not on branch `A`, do `git log A..B`.
If you want to list commits that are on your local branch `dev`, but not the the remote branch `origin/dev`, do:
```
git fetch origin # Update origin/dev if needed
git log origin/dev..dev
```
If you want to list ... |
25507951 | Easiest way to rename git project configured on BitBucket | 91 | 2014-08-26 14:10:49 | <p>I have a project hosted on BitBucket</p>
<p>Can I rename it ?</p>
<p>If not and I need to create a new repository can someone tell me the easiest way to do that and have new repo on BitBucket (one particular cause of confusion for me is whether to drive the process locally or from the bitbucket website)</p>
<p><s... | 72,352 | 1,480,018 | 2022-06-30 18:27:34 | 25,507,992 | 103 | 2014-08-26 14:13:06 | 611,685 | 2014-08-26 14:13:06 | https://stackoverflow.com/q/25507951 | https://stackoverflow.com/a/25507992 | <p>You can rename the project form the settings menu of the projects on Bitbucket.</p>
<p>Once you rename it, you need to update your git config file to fetch the data from the new location</p>
<pre><code>nano .git/config
</code></pre>
<p>Change the name of the project to the new name and save</p>
| <p>You can rename the project form the settings menu of the projects on Bitbucket.</p> <p>Once you rename it, you need to update your git config file to fetch the data from the new location</p> <pre><code>nano .git/config </code></pre> <p>Change the name of the project to the new name and save</p> | 119, 8337 | bitbucket, git | <h1>Easiest way to rename git project configured on BitBucket</h1>
<p>I have a project hosted on BitBucket</p>
<p>Can I rename it ?</p>
<p>If not and I need to create a new repository can someone tell me the easiest way to do that and have new repo on BitBucket (one particular cause of confusion for me is whether to ... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,935 | git | # Easiest way to rename git project configured on BitBucket
I have a project hosted on BitBucket
Can I rename it ?
If not and I need to create a new repository can someone tell me the easiest way to do that and have new repo on BitBucket (one particular cause of confusion for me is whether to drive the process local... | You can rename the project form the settings menu of the projects on Bitbucket.
Once you rename it, you need to update your git config file to fetch the data from the new location
```
nano .git/config
```
Change the name of the project to the new name and save |
2013091 | Coloured Git diff to HTML | 85 | 2010-01-06 13:13:21 | <p>I enjoy using <code>git diff --color-words</code> to clearly see the words that have changed in a file:</p>
<p><img src="https://i.sstatic.net/HnM4B.png" alt="Screenshot"></p>
<p>However I want to share that diff with someone without git or a colour terminal for that matter. So does anyone know of a tool or trick ... | 55,863 | 4,534 | 2021-05-16 19:29:07 | 2,031,457 | 103 | 2010-01-08 23:15:15 | 4,534 | 2015-10-02 20:40:35 | https://stackoverflow.com/q/2013091 | https://stackoverflow.com/a/2031457 | <pre class="lang-bash prettyprint-override"><code>wget "http://www.pixelbeat.org/scripts/ansi2html.sh" -O /tmp/ansi2html.sh
chmod +x /tmp/ansi2html.sh
git diff --color-words --no-index orig.txt edited.txt | \
/tmp/ansi2html.sh > 2beshared.html
</code></pre>
<p>What I really needed was an <a href="http://en.wikipedi... | <pre class="lang-bash prettyprint-override"><code>wget "http://www.pixelbeat.org/scripts/ansi2html.sh" -O /tmp/ansi2html.sh chmod +x /tmp/ansi2html.sh git diff --color-words --no-index orig.txt edited.txt | \ /tmp/ansi2html.sh > 2beshared.html </code></pre> <p>What I really needed was an <a href="http://en.wikipedi... | 2, 119, 391, 606, 6439 | colors, diff, git, html, terminal | <h1>Coloured Git diff to HTML</h1>
<p>I enjoy using <code>git diff --color-words</code> to clearly see the words that have changed in a file:</p>
<p><img src="https://i.sstatic.net/HnM4B.png" alt="Screenshot"></p>
<p>However I want to share that diff with someone without git or a colour terminal for that matter. So d... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,936 | git | # Coloured Git diff to HTML
I enjoy using `git diff --color-words` to clearly see the words that have changed in a file:

However I want to share that diff with someone without git or a colour terminal for that matter. So does anyone know of a tool or trick that can conv... | ```
wget "http://www.pixelbeat.org/scripts/ansi2html.sh" -O /tmp/ansi2html.sh
chmod +x /tmp/ansi2html.sh
git diff --color-words --no-index orig.txt edited.txt | \
/tmp/ansi2html.sh > 2beshared.html
```
What I really needed was an [ANSI](http://en.wikipedia.org/wiki/ANSI_escape_code) to HTML converter. And I found a ve... |
16574625 | How do I add files in Git to the path of a former submodule? | 78 | 2013-05-15 20:42:59 | <p>I have a project that used to contain a submodule, at path <code>mysubmodule</code>. I installed the latest Git from source (1.8.3-rc2) and ran <code>git submodule deinit mysubmodule</code>. I then deleted the <code>.gitmodules</code> file and committed the change. I also deleted the <code>.git</code> directory f... | 31,368 | 9,161 | 2013-05-16 07:09:46 | 16,581,096 | 103 | 2013-05-16 07:09:46 | 6,309 | 2013-05-16 07:09:46 | https://stackoverflow.com/q/16574625 | https://stackoverflow.com/a/16581096 | <p>Git still think <code>mysubmodule</code> is a submodule, because it is recorded in the index with a special mode "160000".<br>
See "<a href="https://stackoverflow.com/questions/1992018/git-submodule-update-needed-only-initially/2227598#2227598">git submodule update needed only initially?</a>" for more.<br>
To check ... | <p>Git still think <code>mysubmodule</code> is a submodule, because it is recorded in the index with a special mode "160000".<br> See "<a href="https://stackoverflow.com/questions/1992018/git-submodule-update-needed-only-initially/2227598#2227598">git submodule update needed only initially?</a>" for more.<br> To check ... | 119, 41612 | git, git-submodules | <h1>How do I add files in Git to the path of a former submodule?</h1>
<p>I have a project that used to contain a submodule, at path <code>mysubmodule</code>. I installed the latest Git from source (1.8.3-rc2) and ran <code>git submodule deinit mysubmodule</code>. I then deleted the <code>.gitmodules</code> file and c... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,938 | git | # How do I add files in Git to the path of a former submodule?
I have a project that used to contain a submodule, at path `mysubmodule`. I installed the latest Git from source (1.8.3-rc2) and ran `git submodule deinit mysubmodule`. I then deleted the `.gitmodules` file and committed the change. I also deleted the `.gi... | Git still think `mysubmodule` is a submodule, because it is recorded in the index with a special mode "160000".
See "[git submodule update needed only initially?](https://stackoverflow.com/questions/1992018/git-submodule-update-needed-only-initially/2227598#2227598)" for more.
To check that, as in [in this answer](... |
46382883 | Shortcut to push code to git in VSCode? | 77 | 2017-09-23 18:19:34 | <p>In VS Code, the only way that I know of to push commits with git is to go into the "..." menu of the Source Control tab and click <code>Push</code>.</p>
<p><a href="https://i.sstatic.net/0c7a7.png" rel="noreferrer"><img src="https://i.sstatic.net/0c7a7.png" alt="Exhibit A"></a></p>
<p>That method seems a bit round... | 58,516 | 3,339,274 | 2024-10-27 08:44:10 | 46,383,040 | 103 | 2017-09-23 18:37:10 | 2,037,090 | 2018-04-11 16:41:27 | https://stackoverflow.com/q/46382883 | https://stackoverflow.com/a/46383040 | <p>There is a button at the bottom left of the VS Code editor, which you can click to automatically sync your branch with that from remote (i.e. both pull AND push, merging your branch with upstream if necessary). This might or might not be what you want, but it's easy to click this when you know that there are no chan... | <p>There is a button at the bottom left of the VS Code editor, which you can click to automatically sync your branch with that from remote (i.e. both pull AND push, merging your branch with upstream if necessary). This might or might not be what you want, but it's easy to click this when you know that there are no chan... | 119, 111608 | git, visual-studio-code | <h1>Shortcut to push code to git in VSCode?</h1>
<p>In VS Code, the only way that I know of to push commits with git is to go into the "..." menu of the Source Control tab and click <code>Push</code>.</p>
<p><a href="https://i.sstatic.net/0c7a7.png" rel="noreferrer"><img src="https://i.sstatic.net/0c7a7.png" alt="Exhi... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,939 | git | # Shortcut to push code to git in VSCode?
In VS Code, the only way that I know of to push commits with git is to go into the "..." menu of the Source Control tab and click `Push`.
[](https://i.sstatic.net/0c7a7.png)
That method seems a bit roundabout to me, especially con... | There is a button at the bottom left of the VS Code editor, which you can click to automatically sync your branch with that from remote (i.e. both pull AND push, merging your branch with upstream if necessary). This might or might not be what you want, but it's easy to click this when you know that there are no changes... |
21998728 | How to specify a git commit message template for a repository in a file at a relative path to the repository? | 75 | 2014-02-24 20:51:36 | <p>Is there a way to specify a git commit.template that is relative to a repository?</p>
<p>For configuration an example is</p>
<pre><code>$ git config commit.template $HOME/.gitmessage.txt
</code></pre>
<p>But I would like to specify a template file relative to the .git folder of the repository.</p>
| 73,133 | 918,944 | 2020-11-07 02:08:28 | 28,948,582 | 103 | 2015-03-09 17:50:33 | 9,660 | 2015-03-09 17:50:33 | https://stackoverflow.com/q/21998728 | https://stackoverflow.com/a/28948582 | <p><a href="http://www.syntevo.com/blog/?p=4076">This blog</a> tipped me off that if the path to the template file is not absolute, then the path is considered to be relative to the repository root.</p>
<pre><code>git config commit.template /absolute/path/to/file
or
git config commit.template relative-path-from-repo... | <p><a href="http://www.syntevo.com/blog/?p=4076">This blog</a> tipped me off that if the path to the template file is not absolute, then the path is considered to be relative to the repository root.</p> <pre><code>git config commit.template /absolute/path/to/file or git config commit.template relative-path-from-repo... | 119 | git | <h1>How to specify a git commit message template for a repository in a file at a relative path to the repository?</h1>
<p>Is there a way to specify a git commit.template that is relative to a repository?</p>
<p>For configuration an example is</p>
<pre><code>$ git config commit.template $HOME/.gitmessage.txt
</code></... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,940 | git | # How to specify a git commit message template for a repository in a file at a relative path to the repository?
Is there a way to specify a git commit.template that is relative to a repository?
For configuration an example is
```
$ git config commit.template $HOME/.gitmessage.txt
```
But I would like to specify a t... | [This blog](http://www.syntevo.com/blog/?p=4076) tipped me off that if the path to the template file is not absolute, then the path is considered to be relative to the repository root.
```
git config commit.template /absolute/path/to/file
or
git config commit.template relative-path-from-repository-root
``` |
559917 | git rebase and git push: non-fast forward, why use? | 71 | 2009-02-18 05:09:23 | <p>I have a branch that should be available to other contributors and that should constantly stay up to date with the master.</p>
<p>Unfortunately, every time I do 'git rebase' and then try to push, it results in 'non-fast forward' message and abortion of pushing. The only way to push here is to use --force. Does that... | 45,584 | 34,134 | 2013-01-11 10:37:40 | 559,971 | 103 | 2009-02-18 05:37:26 | 64,004 | 2009-09-09 20:51:36 | https://stackoverflow.com/q/559917 | https://stackoverflow.com/a/559971 | <p><strong>A few notes on how git works (non technical):</strong></p>
<p>When you rebase, git takes the commits in question, and "recommits" them on top of a clean history. This is to prevent the history from showing:</p>
<pre><code>Description: tree -> mywork -> merge -> mywork -> merge -> mywork -&g... | <p><strong>A few notes on how git works (non technical):</strong></p> <p>When you rebase, git takes the commits in question, and "recommits" them on top of a clean history. This is to prevent the history from showing:</p> <pre><code>Description: tree -> mywork -> merge -> mywork -> merge -> mywork -&g... | 119, 717, 8974 | git, merge, rebase | <h1>git rebase and git push: non-fast forward, why use?</h1>
<p>I have a branch that should be available to other contributors and that should constantly stay up to date with the master.</p>
<p>Unfortunately, every time I do 'git rebase' and then try to push, it results in 'non-fast forward' message and abortion of pu... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,941 | git | # git rebase and git push: non-fast forward, why use?
I have a branch that should be available to other contributors and that should constantly stay up to date with the master.
Unfortunately, every time I do 'git rebase' and then try to push, it results in 'non-fast forward' message and abortion of pushing. The only ... | **A few notes on how git works (non technical):**
When you rebase, git takes the commits in question, and "recommits" them on top of a clean history. This is to prevent the history from showing:
```
Description: tree -> mywork -> merge -> mywork -> merge -> mywork -> merge
Commit SHA1: aaaa -> bbbb -> cccc -> dddd... |
21559119 | How to resolve conflicts in EGit | 70 | 2014-02-04 17:19:40 | <p>I am using EGit on <a href="https://en.wikipedia.org/wiki/Eclipse_%28software%29#Releases" rel="noreferrer">Eclipse v4.3</a> (Kepler). I want to commit and push my changes. I do a pull first and one file is conflicting. After manually resolving the conflict (local and remote are the same now), I am still runnin... | 269,962 | 2,231,887 | 2022-09-30 07:10:26 | 27,914,508 | 103 | 2015-01-13 03:35:02 | 692,626 | 2022-09-30 07:10:26 | https://stackoverflow.com/q/21559119 | https://stackoverflow.com/a/27914508 | <p>Are you using the Team Synchronise view? If so that's the problem. Conflict resolution in the Team Synchronise view doesn't work with EGit. Instead you need to use the Git Repository view.</p>
<p>Open the Git perspective. In the Git Repository view, go to on <em>Branches</em> → <em>Local</em> → <em>master</em> and r... | <p>Are you using the Team Synchronise view? If so that's the problem. Conflict resolution in the Team Synchronise view doesn't work with EGit. Instead you need to use the Git Repository view.</p> <p>Open the Git perspective. In the Git Repository view, go to on <em>Branches</em> → <em>Local</em> → <em>master</em> and r... | 53, 119, 43702 | eclipse, egit, git | <h1>How to resolve conflicts in EGit</h1>
<p>I am using EGit on <a href="https://en.wikipedia.org/wiki/Eclipse_%28software%29#Releases" rel="noreferrer">Eclipse v4.3</a> (Kepler). I want to commit and push my changes. I do a pull first and one file is conflicting. After manually resolving the conflict (local and r... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,942 | git | # How to resolve conflicts in EGit
I am using EGit on [Eclipse v4.3](https://en.wikipedia.org/wiki/Eclipse_%28software%29#Releases) (Kepler). I want to commit and push my changes. I do a pull first and one file is conflicting. After manually resolving the conflict (local and remote are the same now), I am still runnin... | Are you using the Team Synchronise view? If so that's the problem. Conflict resolution in the Team Synchronise view doesn't work with EGit. Instead you need to use the Git Repository view.
Open the Git perspective. In the Git Repository view, go to on *Branches* → *Local* → *master* and right click → *Merge*...
It sh... |
4948494 | Break up multiple changes into separate commits with git? | 63 | 2011-02-09 17:44:53 | <p>If I have made multiple sets of changes to a large file, is it possible to split those into separate commits using git?</p>
| 25,783 | 97,101 | 2019-12-03 09:45:25 | 4,948,806 | 103 | 2011-02-09 18:17:09 | 140,750 | 2019-04-16 06:14:25 | https://stackoverflow.com/q/4948494 | https://stackoverflow.com/a/4948806 | <p>You want <code>git add --patch</code> (<a href="https://git-scm.com/docs/git-add#Documentation/git-add.txt-patch" rel="noreferrer">documentation</a>), which will allow you to select which changes to stage.</p>
| <p>You want <code>git add --patch</code> (<a href="https://git-scm.com/docs/git-add#Documentation/git-add.txt-patch" rel="noreferrer">documentation</a>), which will allow you to select which changes to stage.</p> | 119 | git | <h1>Break up multiple changes into separate commits with git?</h1>
<p>If I have made multiple sets of changes to a large file, is it possible to split those into separate commits using git?</p>
| q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,943 | git | # Break up multiple changes into separate commits with git?
If I have made multiple sets of changes to a large file, is it possible to split those into separate commits using git? | You want `git add --patch` ([documentation](https://git-scm.com/docs/git-add#Documentation/git-add.txt-patch)), which will allow you to select which changes to stage. |
21630980 | BFG remove multiple folders | 53 | 2014-02-07 15:01:23 | <p>I found that BFG is much faster than the original git-filter-branch.</p>
<p>We have multiple svn repo to move to even more git repositories, this implies some repository folder merges and splits.
During the process I need to remove a set of root folders and I'd like to remove those to the whole history.</p>
<p>I t... | 16,139 | 929,219 | 2021-01-22 14:56:31 | 21,636,596 | 103 | 2014-02-07 19:52:23 | 438,886 | 2016-01-20 20:12:09 | https://stackoverflow.com/q/21630980 | https://stackoverflow.com/a/21636596 | <p>The argument to <code>--delete-folders</code> is a <a href="http://en.wikipedia.org/wiki/Glob_%28programming%29">glob</a> expression, so you should be able to just comma-separate the folder names, like this:</p>
<pre><code>$ bfg --delete-folders "{folderA,folderB,folderC}" my-repo.git
</code></pre>
<p>Good luck!</... | <p>The argument to <code>--delete-folders</code> is a <a href="http://en.wikipedia.org/wiki/Glob_%28programming%29">glob</a> expression, so you should be able to just comma-separate the folder names, like this:</p> <pre><code>$ bfg --delete-folders "{folderA,folderB,folderC}" my-repo.git </code></pre> <p>Good luck!</... | 91259, 105532 | bfg-repo-cleaner, git-rewrite-history | <h1>BFG remove multiple folders</h1>
<p>I found that BFG is much faster than the original git-filter-branch.</p>
<p>We have multiple svn repo to move to even more git repositories, this implies some repository folder merges and splits.
During the process I need to remove a set of root folders and I'd like to remove th... | q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10 | 15,945 | git | # BFG remove multiple folders
I found that BFG is much faster than the original git-filter-branch.
We have multiple svn repo to move to even more git repositories, this implies some repository folder merges and splits.
During the process I need to remove a set of root folders and I'd like to remove those to the whole... | The argument to `--delete-folders` is a [glob](http://en.wikipedia.org/wiki/Glob_%28programming%29) expression, so you should be able to just comma-separate the folder names, like this:
```
$ bfg --delete-folders "{folderA,folderB,folderC}" my-repo.git
```
Good luck!
*Full disclosure: I'm the author of the [BFG Repo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.