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
7434449
Why use 'git rm' to remove a file instead of 'rm'?
263
2011-09-15 16:43:02
<p>On SVN, removing something from the filesystem directly (rather than using svn) created a load of headaches.</p> <p>I haven't found this to be an issue when using <code>git</code>, but I notice that git has its own <code>rm</code> implementation (<code>git rm</code>).</p> <p>What is the difference between <code>rm</...
166,553
222,151
2023-01-15 17:35:33
7,434,558
355
2011-09-15 16:51:30
275,354
2011-09-15 16:51:30
https://stackoverflow.com/q/7434449
https://stackoverflow.com/a/7434558
<p>If you just use <code>rm</code>, you will need to follow it up with <code>git add &lt;fileRemoved&gt;</code>. <code>git rm</code> does this in one step.</p> <p>You can also use <code>git rm --cached</code> which will remove the file from the index (staging it for deletion on the next commit), but keep your copy in...
<p>If you just use <code>rm</code>, you will need to follow it up with <code>git add &lt;fileRemoved&gt;</code>. <code>git rm</code> does this in one step.</p> <p>You can also use <code>git rm --cached</code> which will remove the file from the index (staging it for deletion on the next commit), but keep your copy in...
119
git
<h1>Why use 'git rm' to remove a file instead of 'rm'?</h1> <p>On SVN, removing something from the filesystem directly (rather than using svn) created a load of headaches.</p> <p>I haven't found this to be an issue when using <code>git</code>, but I notice that git has its own <code>rm</code> implementation (<code>git ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,577
git
# Why use 'git rm' to remove a file instead of 'rm'? On SVN, removing something from the filesystem directly (rather than using svn) created a load of headaches. I haven't found this to be an issue when using `git`, but I notice that git has its own `rm` implementation (`git rm`). What is the difference between `rm`...
If you just use `rm`, you will need to follow it up with `git add <fileRemoved>`. `git rm` does this in one step. You can also use `git rm --cached` which will remove the file from the index (staging it for deletion on the next commit), but keep your copy in the local file system.
12123633
Differences for a certain folder between Git branches
173
2012-08-25 16:19:16
<p>How can I get a diff file for a certain folder between the <em>master</em> branch and a branch I have created?</p>
114,188
267,416
2024-02-02 22:07:45
12,123,669
354
2012-08-25 16:23:18
592,392
2022-07-01 11:31:47
https://stackoverflow.com/q/12123633
https://stackoverflow.com/a/12123669
<p>You can use</p> <pre><code>git diff master..yourbranch -- path/to/folder </code></pre>
<p>You can use</p> <pre><code>git diff master..yourbranch -- path/to/folder </code></pre>
119, 456, 606, 9033
diff, git, git-diff, version-control
<h1>Differences for a certain folder between Git branches</h1> <p>How can I get a diff file for a certain folder between the <em>master</em> branch and a branch I have created?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,581
git
# Differences for a certain folder between Git branches How can I get a diff file for a certain folder between the *master* branch and a branch I have created?
You can use ``` git diff master..yourbranch -- path/to/folder ```
42332769
How do I reset the git master branch to the upstream branch in a forked repository?
197
2017-02-19 20:55:25
<p>I've completely messed up the master branch of my forked git repo.</p> <p>I want to completely reset the master branch that was pushed to my fork with the contents of the upstream master repo. I have no interest in retaining any master branch changes or history.</p> <p>The simplest approach would have been to del...
179,930
1,626,229
2025-09-16 10:31:14
42,332,860
353
2017-02-19 21:05:44
2,038,939
2021-08-12 13:29:41
https://stackoverflow.com/q/42332769
https://stackoverflow.com/a/42332860
<p>You can reset your local master branch to the upstream version and push it to your origin repository.</p> <p>Assuming that &quot;upstream&quot; is the original repository and &quot;origin&quot; is your fork:</p> <pre><code># ensures current branch is master git checkout master # pulls all new commits made to upstre...
<p>You can reset your local master branch to the upstream version and push it to your origin repository.</p> <p>Assuming that &quot;upstream&quot; is the original repository and &quot;origin&quot; is your fork:</p> <pre><code># ensures current branch is master git checkout master # pulls all new commits made to upstre...
119
git
<h1>How do I reset the git master branch to the upstream branch in a forked repository?</h1> <p>I've completely messed up the master branch of my forked git repo.</p> <p>I want to completely reset the master branch that was pushed to my fork with the contents of the upstream master repo. I have no interest in retaini...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,582
git
# How do I reset the git master branch to the upstream branch in a forked repository? I've completely messed up the master branch of my forked git repo. I want to completely reset the master branch that was pushed to my fork with the contents of the upstream master repo. I have no interest in retaining any master bra...
You can reset your local master branch to the upstream version and push it to your origin repository. Assuming that "upstream" is the original repository and "origin" is your fork: ``` # ensures current branch is master git checkout master # pulls all new commits made to upstream/master git pull upstream master # t...
5817579
How can I preview a merge in git?
521
2011-04-28 11:04:17
<p>I have a git branch (the mainline, for example) and I want to merge in another development branch. Or do I?</p> <p>In order to decide whether I really want to merge this branch in, i'd like to see some sort of preview of what the merge will do. Preferably with the ability to see the list of commits that are being a...
203,744
173,062
2026-01-23 18:15:09
30,516,827
352
2015-05-28 20:49:01
497,369
2019-09-23 15:33:05
https://stackoverflow.com/q/5817579
https://stackoverflow.com/a/30516827
<p>I've found that the solution the works best for me is to <strong>just perform the merge and abort it if there are conflicts</strong>. This particular syntax feels clean and simple to me. This is <strong>Strategy 2</strong> below.</p> <p>However, if you want to ensure you don't mess up your current branch, or you're ...
<p>I've found that the solution the works best for me is to <strong>just perform the merge and abort it if there are conflicts</strong>. This particular syntax feels clean and simple to me. This is <strong>Strategy 2</strong> below.</p> <p>However, if you want to ensure you don't mess up your current branch, or you're ...
119, 28897
git, git-merge
<h1>How can I preview a merge in git?</h1> <p>I have a git branch (the mainline, for example) and I want to merge in another development branch. Or do I?</p> <p>In order to decide whether I really want to merge this branch in, i'd like to see some sort of preview of what the merge will do. Preferably with the ability ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,583
git
# How can I preview a merge in git? I have a git branch (the mainline, for example) and I want to merge in another development branch. Or do I? In order to decide whether I really want to merge this branch in, i'd like to see some sort of preview of what the merge will do. Preferably with the ability to see the list ...
I've found that the solution the works best for me is to **just perform the merge and abort it if there are conflicts**. This particular syntax feels clean and simple to me. This is **Strategy 2** below. However, if you want to ensure you don't mess up your current branch, or you're just not ready to merge regardless ...
12961752
Git merge error "commit is not possible because you have unmerged files"
255
2012-10-18 18:54:21
<p>I forgot to <code>git pull</code> my code before editing it; when I committed the new code and tried to push, I got the error &quot;push is not possible&quot;.</p> <p>At that point I did a <code>git pull</code> which made some files with conflict highlighted. I removed the conflicts but I don't know what to do from ...
386,140
814,359
2024-01-02 14:16:41
12,961,804
352
2012-10-18 18:57:36
203,723
2012-10-18 18:57:36
https://stackoverflow.com/q/12961752
https://stackoverflow.com/a/12961804
<p>If you have fixed the conflicts you need to add the files to the stage with <code>git add [filename]</code>, then commit as normal.</p>
<p>If you have fixed the conflicts you need to add the files to the stage with <code>git add [filename]</code>, then commit as normal.</p>
119, 28897
git, git-merge
<h1>Git merge error "commit is not possible because you have unmerged files"</h1> <p>I forgot to <code>git pull</code> my code before editing it; when I committed the new code and tried to push, I got the error &quot;push is not possible&quot;.</p> <p>At that point I did a <code>git pull</code> which made some files wi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,585
git
# Git merge error "commit is not possible because you have unmerged files" I forgot to `git pull` my code before editing it; when I committed the new code and tried to push, I got the error "push is not possible". At that point I did a `git pull` which made some files with conflict highlighted. I removed the conflict...
If you have fixed the conflicts you need to add the files to the stage with `git add [filename]`, then commit as normal.
13363553
Git error: "Host Key Verification Failed" when connecting to remote repository
588
2012-11-13 15:26:36
<p>I am trying to connect to a remote Git repository that resides on my web server and clone it to my machine.</p> <p>I am using the following format for my command:</p> <pre><code>git clone ssh://username@domain.example/repository.git </code></pre> <p>This has worked fine for most of my team members. Usually after run...
1,089,316
1,775,860
2024-04-29 20:45:04
13,364,116
351
2012-11-13 15:59:18
123,109
2022-06-20 10:29:40
https://stackoverflow.com/q/13363553
https://stackoverflow.com/a/13364116
<p>You are connecting via the SSH protocol, as indicated by the <code>ssh://</code> prefix on your clone URL. Using SSH, every host has a key. Clients remember the host key associated with a particular address and refuse to connect if a host key appears to change. This prevents man in the middle attacks.</p> <p>The hos...
<p>You are connecting via the SSH protocol, as indicated by the <code>ssh://</code> prefix on your clone URL. Using SSH, every host has a key. Clients remember the host key associated with a particular address and refuse to connect if a host key appears to change. This prevents man in the middle attacks.</p> <p>The hos...
119, 386, 25308
git, ssh, ssh-keys
<h1>Git error: "Host Key Verification Failed" when connecting to remote repository</h1> <p>I am trying to connect to a remote Git repository that resides on my web server and clone it to my machine.</p> <p>I am using the following format for my command:</p> <pre><code>git clone ssh://username@domain.example/repository....
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,586
git
# Git error: "Host Key Verification Failed" when connecting to remote repository I am trying to connect to a remote Git repository that resides on my web server and clone it to my machine. I am using the following format for my command: ``` git clone ssh://username@domain.example/repository.git ``` This has worked ...
You are connecting via the SSH protocol, as indicated by the `ssh://` prefix on your clone URL. Using SSH, every host has a key. Clients remember the host key associated with a particular address and refuse to connect if a host key appears to change. This prevents man in the middle attacks. The host key for `domain.ex...
17581379
git clone without project folder
165
2013-07-10 21:40:22
<p>I have given access to server, and want to clone git repo into my root folder. But when I do git clone it will make me folder with project name, and my project folder is my root. I dont have access to my parent folder my root is</p> <pre><code>/var/www/sites/mysite/ </code></pre> <p>and when I do cloning folder st...
190,737
936,930
2022-09-19 00:04:38
17,581,648
351
2013-07-10 21:58:05
865,874
2013-07-10 21:58:05
https://stackoverflow.com/q/17581379
https://stackoverflow.com/a/17581648
<p><code>git clone</code> accepts a last argument that is the destination directory, it is by default the name of the project but you can change it. In your case you probably want simply <code>.</code>:</p> <pre><code>$ git clone origin-url . </code></pre> <p>But note that, from <code>man git-clone</code>:</p> <bloc...
<p><code>git clone</code> accepts a last argument that is the destination directory, it is by default the name of the project but you can change it. In your case you probably want simply <code>.</code>:</p> <pre><code>$ git clone origin-url . </code></pre> <p>But note that, from <code>man git-clone</code>:</p> <bloc...
119
git
<h1>git clone without project folder</h1> <p>I have given access to server, and want to clone git repo into my root folder. But when I do git clone it will make me folder with project name, and my project folder is my root. I dont have access to my parent folder my root is</p> <pre><code>/var/www/sites/mysite/ </code>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,587
git
# git clone without project folder I have given access to server, and want to clone git repo into my root folder. But when I do git clone it will make me folder with project name, and my project folder is my root. I dont have access to my parent folder my root is ``` /var/www/sites/mysite/ ``` and when I do cloning ...
`git clone` accepts a last argument that is the destination directory, it is by default the name of the project but you can change it. In your case you probably want simply `.`: ``` $ git clone origin-url . ``` But note that, from `man git-clone`: > Cloning into an existing directory is only allowed if the directory...
6624036
Restore file from old commit in git
315
2011-07-08 11:53:09
<p>I have an old commit that I did a few weeks ago. I want to restore only a single file from that commit. What do I do?</p>
176,248
652,895
2025-10-24 13:17:14
6,624,085
350
2011-07-08 11:57:38
85,371
2013-01-09 18:23:20
https://stackoverflow.com/q/6624036
https://stackoverflow.com/a/6624085
<pre><code>git checkout 'master@{7 days ago}' -- path/to/file.txt </code></pre> <p>This will not alter HEAD, it will just overwrite the local file <code>path/to/file.txt</code></p> <p>See <a href="http://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html">man git-rev-parse</a> for possible revision specifica...
<pre><code>git checkout 'master@{7 days ago}' -- path/to/file.txt </code></pre> <p>This will not alter HEAD, it will just overwrite the local file <code>path/to/file.txt</code></p> <p>See <a href="http://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html">man git-rev-parse</a> for possible revision specifica...
119, 37230
git, git-checkout
<h1>Restore file from old commit in git</h1> <p>I have an old commit that I did a few weeks ago. I want to restore only a single file from that commit. What do I do?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,588
git
# Restore file from old commit in git I have an old commit that I did a few weeks ago. I want to restore only a single file from that commit. What do I do?
``` git checkout 'master@{7 days ago}' -- path/to/file.txt ``` This will not alter HEAD, it will just overwrite the local file `path/to/file.txt` See [man git-rev-parse](http://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html) for possible revision specifications there (of course a simple hash (like `dd9ba...
1979167
Git submodule update
294
2009-12-30 09:02:24
<p>I'm not clear on what the following means (from the <a href="http://git-scm.com/docs/git-submodule" rel="noreferrer">Git submodule update</a> documentation):</p> <blockquote> <p>...will make the submodules HEAD be detached, unless <code>--rebase</code> or <code>--merge</code> is specified...</p> </blockquote> <p...
465,416
51,923
2021-07-22 19:54:27
1,979,194
350
2009-12-30 09:10:02
6,309
2017-12-18 09:06:01
https://stackoverflow.com/q/1979167
https://stackoverflow.com/a/1979194
<p>This <a href="http://git-scm.com/book/ch6-6.html" rel="noreferrer">GitPro page</a> does summarize the consequence of a git submodule update nicely</p> <blockquote> <p>When you run <code>git submodule update</code>, it checks out the specific version of the project, but not within a branch. This is called having a...
<p>This <a href="http://git-scm.com/book/ch6-6.html" rel="noreferrer">GitPro page</a> does summarize the consequence of a git submodule update nicely</p> <blockquote> <p>When you run <code>git submodule update</code>, it checks out the specific version of the project, but not within a branch. This is called having a...
119, 41612
git, git-submodules
<h1>Git submodule update</h1> <p>I'm not clear on what the following means (from the <a href="http://git-scm.com/docs/git-submodule" rel="noreferrer">Git submodule update</a> documentation):</p> <blockquote> <p>...will make the submodules HEAD be detached, unless <code>--rebase</code> or <code>--merge</code> is spec...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,589
git
# Git submodule update I'm not clear on what the following means (from the [Git submodule update](http://git-scm.com/docs/git-submodule) documentation): > ...will make the submodules HEAD be detached, unless `--rebase` or `--merge` is specified... How does `--rebase`/`--merge` change things? My main use case is to ...
This [GitPro page](http://git-scm.com/book/ch6-6.html) does summarize the consequence of a git submodule update nicely > When you run `git submodule update`, it checks out the specific version of the project, but not within a branch. This is called having a detached head — it means the HEAD file points directly to a c...
1386291
git --git-dir not working as expected
248
2009-09-06 18:08:54
<p>I am trying to run git from a different directory than I am in. So for example if I am in:</p> <pre><code>cd /home/domain/ git status &lt;&lt; runs perfect ie # On branch master # Your branch is ahead of 'origin/master' by 6 commits. </code></pre> <p>So now I want to run this command from a different directory usi...
104,322
99,877
2021-09-02 14:16:58
1,386,350
350
2009-09-06 18:33:46
5,601
2015-03-04 21:09:20
https://stackoverflow.com/q/1386291
https://stackoverflow.com/a/1386350
<p>You have to define the working dir as well. Confusing I know but it's a flexibility thing.</p> <pre><code>git --git-dir=/mycode/.git --work-tree=/mycode status </code></pre> <p>You can read a little more <a href="http://marc.info/?l=git&amp;m=120956110207686&amp;w=2" rel="noreferrer">here</a></p>
<p>You have to define the working dir as well. Confusing I know but it's a flexibility thing.</p> <pre><code>git --git-dir=/mycode/.git --work-tree=/mycode status </code></pre> <p>You can read a little more <a href="http://marc.info/?l=git&amp;m=120956110207686&amp;w=2" rel="noreferrer">here</a></p>
119
git
<h1>git --git-dir not working as expected</h1> <p>I am trying to run git from a different directory than I am in. So for example if I am in:</p> <pre><code>cd /home/domain/ git status &lt;&lt; runs perfect ie # On branch master # Your branch is ahead of 'origin/master' by 6 commits. </code></pre> <p>So now I want to ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,590
git
# git --git-dir not working as expected I am trying to run git from a different directory than I am in. So for example if I am in: ``` cd /home/domain/ git status << runs perfect ie # On branch master # Your branch is ahead of 'origin/master' by 6 commits. ``` So now I want to run this command from a different direc...
You have to define the working dir as well. Confusing I know but it's a flexibility thing. ``` git --git-dir=/mycode/.git --work-tree=/mycode status ``` You can read a little more [here](http://marc.info/?l=git&m=120956110207686&w=2)
880957
Pull all commits from a branch, push specified commits to another
113
2009-05-19 04:20:26
<p>I have the following branches:</p> <ul> <li><code>master</code></li> <li><code>production</code></li> </ul> <p>and the following remote branches:</p> <ul> <li><code>origin/master</code></li> <li><code>origin/production</code></li> </ul> <p>I have a script that fetches the <code>origin/master</code> branch and ge...
107,529
101,969
2018-07-19 09:45:48
881,014
350
2009-05-19 04:53:32
36,723
2018-07-19 09:45:48
https://stackoverflow.com/q/880957
https://stackoverflow.com/a/881014
<p>The term I think you're looking for is a 'cherry pick'. That is, take a single commit from the middle of one branch and add it to another:</p> <pre><code>A-----B------C \ \ D </code></pre> <p>becomes</p> <pre><code>A-----B------C \ \ D-----C' </code></pre> <p>This, of course, can be done with the git...
<p>The term I think you're looking for is a 'cherry pick'. That is, take a single commit from the middle of one branch and add it to another:</p> <pre><code>A-----B------C \ \ D </code></pre> <p>becomes</p> <pre><code>A-----B------C \ \ D-----C' </code></pre> <p>This, of course, can be done with the git...
119, 1879
branch, git
<h1>Pull all commits from a branch, push specified commits to another</h1> <p>I have the following branches:</p> <ul> <li><code>master</code></li> <li><code>production</code></li> </ul> <p>and the following remote branches:</p> <ul> <li><code>origin/master</code></li> <li><code>origin/production</code></li> </ul> <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,591
git
# Pull all commits from a branch, push specified commits to another I have the following branches: - `master` - `production` and the following remote branches: - `origin/master` - `origin/production` I have a script that fetches the `origin/master` branch and gets the diff of what changed from my last fetch (`log ...
The term I think you're looking for is a 'cherry pick'. That is, take a single commit from the middle of one branch and add it to another: ``` A-----B------C \ \ D ``` becomes ``` A-----B------C \ \ D-----C' ``` This, of course, can be done with the git cherry-pick command. The problem with this commit...
1241720
Git Cherry-pick vs Merge Workflow
349
2009-08-06 21:50:25
<p>Assuming I am the maintainer of a repo, and I want to pull in changes from a contributor, there are a few possible workflows:</p> <ol> <li>I <code>cherry-pick</code> each commit from the remote (in order). In this case git records the commit as unrelated to the remote branch.</li> <li>I <code>merge</code> the branc...
196,361
64,313
2017-12-13 06:10:38
1,241,829
349
2009-08-06 22:14:19
29,057
2009-08-06 22:26:20
https://stackoverflow.com/q/1241720
https://stackoverflow.com/a/1241829
<p>Both <code>rebase</code> (and <code>cherry-pick</code>) and <code>merge</code> have their advantages and disadvantages. I argue for <code>merge</code> here, but it's worth understanding both. (Look here for an alternate, well-argued <a href="https://stackoverflow.com/questions/457927/git-workflow-and-rebase-vs-mer...
<p>Both <code>rebase</code> (and <code>cherry-pick</code>) and <code>merge</code> have their advantages and disadvantages. I argue for <code>merge</code> here, but it's worth understanding both. (Look here for an alternate, well-argued <a href="https://stackoverflow.com/questions/457927/git-workflow-and-rebase-vs-mer...
119, 717, 36489
cherry-pick, git, merge
<h1>Git Cherry-pick vs Merge Workflow</h1> <p>Assuming I am the maintainer of a repo, and I want to pull in changes from a contributor, there are a few possible workflows:</p> <ol> <li>I <code>cherry-pick</code> each commit from the remote (in order). In this case git records the commit as unrelated to the remote bran...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,592
git
# Git Cherry-pick vs Merge Workflow Assuming I am the maintainer of a repo, and I want to pull in changes from a contributor, there are a few possible workflows: 1. I `cherry-pick` each commit from the remote (in order). In this case git records the commit as unrelated to the remote branch. 2. I `merge` the branch, p...
Both `rebase` (and `cherry-pick`) and `merge` have their advantages and disadvantages. I argue for `merge` here, but it's worth understanding both. (Look here for an alternate, well-argued [answer](https://stackoverflow.com/questions/457927/git-workflow-and-rebase-vs-merge-questions) enumerating cases where `rebase` is...
727994
Skipping specific commits when merging
254
2009-04-07 23:32:54
<p>I have two Git branches called <code>master10</code> (for v1) and <code>master20</code> (for v2). I've been making bug fixes in v1 on branch <code>master10</code>, and developing new stuff of <code>master20</code>. Whenever I make a bug fix I merge it into v2 by checking out <code>master20</code> and doing <code>git...
98,597
77,002
2024-08-16 09:54:47
729,723
349
2009-04-08 12:26:14
85,134
2020-07-08 19:14:41
https://stackoverflow.com/q/727994
https://stackoverflow.com/a/729723
<p>If you want to merge most but not all of the commits on branch &quot;maint&quot; to &quot;master&quot;, for instance, you can do this. It requires some work---- as mentioned above, the usual use case is to merge everything from a branch--- but sometimes it happens that you made a change to a release version that sho...
<p>If you want to merge most but not all of the commits on branch &quot;maint&quot; to &quot;master&quot;, for instance, you can do this. It requires some work---- as mentioned above, the usual use case is to merge everything from a branch--- but sometimes it happens that you made a change to a release version that sho...
119, 456, 28897
git, git-merge, version-control
<h1>Skipping specific commits when merging</h1> <p>I have two Git branches called <code>master10</code> (for v1) and <code>master20</code> (for v2). I've been making bug fixes in v1 on branch <code>master10</code>, and developing new stuff of <code>master20</code>. Whenever I make a bug fix I merge it into v2 by checki...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,593
git
# Skipping specific commits when merging I have two Git branches called `master10` (for v1) and `master20` (for v2). I've been making bug fixes in v1 on branch `master10`, and developing new stuff of `master20`. Whenever I make a bug fix I merge it into v2 by checking out `master20` and doing `git merge master10`. So ...
If you want to merge most but not all of the commits on branch "maint" to "master", for instance, you can do this. It requires some work---- as mentioned above, the usual use case is to merge everything from a branch--- but sometimes it happens that you made a change to a release version that shouldn't be integrated ba...
6899582
I change the capitalization of a directory and Git doesn't seem to pick up on it
342
2011-08-01 14:04:25
<p>I'm developing a project on OS X Lion that is under Git version control. I had these lowercase directories and then later capitalized them (e.g. emailaddresses => EmailAddresses), but Git doesn't seem to recognize the change. It still thinks the directories are lowercase when I run <code>git ls-files</code> and othe...
148,450
232,417
2020-07-17 05:14:03
6,899,682
346
2011-08-01 14:11:22
253,056
2011-08-01 14:11:22
https://stackoverflow.com/q/6899582
https://stackoverflow.com/a/6899682
<p>You're probably using case insensitive (but case preserving) HFS+. I usually work round this like so:</p> <pre><code>$ git mv somename tmpname $ git mv tmpname SomeName </code></pre>
<p>You're probably using case insensitive (but case preserving) HFS+. I usually work round this like so:</p> <pre><code>$ git mv somename tmpname $ git mv tmpname SomeName </code></pre>
119, 369
git, macos
<h1>I change the capitalization of a directory and Git doesn't seem to pick up on it</h1> <p>I'm developing a project on OS X Lion that is under Git version control. I had these lowercase directories and then later capitalized them (e.g. emailaddresses => EmailAddresses), but Git doesn't seem to recognize the change. I...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,598
git
# I change the capitalization of a directory and Git doesn't seem to pick up on it I'm developing a project on OS X Lion that is under Git version control. I had these lowercase directories and then later capitalized them (e.g. emailaddresses => EmailAddresses), but Git doesn't seem to recognize the change. It still t...
You're probably using case insensitive (but case preserving) HFS+. I usually work round this like so: ``` $ git mv somename tmpname $ git mv tmpname SomeName ```
426026
Git on Windows: How do you set up a mergetool?
384
2009-01-08 21:24:49
<p>I've tried msysGit and Git on Cygwin. Both work just fine in and of themselves and both run gitk and git-gui perfectly.</p> <p>Now how the heck do I configure a mergetool? (Vimdiff works on Cygwin, but preferably I would like something a little more user-friendly for some of our Windows-loving coworkers.)</p>
315,762
10,675
2020-07-03 14:48:07
436,040
345
2009-01-12 16:41:52
23,843
2014-07-10 15:18:45
https://stackoverflow.com/q/426026
https://stackoverflow.com/a/436040
<p>To follow-up on Charles Bailey's answer, here's my git setup that's using <a href="http://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools" rel="noreferrer">p4merge</a> (free cross-platform 3way merge tool); tested on msys Git (Windows) install:</p> <pre><code>git config --global merge.tool ...
<p>To follow-up on Charles Bailey's answer, here's my git setup that's using <a href="http://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools" rel="noreferrer">p4merge</a> (free cross-platform 3way merge tool); tested on msys Git (Windows) install:</p> <pre><code>git config --global merge.tool ...
64, 119, 1731, 21628
cygwin, git, msysgit, windows
<h1>Git on Windows: How do you set up a mergetool?</h1> <p>I've tried msysGit and Git on Cygwin. Both work just fine in and of themselves and both run gitk and git-gui perfectly.</p> <p>Now how the heck do I configure a mergetool? (Vimdiff works on Cygwin, but preferably I would like something a little more user-frien...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,600
git
# Git on Windows: How do you set up a mergetool? I've tried msysGit and Git on Cygwin. Both work just fine in and of themselves and both run gitk and git-gui perfectly. Now how the heck do I configure a mergetool? (Vimdiff works on Cygwin, but preferably I would like something a little more user-friendly for some of ...
To follow-up on Charles Bailey's answer, here's my git setup that's using [p4merge](http://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools) (free cross-platform 3way merge tool); tested on msys Git (Windows) install: ``` git config --global merge.tool p4merge git config --global mergetool.p4me...
6941889
Is it safe to shallow clone with --depth 1, create commits, and pull updates again?
320
2011-08-04 13:02:41
<p>The <code>--depth 1</code> option in <a href="http://git-scm.com/docs/git-clone" rel="noreferrer"><code>git clone</code></a>:</p> <blockquote> <p>Create a <em>shallow</em> clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fet...
203,510
623,519
2020-04-01 15:35:57
21,217,267
345
2014-01-19 13:19:51
6,309
2020-04-01 15:35:57
https://stackoverflow.com/q/6941889
https://stackoverflow.com/a/21217267
<p>Note that Git 1.9/2.0 (Q1 2014) has <em>removed</em> that limitation.<br> See <a href="https://github.com/git/git/commit/82fba2b9d39163a0c9b7a3a2f35964cbc039e1a" rel="noreferrer">commit 82fba2b</a>, from <a href="https://github.com/pclouds" rel="noreferrer">Nguyễn Thái Ngọc Duy (<code>pclouds</code>)</a>:</p> <bloc...
<p>Note that Git 1.9/2.0 (Q1 2014) has <em>removed</em> that limitation.<br> See <a href="https://github.com/git/git/commit/82fba2b9d39163a0c9b7a3a2f35964cbc039e1a" rel="noreferrer">commit 82fba2b</a>, from <a href="https://github.com/pclouds" rel="noreferrer">Nguyễn Thái Ngọc Duy (<code>pclouds</code>)</a>:</p> <bloc...
119, 598, 34099
git, git-clone, performance
<h1>Is it safe to shallow clone with --depth 1, create commits, and pull updates again?</h1> <p>The <code>--depth 1</code> option in <a href="http://git-scm.com/docs/git-clone" rel="noreferrer"><code>git clone</code></a>:</p> <blockquote> <p>Create a <em>shallow</em> clone with a history truncated to the specified n...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,601
git
# Is it safe to shallow clone with --depth 1, create commits, and pull updates again? The `--depth 1` option in [`git clone`](http://git-scm.com/docs/git-clone): > Create a *shallow* clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone...
Note that Git 1.9/2.0 (Q1 2014) has *removed* that limitation. See [commit 82fba2b](https://github.com/git/git/commit/82fba2b9d39163a0c9b7a3a2f35964cbc039e1a), from [Nguyễn Thái Ngọc Duy (`pclouds`)](https://github.com/pclouds): > Now that git supports data transfer from or to a shallow clone, these limitations are ...
1440050
How to split the last commit into two in Git?
291
2009-09-17 16:53:15
<p>I have two branches, <code>master</code> and <code>forum</code>, and I've just made some modifications in <code>forum</code> that I'd like to cherry-pick into <code>master</code>. But unfortunately, the commit I want to cherry-pick also contains some modifications that I don't want.</p> <p>The solution would probabl...
93,858
72,583
2022-11-15 16:30:26
1,440,200
343
2009-09-17 17:23:16
17,916
2012-10-25 12:44:08
https://stackoverflow.com/q/1440050
https://stackoverflow.com/a/1440200
<p>You should use the index. After doing a mixed reset ("<a href="http://git-scm.com/docs/git-reset" rel="noreferrer">git reset</a> HEAD^"), add the first set of changes into the index, then commit them. Then commit the rest.</p> <p>You can use "<a href="http://git-scm.com/docs/git-add" rel="noreferrer">git add</a>" t...
<p>You should use the index. After doing a mixed reset ("<a href="http://git-scm.com/docs/git-reset" rel="noreferrer">git reset</a> HEAD^"), add the first set of changes into the index, then commit them. Then commit the rest.</p> <p>You can use "<a href="http://git-scm.com/docs/git-add" rel="noreferrer">git add</a>" t...
119, 456
git, version-control
<h1>How to split the last commit into two in Git?</h1> <p>I have two branches, <code>master</code> and <code>forum</code>, and I've just made some modifications in <code>forum</code> that I'd like to cherry-pick into <code>master</code>. But unfortunately, the commit I want to cherry-pick also contains some modificatio...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,602
git
# How to split the last commit into two in Git? I have two branches, `master` and `forum`, and I've just made some modifications in `forum` that I'd like to cherry-pick into `master`. But unfortunately, the commit I want to cherry-pick also contains some modifications that I don't want. The solution would probably be...
You should use the index. After doing a mixed reset ("[git reset](http://git-scm.com/docs/git-reset) HEAD^"), add the first set of changes into the index, then commit them. Then commit the rest. You can use "[git add](http://git-scm.com/docs/git-add)" to put all changes made in a file to the index. If you don't want t...
3404294
Merging 2 branches together in Git
277
2010-08-04 09:40:42
<p>I've only just started to use Git and think it is wonderful, however I'm a little confused over what the <code>merge</code> command does.</p> <p>Let us say we have a working project in the branch &quot;A&quot;.</p> <p>I go home and make changes to this branch and save it as &quot;B&quot;. Another programmer makes ch...
620,260
164,230
2024-09-25 07:43:43
3,404,410
343
2010-08-04 09:58:05
112,968
2024-09-25 07:43:43
https://stackoverflow.com/q/3404294
https://stackoverflow.com/a/3404410
<p><a href="https://git-scm.com/docs/git-merge" rel="noreferrer"><code>merge</code></a> is used to bring two (or more) branches together.</p> <p>A little example:</p> <pre><code>$ # on branch A: $ # create new branch B $ git checkout -b B $ # edit files $ git commit -am &quot;commit on branch B&quot; $ # create new br...
<p><a href="https://git-scm.com/docs/git-merge" rel="noreferrer"><code>merge</code></a> is used to bring two (or more) branches together.</p> <p>A little example:</p> <pre><code>$ # on branch A: $ # create new branch B $ git checkout -b B $ # edit files $ git commit -am &quot;commit on branch B&quot; $ # create new br...
119, 717, 5597
commit, git, merge
<h1>Merging 2 branches together in Git</h1> <p>I've only just started to use Git and think it is wonderful, however I'm a little confused over what the <code>merge</code> command does.</p> <p>Let us say we have a working project in the branch &quot;A&quot;.</p> <p>I go home and make changes to this branch and save it a...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,603
git
# Merging 2 branches together in Git I've only just started to use Git and think it is wonderful, however I'm a little confused over what the `merge` command does. Let us say we have a working project in the branch "A". I go home and make changes to this branch and save it as "B". Another programmer makes changes to...
[`merge`](https://git-scm.com/docs/git-merge) is used to bring two (or more) branches together. A little example: ``` $ # on branch A: $ # create new branch B $ git checkout -b B $ # edit files $ git commit -am "commit on branch B" $ # create new branch C from A $ git checkout -b C A $ # edit files $ git commit -am ...
7297379
How do you rebase the current branch's changes on top of changes being merged in?
223
2011-09-04 04:14:57
<p>Okay. If I'm on a branch (say <code>working</code>), and I want to merge in the changes from another branch (say <code>master</code>), then I run the command <code>git-merge master</code> while on the <code>working</code> branch, and the changes get merged in without rebasing the history at all. If I run <code>git-r...
397,301
160,887
2023-09-06 12:18:31
7,297,393
343
2011-09-04 04:18:29
152,948
2011-09-04 04:18:29
https://stackoverflow.com/q/7297379
https://stackoverflow.com/a/7297393
<p>You've got what <code>rebase</code> does backwards. <code>git rebase master</code> does what you're asking for — takes the changes on the current branch (since its divergence from master) and replays them on top of <code>master</code>, then sets the head of the current branch to be the head of that new history. It <...
<p>You've got what <code>rebase</code> does backwards. <code>git rebase master</code> does what you're asking for — takes the changes on the current branch (since its divergence from master) and replays them on top of <code>master</code>, then sets the head of the current branch to be the head of that new history. It <...
119, 717, 8974, 29934
git, git-rebase, merge, rebase
<h1>How do you rebase the current branch's changes on top of changes being merged in?</h1> <p>Okay. If I'm on a branch (say <code>working</code>), and I want to merge in the changes from another branch (say <code>master</code>), then I run the command <code>git-merge master</code> while on the <code>working</code> bran...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,604
git
# How do you rebase the current branch's changes on top of changes being merged in? Okay. If I'm on a branch (say `working`), and I want to merge in the changes from another branch (say `master`), then I run the command `git-merge master` while on the `working` branch, and the changes get merged in without rebasing th...
You've got what `rebase` does backwards. `git rebase master` does what you're asking for — takes the changes on the current branch (since its divergence from master) and replays them on top of `master`, then sets the head of the current branch to be the head of that new history. It *doesn't* replay the changes from `ma...
3489173
How to clone git repository with specific revision/changeset?
572
2010-08-15 20:45:53
<p>How can I clone git repository with specific revision, something like I usually do in Mercurial:</p> <pre><code>hg clone -r 3 /path/to/repository </code></pre>
827,814
421,182
2025-07-01 13:33:46
3,489,576
342
2010-08-15 22:40:47
19,563
2020-12-01 14:36:45
https://stackoverflow.com/q/3489173
https://stackoverflow.com/a/3489576
<p><strong>UPDATE 2</strong> Since <a href="https://github.com/git/git/blob/master/Documentation/RelNotes/2.5.0.txt" rel="noreferrer">Git 2.5.0</a> the feature described below can be enabled on server side with configuration variable <strong><code>uploadpack.allowReachableSHA1InWant</code></strong>, here the <a href="h...
<p><strong>UPDATE 2</strong> Since <a href="https://github.com/git/git/blob/master/Documentation/RelNotes/2.5.0.txt" rel="noreferrer">Git 2.5.0</a> the feature described below can be enabled on server side with configuration variable <strong><code>uploadpack.allowReachableSHA1InWant</code></strong>, here the <a href="h...
119, 1555, 34099
git, git-clone, revision
<h1>How to clone git repository with specific revision/changeset?</h1> <p>How can I clone git repository with specific revision, something like I usually do in Mercurial:</p> <pre><code>hg clone -r 3 /path/to/repository </code></pre>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,605
git
# How to clone git repository with specific revision/changeset? How can I clone git repository with specific revision, something like I usually do in Mercurial: ``` hg clone -r 3 /path/to/repository ```
**UPDATE 2** Since [Git 2.5.0](https://github.com/git/git/blob/master/Documentation/RelNotes/2.5.0.txt) the feature described below can be enabled on server side with configuration variable **`uploadpack.allowReachableSHA1InWant`**, here the [GitHub feature request](https://github.com/isaacs/github/issues/436) and the ...
20028507
Git stash uncached: how to put away all unstaged changes?
318
2013-11-17 07:53:27
<p>Suppose two set of changes are made in a project versioned by git. One set is staged and the other is not.</p> <p>I would like to recheck staged changes by running my project at this state (before commit). <strong>What is a simple way to put away all unstaged changes and leave only staged?</strong> So I need unstag...
132,789
747,050
2025-05-19 14:17:01
20,028,585
342
2013-11-17 08:05:54
2,149,092
2024-12-10 15:57:23
https://stackoverflow.com/q/20028507
https://stackoverflow.com/a/20028585
<p><strong>Update 2:</strong><br /> I'm not sure why people are complaining about this answer, it seems to be working perfectly with me.</p> <p>To stash only unstaged changes:</p> <pre><code>git stash --keep-index # or shorter: git stash -k </code></pre> <p>For untracked files you can add the <code>-u</code> flag. The ...
<p><strong>Update 2:</strong><br /> I'm not sure why people are complaining about this answer, it seems to be working perfectly with me.</p> <p>To stash only unstaged changes:</p> <pre><code>git stash --keep-index # or shorter: git stash -k </code></pre> <p>For untracked files you can add the <code>-u</code> flag. The ...
119, 13091
git, git-stash
<h1>Git stash uncached: how to put away all unstaged changes?</h1> <p>Suppose two set of changes are made in a project versioned by git. One set is staged and the other is not.</p> <p>I would like to recheck staged changes by running my project at this state (before commit). <strong>What is a simple way to put away al...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,606
git
# Git stash uncached: how to put away all unstaged changes? Suppose two set of changes are made in a project versioned by git. One set is staged and the other is not. I would like to recheck staged changes by running my project at this state (before commit). **What is a simple way to put away all unstaged changes and...
**Update 2:** I'm not sure why people are complaining about this answer, it seems to be working perfectly with me. To stash only unstaged changes: ``` git stash --keep-index # or shorter: git stash -k ``` For untracked files you can add the `-u` flag. The full command becomes `git stash --keep-index -u`. And here...
7194877
How make Eclipse/EGit recognize existing repository information after update?
219
2011-08-11 12:06:47
<p>After upgrading Eclipse from Helios to Indigo with EGit plugin 1.0.0, all my projects seem to have lost their metadata about their git repositories, respectively.</p> <p>In Helios, every Eclipse project was a git repository on its own. When updating to Indigo, i hoped i could continue using the workspace from Helio...
90,326
342,546
2025-07-23 19:33:20
7,194,878
342
2011-08-12 08:37:31
342,546
2011-08-12 08:37:31
https://stackoverflow.com/q/7194877
https://stackoverflow.com/a/7194878
<p>Thanks to Jeremy, i found how to reactivate the repos myself. Basically, two steps were required:</p> <ol> <li>Add the (already existing) local repository to EGit's <code>Git Repositories</code> view;</li> <li>"Share" each of the projects again using "use or create repository".</li> </ol> <p>The second step won't ...
<p>Thanks to Jeremy, i found how to reactivate the repos myself. Basically, two steps were required:</p> <ol> <li>Add the (already existing) local repository to EGit's <code>Git Repositories</code> view;</li> <li>"Share" each of the projects again using "use or create repository".</li> </ol> <p>The second step won't ...
53, 119
eclipse, git
<h1>How make Eclipse/EGit recognize existing repository information after update?</h1> <p>After upgrading Eclipse from Helios to Indigo with EGit plugin 1.0.0, all my projects seem to have lost their metadata about their git repositories, respectively.</p> <p>In Helios, every Eclipse project was a git repository on it...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,608
git
# How make Eclipse/EGit recognize existing repository information after update? After upgrading Eclipse from Helios to Indigo with EGit plugin 1.0.0, all my projects seem to have lost their metadata about their git repositories, respectively. In Helios, every Eclipse project was a git repository on its own. When upda...
Thanks to Jeremy, i found how to reactivate the repos myself. Basically, two steps were required: 1. Add the (already existing) local repository to EGit's `Git Repositories` view; 2. "Share" each of the projects again using "use or create repository". The second step won't work if the repo isn't available in the repo...
12082981
Get all git commits since last tag
202
2012-08-22 23:53:49
<p>When I'm going to tag a commit, I need to know what changed since the last tagged commit. Eg:</p> <pre><code>a87a6sdf87a6d4 Some new feature a87a6sdf87a6d3 Some bug fix a87a6sdf87a6d2 Some comments added a87a6sdf87a6d1 Some merge &lt;- v1.4.0 </code></pre> <p>In this example I would like to know about the 3 newest...
103,633
1,502,830
2025-03-11 15:43:47
12,083,016
342
2012-08-22 23:59:02
365,237
2023-06-30 10:04:37
https://stackoverflow.com/q/12082981
https://stackoverflow.com/a/12083016
<pre><code>git log &lt;yourlasttag&gt;..HEAD </code></pre> <p>If you want them like in your example, on the one line with commit id + message, then</p> <pre><code>git log &lt;yourlasttag&gt;..HEAD --oneline </code></pre> <p>and in case you don't know your latest tag or want this to be dynamic, on Linux / git bash / Win...
<pre><code>git log &lt;yourlasttag&gt;..HEAD </code></pre> <p>If you want them like in your example, on the one line with commit id + message, then</p> <pre><code>git log &lt;yourlasttag&gt;..HEAD --oneline </code></pre> <p>and in case you don't know your latest tag or want this to be dynamic, on Linux / git bash / Win...
119, 456
git, version-control
<h1>Get all git commits since last tag</h1> <p>When I'm going to tag a commit, I need to know what changed since the last tagged commit. Eg:</p> <pre><code>a87a6sdf87a6d4 Some new feature a87a6sdf87a6d3 Some bug fix a87a6sdf87a6d2 Some comments added a87a6sdf87a6d1 Some merge &lt;- v1.4.0 </code></pre> <p>In this exa...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,609
git
# Get all git commits since last tag When I'm going to tag a commit, I need to know what changed since the last tagged commit. Eg: ``` a87a6sdf87a6d4 Some new feature a87a6sdf87a6d3 Some bug fix a87a6sdf87a6d2 Some comments added a87a6sdf87a6d1 Some merge <- v1.4.0 ``` In this example I would like to know about the ...
``` git log <yourlasttag>..HEAD ``` If you want them like in your example, on the one line with commit id + message, then ``` git log <yourlasttag>..HEAD --oneline ``` and in case you don't know your latest tag or want this to be dynamic, on Linux / git bash / Windows bash you could do: ``` git log $(git describe -...
14970728
Homebrew’s `git` not using completion
187
2013-02-20 01:24:05
<p>When using OSX’s git, after I modify a file I can simply do <code>git commit &lt;tab&gt;</code>, and that’ll auto complete the file’s name to the one that was modified. However, if I install a newer version of git from homebrew and I use it, that feature no longer works (meaning I press <code>&lt;tab&gt;</code> and ...
76,851
1,661,012
2022-04-12 21:12:30
14,970,926
341
2013-02-20 01:47:11
434,004
2019-01-31 06:03:40
https://stackoverflow.com/q/14970728
https://stackoverflow.com/a/14970926
<p>You're looking for:</p> <pre><code>brew install git bash-completion </code></pre> <p>As warpc's comment states, you'll need to add the following to your <code>~/.bash_profile</code> to get homebrew's bash-completion working:</p> <pre><code>if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix...
<p>You're looking for:</p> <pre><code>brew install git bash-completion </code></pre> <p>As warpc's comment states, you'll need to add the following to your <code>~/.bash_profile</code> to get homebrew's bash-completion working:</p> <pre><code>if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix...
119, 369, 3791, 4682
autocomplete, git, macos, zsh
<h1>Homebrew’s `git` not using completion</h1> <p>When using OSX’s git, after I modify a file I can simply do <code>git commit &lt;tab&gt;</code>, and that’ll auto complete the file’s name to the one that was modified. However, if I install a newer version of git from homebrew and I use it, that feature no longer works...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,610
git
# Homebrew’s `git` not using completion When using OSX’s git, after I modify a file I can simply do `git commit <tab>`, and that’ll auto complete the file’s name to the one that was modified. However, if I install a newer version of git from homebrew and I use it, that feature no longer works (meaning I press `<tab>` ...
You're looking for: ``` brew install git bash-completion ``` As warpc's comment states, you'll need to add the following to your `~/.bash_profile` to get homebrew's bash-completion working: ``` if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi ``` The above is mentio...
999907
git push says "everything up-to-date" even though I have local changes
358
2009-06-16 07:01:16
<p>I have a remote gitosis server and a local git repository, and each time I make a big change in my code, I'll push the changes to that server too. </p> <p>But today I find that even though I have some local changes and commit to local repository, when running <code>git push origin master</code> it says 'Everything ...
518,346
111,896
2025-06-27 19:42:25
1,000,009
340
2009-06-16 07:32:54
6,309
2022-04-06 19:46:14
https://stackoverflow.com/q/999907
https://stackoverflow.com/a/1000009
<p>Are you working with a <a href="https://stackoverflow.com/questions/896832/in-gitk-why-is-my-yellow-button-above-master">detached head</a> by any chance?</p> <p>As in:</p> <p><img src="https://i.sstatic.net/bFqgC.jpg" alt="detached head" /></p> <p>indicating that your latest commit is not a branch head.</p> <p><stro...
<p>Are you working with a <a href="https://stackoverflow.com/questions/896832/in-gitk-why-is-my-yellow-button-above-master">detached head</a> by any chance?</p> <p>As in:</p> <p><img src="https://i.sstatic.net/bFqgC.jpg" alt="detached head" /></p> <p>indicating that your latest commit is not a branch head.</p> <p><stro...
119, 24526
git, gitosis
<h1>git push says "everything up-to-date" even though I have local changes</h1> <p>I have a remote gitosis server and a local git repository, and each time I make a big change in my code, I'll push the changes to that server too. </p> <p>But today I find that even though I have some local changes and commit to local r...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,611
git
# git push says "everything up-to-date" even though I have local changes I have a remote gitosis server and a local git repository, and each time I make a big change in my code, I'll push the changes to that server too. But today I find that even though I have some local changes and commit to local repository, when r...
Are you working with a [detached head](https://stackoverflow.com/questions/896832/in-gitk-why-is-my-yellow-button-above-master) by any chance? As in: ![detached head](https://i.sstatic.net/bFqgC.jpg) indicating that your latest commit is not a branch head. **Warning**: the following does a [`git reset --hard`](http...
746684
How to search through all Git and Mercurial commits in the repository for a certain string?
307
2009-04-14 07:49:49
<p>I have a Git repository with few branches and dangling commits. I would like to search all such commits in repository for a specific string.</p> <p>I know how to get a log of all commits in history, but these don't include branches or dangling blobs, just HEAD's history. I want to get them all, to find a specific c...
138,174
85,055
2023-09-29 13:04:58
746,790
340
2009-04-14 08:53:11
4,596
2011-01-13 20:17:12
https://stackoverflow.com/q/746684
https://stackoverflow.com/a/746790
<p>You can see dangling commits with <code>git log -g</code>.</p> <pre><code>-g, --walk-reflogs Instead of walking the commit ancestry chain, walk reflog entries from the most recent one to older ones. </code></pre> <p>So you could do this to find a particular string in a commit message that is dangling:</p> <pre...
<p>You can see dangling commits with <code>git log -g</code>.</p> <pre><code>-g, --walk-reflogs Instead of walking the commit ancestry chain, walk reflog entries from the most recent one to older ones. </code></pre> <p>So you could do this to find a particular string in a commit message that is dangling:</p> <pre...
119, 802
git, mercurial
<h1>How to search through all Git and Mercurial commits in the repository for a certain string?</h1> <p>I have a Git repository with few branches and dangling commits. I would like to search all such commits in repository for a specific string.</p> <p>I know how to get a log of all commits in history, but these don't ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,612
git
# How to search through all Git and Mercurial commits in the repository for a certain string? I have a Git repository with few branches and dangling commits. I would like to search all such commits in repository for a specific string. I know how to get a log of all commits in history, but these don't include branches...
You can see dangling commits with `git log -g`. ``` -g, --walk-reflogs Instead of walking the commit ancestry chain, walk reflog entries from the most recent one to older ones. ``` So you could do this to find a particular string in a commit message that is dangling: ``` git log -g --grep=search_for_this ``` Alte...
22906851
When would you use .git/info/exclude instead of .gitignore to exclude files?
264
2014-04-07 08:09:36
<p>I am a bit confused about the pros and cons of using <code>.git/info/exclude</code> and <code>.gitignore</code> to exclude files.</p> <p>Both of them are at the level of the repository/project, so how do they differ and when should we use <code>.git/info/exclude</code> ?</p>
85,413
34,956
2022-10-06 22:01:58
22,906,964
340
2014-04-07 08:15:28
1,860,929
2022-10-06 22:01:58
https://stackoverflow.com/q/22906851
https://stackoverflow.com/a/22906964
<p>The first advantage of <code>.gitignore</code> is that it is versioned into the repository itself, unlike <code>.git/info/exclude</code>. The second advantage is that you can have multiple <code>.gitignore</code> files, one per directory/subdirectory, for directory specific ignore rules, unlike <code>.git/info/exclu...
<p>The first advantage of <code>.gitignore</code> is that it is versioned into the repository itself, unlike <code>.git/info/exclude</code>. The second advantage is that you can have multiple <code>.gitignore</code> files, one per directory/subdirectory, for directory specific ignore rules, unlike <code>.git/info/exclu...
119, 25056
git, gitignore
<h1>When would you use .git/info/exclude instead of .gitignore to exclude files?</h1> <p>I am a bit confused about the pros and cons of using <code>.git/info/exclude</code> and <code>.gitignore</code> to exclude files.</p> <p>Both of them are at the level of the repository/project, so how do they differ and when shoul...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,613
git
# When would you use .git/info/exclude instead of .gitignore to exclude files? I am a bit confused about the pros and cons of using `.git/info/exclude` and `.gitignore` to exclude files. Both of them are at the level of the repository/project, so how do they differ and when should we use `.git/info/exclude` ?
The first advantage of `.gitignore` is that it is versioned into the repository itself, unlike `.git/info/exclude`. The second advantage is that you can have multiple `.gitignore` files, one per directory/subdirectory, for directory specific ignore rules, unlike `.git/info/exclude`. So the `.gitignore` files are versi...
39930664
How to install a pod from a specific branch?
167
2016-10-08 09:14:14
<p>I'm trying add add a pod by cocoapods, and I am using swift 3, while the pod(<a href="https://github.com/stephencelis/SQLite.swift/tree/master" rel="noreferrer">SQlite.swift</a>).</p> <p>I am trying to use doesn't have a master of the latest swift version, however there is a <a href="https://github.com/stephencelis...
102,611
5,531,816
2022-12-22 03:58:06
39,930,762
340
2016-10-08 09:24:54
6,309
2018-08-29 17:58:21
https://stackoverflow.com/q/39930664
https://stackoverflow.com/a/39930762
<p>The <a href="http://guides.cocoapods.org/using/the-podfile.html#from-a-podspec-in-the-root-of-a-library-repo" rel="noreferrer">podfile guide</a> mentions the following syntax:</p> <blockquote> <p>To use a different branch of the repo:</p> </blockquote> <pre><code>pod 'Alamofire', :git =&gt; 'https://github.com/A...
<p>The <a href="http://guides.cocoapods.org/using/the-podfile.html#from-a-podspec-in-the-root-of-a-library-repo" rel="noreferrer">podfile guide</a> mentions the following syntax:</p> <blockquote> <p>To use a different branch of the repo:</p> </blockquote> <pre><code>pod 'Alamofire', :git =&gt; 'https://github.com/A...
119, 908, 77741, 120609
cocoapods, git, podfile, xcode
<h1>How to install a pod from a specific branch?</h1> <p>I'm trying add add a pod by cocoapods, and I am using swift 3, while the pod(<a href="https://github.com/stephencelis/SQLite.swift/tree/master" rel="noreferrer">SQlite.swift</a>).</p> <p>I am trying to use doesn't have a master of the latest swift version, howev...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,614
git
# How to install a pod from a specific branch? I'm trying add add a pod by cocoapods, and I am using swift 3, while the pod([SQlite.swift](https://github.com/stephencelis/SQLite.swift/tree/master)). I am trying to use doesn't have a master of the latest swift version, however there is a [branch](https://github.com/st...
The [podfile guide](http://guides.cocoapods.org/using/the-podfile.html#from-a-podspec-in-the-root-of-a-library-repo) mentions the following syntax: > To use a different branch of the repo: ``` pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'dev' ...
18810623
Git diff to show only lines that have been modified
257
2013-09-15 08:55:30
<p>When I do a git diff, it shows lines that have been added:</p> <pre><code>+ this line is added </code></pre> <p>lines that have been removed:</p> <pre><code>- this line is removed </code></pre> <p>but it also shows many lines which are not modified:</p> <pre><code>this line is not modified this line is also not modi...
129,854
2,680,864
2025-04-22 07:55:22
18,810,673
338
2013-09-15 09:02:30
1,813,853
2024-04-21 12:49:50
https://stackoverflow.com/q/18810623
https://stackoverflow.com/a/18810673
<p>What you want is a diff with 0 lines of context. You can generate this with:</p> <pre><code>git diff --unified=0 </code></pre> <p>or</p> <pre><code>git diff -U0 </code></pre> <p>You can also set this as a config option for that repository:</p> <pre><code>git config diff.context 0 </code></pre> <p>To have it set glob...
<p>What you want is a diff with 0 lines of context. You can generate this with:</p> <pre><code>git diff --unified=0 </code></pre> <p>or</p> <pre><code>git diff -U0 </code></pre> <p>You can also set this as a config option for that repository:</p> <pre><code>git config diff.context 0 </code></pre> <p>To have it set glob...
119, 606
diff, git
<h1>Git diff to show only lines that have been modified</h1> <p>When I do a git diff, it shows lines that have been added:</p> <pre><code>+ this line is added </code></pre> <p>lines that have been removed:</p> <pre><code>- this line is removed </code></pre> <p>but it also shows many lines which are not modified:</p> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,617
git
# Git diff to show only lines that have been modified When I do a git diff, it shows lines that have been added: ``` + this line is added ``` lines that have been removed: ``` - this line is removed ``` but it also shows many lines which are not modified: ``` this line is not modified this line is also not modifi...
What you want is a diff with 0 lines of context. You can generate this with: ``` git diff --unified=0 ``` or ``` git diff -U0 ``` You can also set this as a config option for that repository: ``` git config diff.context 0 ``` To have it set globally, for any repository: ``` git config --global diff.context 0 ```
10972289
How to change SmartGit's licensing option after 30 days of commercial use on ubuntu?
133
2012-06-10 20:56:42
<p>while installing smartgit 3.0.4 I checked the commercial licensing option, because I was just clicking "next" button : ) (30 day trial and then you have to buy it). Now today is my 31st day of using SG and I can't change my licensing options (reinstalling smartgit doesn't help) and I'm not able to use SG anymore wit...
252,403
1,353,905
2025-04-24 01:20:02
14,228,485
338
2013-01-09 04:54:59
241,552
2021-01-14 13:05:35
https://stackoverflow.com/q/10972289
https://stackoverflow.com/a/14228485
<p>I went on the internet and I found this:</p> <p>To alter the license. First, go to</p> <p>Windows: <code>%APPDATA%\syntevo\SmartGit&amp;lt;main-smartgit-version&gt;</code></p> <p>Windows portable: <code>SmartGit\.settings\preferences.yml</code></p> <p>OS X: <code>~/Library/Preferences/SmartGit/&lt;main-smartgit-vers...
<p>I went on the internet and I found this:</p> <p>To alter the license. First, go to</p> <p>Windows: <code>%APPDATA%\syntevo\SmartGit&amp;lt;main-smartgit-version&gt;</code></p> <p>Windows portable: <code>SmartGit\.settings\preferences.yml</code></p> <p>OS X: <code>~/Library/Preferences/SmartGit/&lt;main-smartgit-vers...
119, 65939
git, smartgit
<h1>How to change SmartGit's licensing option after 30 days of commercial use on ubuntu?</h1> <p>while installing smartgit 3.0.4 I checked the commercial licensing option, because I was just clicking "next" button : ) (30 day trial and then you have to buy it). Now today is my 31st day of using SG and I can't change my...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,618
git
# How to change SmartGit's licensing option after 30 days of commercial use on ubuntu? while installing smartgit 3.0.4 I checked the commercial licensing option, because I was just clicking "next" button : ) (30 day trial and then you have to buy it). Now today is my 31st day of using SG and I can't change my licensin...
I went on the internet and I found this: To alter the license. First, go to Windows: `%APPDATA%\syntevo\SmartGit&lt;main-smartgit-version>` Windows portable: `SmartGit\.settings\preferences.yml` OS X: `~/Library/Preferences/SmartGit/<main-smartgit-version>` Unix/Linux: `~/.smartgit/<main-smartgit-version>` and re...
8247605
Configuring so that pip install can work from github
268
2011-11-23 18:56:54
<p>We'd like to use pip with github to install private packages to our production servers. This question concerns what needs to be in the github repo in order for the install to be successful.</p> <p>Assuming the following command line (which authenticates just fine and tries to install):</p> <pre><code>pip install ...
185,723
380,362
2023-07-17 01:28:46
8,256,424
337
2011-11-24 11:40:39
565,999
2023-07-17 01:28:46
https://stackoverflow.com/q/8247605
https://stackoverflow.com/a/8256424
<p>You need the whole python package, with a <code>setup.py</code> file in it.</p> <p>A package named <code>foo</code> would be:</p> <pre><code>foo # the installable package ├── foo │   ├── __init__.py │   └── bar.py └── setup.py </code></pre> <p>And install from github like:</p> <pre><code>$ pip install git+ssh://git@...
<p>You need the whole python package, with a <code>setup.py</code> file in it.</p> <p>A package named <code>foo</code> would be:</p> <pre><code>foo # the installable package ├── foo │   ├── __init__.py │   └── bar.py └── setup.py </code></pre> <p>And install from github like:</p> <pre><code>$ pip install git+ssh://git@...
16, 119, 5119
git, pip, python
<h1>Configuring so that pip install can work from github</h1> <p>We'd like to use pip with github to install private packages to our production servers. This question concerns what needs to be in the github repo in order for the install to be successful.</p> <p>Assuming the following command line (which authenticates...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,619
git
# Configuring so that pip install can work from github We'd like to use pip with github to install private packages to our production servers. This question concerns what needs to be in the github repo in order for the install to be successful. Assuming the following command line (which authenticates just fine and tr...
You need the whole python package, with a `setup.py` file in it. A package named `foo` would be: ``` foo # the installable package ├── foo │   ├── __init__.py │   └── bar.py └── setup.py ``` And install from github like: ``` $ pip install git+ssh://git@github.com/myuser/foo.git or $ pip install git+https://github.c...
7259535
Setting up a git remote origin
203
2011-08-31 15:36:20
<p>I have the following repos.</p> <ol> <li>DEV REPO: in a directory on my development machine where i make changes</li> <li>MAIN REPO: bare repository on my development machine to which i push changes from dev repo</li> <li>PRODUCTION REPO: repository on host machine to pull updates from the main repo</li> </ol> <p>...
295,060
488,856
2016-04-25 08:16:49
7,259,583
336
2011-08-31 15:39:25
135,494
2015-03-15 19:08:41
https://stackoverflow.com/q/7259535
https://stackoverflow.com/a/7259583
<p>Using SSH</p> <pre><code>git remote add origin ssh://login@IP/path/to/repository </code></pre> <p>Using HTTP</p> <pre><code>git remote add origin http://IP/path/to/repository </code></pre> <p>However having a simple <code>git pull</code> as a deployment process is usually a <strong>bad idea</strong> and should b...
<p>Using SSH</p> <pre><code>git remote add origin ssh://login@IP/path/to/repository </code></pre> <p>Using HTTP</p> <pre><code>git remote add origin http://IP/path/to/repository </code></pre> <p>However having a simple <code>git pull</code> as a deployment process is usually a <strong>bad idea</strong> and should b...
119
git
<h1>Setting up a git remote origin</h1> <p>I have the following repos.</p> <ol> <li>DEV REPO: in a directory on my development machine where i make changes</li> <li>MAIN REPO: bare repository on my development machine to which i push changes from dev repo</li> <li>PRODUCTION REPO: repository on host machine to pull up...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,620
git
# Setting up a git remote origin I have the following repos. 1. DEV REPO: in a directory on my development machine where i make changes 2. MAIN REPO: bare repository on my development machine to which i push changes from dev repo 3. PRODUCTION REPO: repository on host machine to pull updates from the main repo I use...
Using SSH ``` git remote add origin ssh://login@IP/path/to/repository ``` Using HTTP ``` git remote add origin http://IP/path/to/repository ``` However having a simple `git pull` as a deployment process is usually a **bad idea** and should be avoided in favor of a real deployment script.
5139290
How to check if there's nothing to be committed in the current branch?
288
2011-02-28 07:34:59
<p>The goal is to get an unambiguous status that can be evaluated in a shell command.</p> <p>I tried <code>git status</code> but it always returns 0, even if there are items to commit.</p> <pre class="lang-bash prettyprint-override"><code>git status echo $? #this is always 0 </code></pre> <p>I have an idea but I think...
131,631
576,472
2023-12-05 16:54:56
5,139,672
335
2011-02-28 08:31:14
223,092
2011-02-28 11:34:12
https://stackoverflow.com/q/5139290
https://stackoverflow.com/a/5139672
<p>An alternative to testing whether the output of <code>git status --porcelain</code> is empty is to test each condition you care about separately. One might not always care, for example, if there are untracked files in the output of <code>git status</code>.</p> <p>For example, to see if there are any local unstaged...
<p>An alternative to testing whether the output of <code>git status --porcelain</code> is empty is to test each condition you care about separately. One might not always care, for example, if there are untracked files in the output of <code>git status</code>.</p> <p>For example, to see if there are any local unstaged...
119, 54839
git, git-status
<h1>How to check if there's nothing to be committed in the current branch?</h1> <p>The goal is to get an unambiguous status that can be evaluated in a shell command.</p> <p>I tried <code>git status</code> but it always returns 0, even if there are items to commit.</p> <pre class="lang-bash prettyprint-override"><code>g...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,622
git
# How to check if there's nothing to be committed in the current branch? The goal is to get an unambiguous status that can be evaluated in a shell command. I tried `git status` but it always returns 0, even if there are items to commit. ``` git status echo $? #this is always 0 ``` I have an idea but I think it is ...
An alternative to testing whether the output of `git status --porcelain` is empty is to test each condition you care about separately. One might not always care, for example, if there are untracked files in the output of `git status`. For example, to see if there are any local unstaged changes, you can look at the ret...
18115411
How to merge specific files from Git branches
338
2013-08-07 23:22:18
<p>I have 2 git branches:</p> <ol> <li><strong>branch1</strong></li> <li><strong>branch2</strong></li> </ol> <p>I want to merge <em>all the history (multiple commits) of <code>file.py</code> in <strong>branch2</strong></em> into <code>file.py</code> in <strong>branch1</strong> and only that file.</p> <p>In essence I ju...
327,964
2,186,160
2026-01-16 19:32:41
33,168,094
334
2015-10-16 10:21:45
3,636,464
2019-09-26 16:05:37
https://stackoverflow.com/q/18115411
https://stackoverflow.com/a/33168094
<p>When content is in <code>file.py</code> from <strong>branch2</strong> that is no longer applies to <strong>branch1</strong>, it requires picking some changes and leaving others. For full control do an interactive merge using the <code>--patch</code> switch:</p> <pre><code>$ git checkout --patch branch2 file.py </co...
<p>When content is in <code>file.py</code> from <strong>branch2</strong> that is no longer applies to <strong>branch1</strong>, it requires picking some changes and leaving others. For full control do an interactive merge using the <code>--patch</code> switch:</p> <pre><code>$ git checkout --patch branch2 file.py </co...
119, 28897
git, git-merge
<h1>How to merge specific files from Git branches</h1> <p>I have 2 git branches:</p> <ol> <li><strong>branch1</strong></li> <li><strong>branch2</strong></li> </ol> <p>I want to merge <em>all the history (multiple commits) of <code>file.py</code> in <strong>branch2</strong></em> into <code>file.py</code> in <strong>bran...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,624
git
# How to merge specific files from Git branches I have 2 git branches: 1. **branch1** 2. **branch2** I want to merge *all the history (multiple commits) of `file.py` in **branch2*** into `file.py` in **branch1** and only that file. In essence I just want to work on the `file.py` in **branch1** but want to take adva...
When content is in `file.py` from **branch2** that is no longer applies to **branch1**, it requires picking some changes and leaving others. For full control do an interactive merge using the `--patch` switch: ``` $ git checkout --patch branch2 file.py ``` The interactive mode section in the man page for `git-add(1)`...
4624357
How do I 'overwrite', rather than 'merge', a branch on another branch in Git?
412
2011-01-07 10:01:54
<p>I have two branches, <code>email</code> and <code>staging</code>. <code>staging</code> is the latest one and I no longer need the old changes in <code>email</code> branch, yet I don't want to delete them.</p> <p>So I just want to dump all the contents of <code>staging</code> into <code>email</code> so that they bot...
415,833
196,697
2024-08-26 15:28:28
4,624,383
333
2011-01-07 10:06:10
112,968
2024-03-12 07:47:05
https://stackoverflow.com/q/4624357
https://stackoverflow.com/a/4624383
<p>You can use the <a href="https://git-scm.com/docs/git-merge#Documentation/git-merge.txt-ours" rel="noreferrer">'ours' merge strategy</a>:</p> <pre><code>$ git checkout staging $ git merge -s ours email # Merge branches, but use our (=staging) branch head $ git checkout email $ git merge staging </code></pre> <hr /> ...
<p>You can use the <a href="https://git-scm.com/docs/git-merge#Documentation/git-merge.txt-ours" rel="noreferrer">'ours' merge strategy</a>:</p> <pre><code>$ git checkout staging $ git merge -s ours email # Merge branches, but use our (=staging) branch head $ git checkout email $ git merge staging </code></pre> <hr /> ...
119, 28897
git, git-merge
<h1>How do I 'overwrite', rather than 'merge', a branch on another branch in Git?</h1> <p>I have two branches, <code>email</code> and <code>staging</code>. <code>staging</code> is the latest one and I no longer need the old changes in <code>email</code> branch, yet I don't want to delete them.</p> <p>So I just want to...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,625
git
# How do I 'overwrite', rather than 'merge', a branch on another branch in Git? I have two branches, `email` and `staging`. `staging` is the latest one and I no longer need the old changes in `email` branch, yet I don't want to delete them. So I just want to dump all the contents of `staging` into `email` so that the...
You can use the ['ours' merge strategy](https://git-scm.com/docs/git-merge#Documentation/git-merge.txt-ours): ``` $ git checkout staging $ git merge -s ours email # Merge branches, but use our (=staging) branch head $ git checkout email $ git merge staging ``` --- The question requires the commits of the `email` bra...
21101572
Difference between file in local repository and origin
269
2014-01-13 21:19:27
<p>I want to find the differences between a file I have in my local repository vs. what is in the <code>origin master</code>.</p> <p>I know that there is <code>git diff</code>. However, I just want to isolate it down to this one particular file.</p> <p>For simplicity, let’s say the file is named <code>file1.txt</code> ...
421,921
2,020,869
2023-07-30 10:54:28
21,101,689
333
2014-01-13 21:25:55
1,440,565
2017-06-29 17:25:46
https://stackoverflow.com/q/21101572
https://stackoverflow.com/a/21101689
<p>If <code>[remote-path]</code> and <code>[local-path]</code> are the same, you can do</p> <pre><code>$ git fetch origin master $ git diff origin/master -- [local-path] </code></pre> <p><strong>Note 1:</strong> The second command above will compare against the locally stored remote tracking branch. The fetch command...
<p>If <code>[remote-path]</code> and <code>[local-path]</code> are the same, you can do</p> <pre><code>$ git fetch origin master $ git diff origin/master -- [local-path] </code></pre> <p><strong>Note 1:</strong> The second command above will compare against the locally stored remote tracking branch. The fetch command...
119, 9033
git, git-diff
<h1>Difference between file in local repository and origin</h1> <p>I want to find the differences between a file I have in my local repository vs. what is in the <code>origin master</code>.</p> <p>I know that there is <code>git diff</code>. However, I just want to isolate it down to this one particular file.</p> <p>For...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,626
git
# Difference between file in local repository and origin I want to find the differences between a file I have in my local repository vs. what is in the `origin master`. I know that there is `git diff`. However, I just want to isolate it down to this one particular file. For simplicity, let’s say the file is named `f...
If `[remote-path]` and `[local-path]` are the same, you can do ``` $ git fetch origin master $ git diff origin/master -- [local-path] ``` **Note 1:** The second command above will compare against the locally stored remote tracking branch. The fetch command is required to update the remote tracking branch to be in syn...
17267218
Perforce for Git users?
174
2013-06-24 02:24:42
<p>There is a lot of "Git for Perforce users" documentation out there, but seemingly very little of the opposite.</p> <p>I have only used Git previously and recently started a job where I have to use Perforce a lot, and find myself getting very confused a lot of the time. The concepts I'm used to from Git seem not to ...
61,432
242,814
2019-03-19 13:00:25
17,331,274
333
2013-06-26 22:04:03
502,497
2019-03-19 13:00:25
https://stackoverflow.com/q/17267218
https://stackoverflow.com/a/17331274
<p>This something I've been working on over the past couple weeks on and off. It's still evolving, but it may be helpful. Please note I'm a Perforce employee.</p> <h1>An intro to Perforce for Git users</h1> <p>To say that moving from Git to Perforce or from Perforce to Git is non-trivial is a grand understatement. Fo...
<p>This something I've been working on over the past couple weeks on and off. It's still evolving, but it may be helpful. Please note I'm a Perforce employee.</p> <h1>An intro to Perforce for Git users</h1> <p>To say that moving from Git to Perforce or from Perforce to Git is non-trivial is a grand understatement. Fo...
119, 1286
git, perforce
<h1>Perforce for Git users?</h1> <p>There is a lot of "Git for Perforce users" documentation out there, but seemingly very little of the opposite.</p> <p>I have only used Git previously and recently started a job where I have to use Perforce a lot, and find myself getting very confused a lot of the time. The concepts ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,627
git
# Perforce for Git users? There is a lot of "Git for Perforce users" documentation out there, but seemingly very little of the opposite. I have only used Git previously and recently started a job where I have to use Perforce a lot, and find myself getting very confused a lot of the time. The concepts I'm used to from...
This something I've been working on over the past couple weeks on and off. It's still evolving, but it may be helpful. Please note I'm a Perforce employee. # An intro to Perforce for Git users To say that moving from Git to Perforce or from Perforce to Git is non-trivial is a grand understatement. For being two tools...
35245658
"You must type a file name" error thrown, when I create a .gitignore file on Windows
137
2016-02-06 19:49:05
<p>When I try to do this, I get the following error:</p> <p><a href="https://i.sstatic.net/IJxts.png"><img src="https://i.sstatic.net/IJxts.png" alt="gitignore error"></a></p> <p>Obviously, Windows Explorer doesn't allow me to create this type of file patterns. How can I overcome this problem?</p>
47,579
6,999,882
2022-06-29 16:21:09
35,246,741
333
2016-02-06 21:34:56
717,372
2022-06-29 16:21:09
https://stackoverflow.com/q/35245658
https://stackoverflow.com/a/35246741
<p>In the File Explorer, the trick is to call your file <code>.gitignore.</code> and it will remove the ending <code>.</code></p> <p>A strange behavior but, hey!, it works 😅</p> <p>Or create it from a text editor...</p>
<p>In the File Explorer, the trick is to call your file <code>.gitignore.</code> and it will remove the ending <code>.</code></p> <p>A strange behavior but, hey!, it works 😅</p> <p>Or create it from a text editor...</p>
64, 119, 25056
git, gitignore, windows
<h1>"You must type a file name" error thrown, when I create a .gitignore file on Windows</h1> <p>When I try to do this, I get the following error:</p> <p><a href="https://i.sstatic.net/IJxts.png"><img src="https://i.sstatic.net/IJxts.png" alt="gitignore error"></a></p> <p>Obviously, Windows Explorer doesn't allow me ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,628
git
# "You must type a file name" error thrown, when I create a .gitignore file on Windows When I try to do this, I get the following error: [![gitignore error](https://i.sstatic.net/IJxts.png)](https://i.sstatic.net/IJxts.png) Obviously, Windows Explorer doesn't allow me to create this type of file patterns. How can I ...
In the File Explorer, the trick is to call your file `.gitignore.` and it will remove the ending `.` A strange behavior but, hey!, it works 😅 Or create it from a text editor...
21676150
Setup git in Intellij terminal
129
2014-02-10 11:38:13
<p>I want to use git in Intellij Terminal but it does not recognize the command. In Command Prompt and Windows power shell the command in recognized (I added the git path in System Environment Variables). I am also aware that Intellij has an GUI integration with Git.</p> <p>So, can anyone tell me how can I use the git...
155,963
2,302,448
2022-08-27 15:56:39
29,347,211
333
2015-03-30 13:14:53
4,490,860
2022-03-09 19:26:28
https://stackoverflow.com/q/21676150
https://stackoverflow.com/a/29347211
<p><strong>Setup JetBrains(InteliJ, WebStorm, PHPStorm) IDE terminal to use GIT bash</strong></p> <ul> <li>File</li> <li>Settings</li> <li>(Enter 'Terminal' in search)</li> <li>Change Shell path to:</li> </ul> <pre><code>&quot;C:\Program Files\Git\bin\sh.exe&quot; --login -i </code></pre> <p>or</p> <pre><code>&quot;C:\...
<p><strong>Setup JetBrains(InteliJ, WebStorm, PHPStorm) IDE terminal to use GIT bash</strong></p> <ul> <li>File</li> <li>Settings</li> <li>(Enter 'Terminal' in search)</li> <li>Change Shell path to:</li> </ul> <pre><code>&quot;C:\Program Files\Git\bin\sh.exe&quot; --login -i </code></pre> <p>or</p> <pre><code>&quot;C:\...
64, 119, 8945
git, intellij-idea, windows
<h1>Setup git in Intellij terminal</h1> <p>I want to use git in Intellij Terminal but it does not recognize the command. In Command Prompt and Windows power shell the command in recognized (I added the git path in System Environment Variables). I am also aware that Intellij has an GUI integration with Git.</p> <p>So, ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,629
git
# Setup git in Intellij terminal I want to use git in Intellij Terminal but it does not recognize the command. In Command Prompt and Windows power shell the command in recognized (I added the git path in System Environment Variables). I am also aware that Intellij has an GUI integration with Git. So, can anyone tell ...
**Setup JetBrains(InteliJ, WebStorm, PHPStorm) IDE terminal to use GIT bash** - File - Settings - (Enter 'Terminal' in search) - Change Shell path to: ``` "C:\Program Files\Git\bin\sh.exe" --login -i ``` or ``` "C:\Program Files\Git\bin\bash.exe" ``` If you have another directory for installed git change it respec...
18779442
Error while pull from git - insufficient permission for adding an object to repository database .git/objects
152
2013-09-13 06:15:01
<p>I have git error: "insufficient permission for adding an object to repository database .git/objects" every time I make "git pull origin develop".</p> <pre><code> remote: Counting objects: 70, done. remote: Compressing objects: 100% (7/7), done. remote: Total 42 (delta 35), reused 42 (delta 35) error:...
100,076
2,431,113
2023-03-16 10:08:21
19,801,059
332
2013-11-05 23:20:31
1,349,518
2016-12-15 23:25:33
https://stackoverflow.com/q/18779442
https://stackoverflow.com/a/19801059
<p>Assuming @ChrisHayes is right about an accidental sudo, this should fix it. From inside your repository:</p> <pre><code>sudo chown -R $USER:$USER "$(git rev-parse --show-toplevel)/.git" </code></pre> <p><strong>Update</strong>: for those of you getting the <code>illegal group name</code> error, try this instead:</...
<p>Assuming @ChrisHayes is right about an accidental sudo, this should fix it. From inside your repository:</p> <pre><code>sudo chown -R $USER:$USER "$(git rev-parse --show-toplevel)/.git" </code></pre> <p><strong>Update</strong>: for those of you getting the <code>illegal group name</code> error, try this instead:</...
119
git
<h1>Error while pull from git - insufficient permission for adding an object to repository database .git/objects</h1> <p>I have git error: "insufficient permission for adding an object to repository database .git/objects" every time I make "git pull origin develop".</p> <pre><code> remote: Counting objects: 70, don...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,630
git
# Error while pull from git - insufficient permission for adding an object to repository database .git/objects I have git error: "insufficient permission for adding an object to repository database .git/objects" every time I make "git pull origin develop". ``` remote: Counting objects: 70, done. remote: Compr...
Assuming @ChrisHayes is right about an accidental sudo, this should fix it. From inside your repository: ``` sudo chown -R $USER:$USER "$(git rev-parse --show-toplevel)/.git" ``` **Update**: for those of you getting the `illegal group name` error, try this instead: ``` sudo chown -R $(id -u):$(id -g) "$(git rev-pars...
29673869
What is fast-forwarding?
354
2015-04-16 11:51:29
<p>Is it OK to assume that fast-forward means all commits are replayed on the target branch and the <code>HEAD</code> is set to the last commit on that branch?</p>
430,416
1,278,730
2024-09-24 22:36:16
29,673,993
331
2015-04-16 11:56:24
515,034
2023-10-08 05:23:40
https://stackoverflow.com/q/29673869
https://stackoverflow.com/a/29673993
<p>When you try to merge one commit with a commit that can be reached by following the first commit’s history, Git simplifies things by moving the pointer forward, because there isn't any divergent work to merge together—this is called a <code>fast-forward</code>.</p> <p>For more: <em><a href="http://git-scm.com/book/e...
<p>When you try to merge one commit with a commit that can be reached by following the first commit’s history, Git simplifies things by moving the pointer forward, because there isn't any divergent work to merge together—this is called a <code>fast-forward</code>.</p> <p>For more: <em><a href="http://git-scm.com/book/e...
119, 52842
fast-forward, git
<h1>What is fast-forwarding?</h1> <p>Is it OK to assume that fast-forward means all commits are replayed on the target branch and the <code>HEAD</code> is set to the last commit on that branch?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,631
git
# What is fast-forwarding? Is it OK to assume that fast-forward means all commits are replayed on the target branch and the `HEAD` is set to the last commit on that branch?
When you try to merge one commit with a commit that can be reached by following the first commit’s history, Git simplifies things by moving the pointer forward, because there isn't any divergent work to merge together—this is called a `fast-forward`. For more: *[3.2 Git Branching - Basic Branching and Merging](http://...
6276752
Can I split an already split hunk with git?
261
2011-06-08 09:34:18
<p>I've recently discovered git's <code>patch</code> option to the <code>add</code> command, and I must say it really is a fantastic feature. I also discovered that a large hunk could be split into smaller hunks by hitting the <kbd>s</kbd> key, which adds to the precision of the commit. But what if I want even more pre...
64,323
353,612
2024-04-24 11:47:13
6,290,646
331
2011-06-09 09:22:06
223,092
2024-04-24 11:44:53
https://stackoverflow.com/q/6276752
https://stackoverflow.com/a/6290646
<p>If you're using <code>git add -p</code> and even after splitting with <kbd>s</kbd>, you don't have a small enough change, you can use <kbd>e</kbd> to edit the patch directly.</p> <p>This can be a little confusing, but if you <em><strong>carefully</strong></em> follow the instructions in the editor window that will b...
<p>If you're using <code>git add -p</code> and even after splitting with <kbd>s</kbd>, you don't have a small enough change, you can use <kbd>e</kbd> to edit the patch directly.</p> <p>This can be a little confusing, but if you <em><strong>carefully</strong></em> follow the instructions in the editor window that will b...
119, 2132, 2193, 14215
addition, git, patch, split
<h1>Can I split an already split hunk with git?</h1> <p>I've recently discovered git's <code>patch</code> option to the <code>add</code> command, and I must say it really is a fantastic feature. I also discovered that a large hunk could be split into smaller hunks by hitting the <kbd>s</kbd> key, which adds to the prec...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,632
git
# Can I split an already split hunk with git? I've recently discovered git's `patch` option to the `add` command, and I must say it really is a fantastic feature. I also discovered that a large hunk could be split into smaller hunks by hitting the `s` key, which adds to the precision of the commit. But what if I want ...
If you're using `git add -p` and even after splitting with `s`, you don't have a small enough change, you can use `e` to edit the patch directly. This can be a little confusing, but if you ***carefully*** follow the instructions in the editor window that will be opened up after pressing `e` then you'll be fine. In the...
4981126
How to amend several commits in Git to change author
337
2011-02-12 22:48:01
<p>I have made a series of commits in Git and I realise now that I forgot to set my user name and user email properties correctly (new machine). I have not yet pushed these commits to my repository, so how can I correct these commits before I do so (only the 3 latest commits on the master branch)?</p> <p>I have been ...
139,777
755
2024-09-12 02:53:46
4,982,271
330
2011-02-13 03:33:19
119,963
2022-01-22 18:27:26
https://stackoverflow.com/q/4981126
https://stackoverflow.com/a/4982271
<p><em><strong>Warning: now <a href="https://git-scm.com/docs/git-filter-branch#_warning" rel="noreferrer">deprecated</a> in favor of <a href="https://stackoverflow.com/questions/4981126/how-to-amend-several-commits-in-git-to-change-author/69947947#69947947">filter-repo</a>.</strong></em></p> <p>Rebase/amend seems inef...
<p><em><strong>Warning: now <a href="https://git-scm.com/docs/git-filter-branch#_warning" rel="noreferrer">deprecated</a> in favor of <a href="https://stackoverflow.com/questions/4981126/how-to-amend-several-commits-in-git-to-change-author/69947947#69947947">filter-repo</a>.</strong></em></p> <p>Rebase/amend seems inef...
119, 53850, 91259
git, git-commit, git-rewrite-history
<h1>How to amend several commits in Git to change author</h1> <p>I have made a series of commits in Git and I realise now that I forgot to set my user name and user email properties correctly (new machine). I have not yet pushed these commits to my repository, so how can I correct these commits before I do so (only th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,635
git
# How to amend several commits in Git to change author I have made a series of commits in Git and I realise now that I forgot to set my user name and user email properties correctly (new machine). I have not yet pushed these commits to my repository, so how can I correct these commits before I do so (only the 3 latest...
***Warning: now [deprecated](https://git-scm.com/docs/git-filter-branch#_warning) in favor of [filter-repo](https://stackoverflow.com/questions/4981126/how-to-amend-several-commits-in-git-to-change-author/69947947#69947947).*** Rebase/amend seems inefficient, when you have the power of filter-branch at your fingertips...
20537223
What is the intended use-case for git stash?
276
2013-12-12 07:15:04
<p>If I work on branch A and suddenly need to work on branch B before being ready with a commit on branch A, I stash my changes on A, checkout B, do my work there, then checkout A and apply the stash.</p> <p>If I work on A and I want to stop working for the day, should I stash my work and then apply it the next day (wh...
259,119
1,836,143
2025-08-25 05:25:34
20,537,356
330
2013-12-12 07:22:10
2,422,776
2020-05-14 17:57:43
https://stackoverflow.com/q/20537223
https://stackoverflow.com/a/20537356
<p>Stash is just a convenience method. Since branches are so cheap and easy to manage in git, I personally almost always prefer creating a new temporary branch than stashing, but it's a matter of taste mostly.</p> <p>The one place I do like stashing is if I discover I forgot something in my last commit and have alread...
<p>Stash is just a convenience method. Since branches are so cheap and easy to manage in git, I personally almost always prefer creating a new temporary branch than stashing, but it's a matter of taste mostly.</p> <p>The one place I do like stashing is if I discover I forgot something in my last commit and have alread...
119, 13091
git, git-stash
<h1>What is the intended use-case for git stash?</h1> <p>If I work on branch A and suddenly need to work on branch B before being ready with a commit on branch A, I stash my changes on A, checkout B, do my work there, then checkout A and apply the stash.</p> <p>If I work on A and I want to stop working for the day, sho...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,636
git
# What is the intended use-case for git stash? If I work on branch A and suddenly need to work on branch B before being ready with a commit on branch A, I stash my changes on A, checkout B, do my work there, then checkout A and apply the stash. If I work on A and I want to stop working for the day, should I stash my ...
Stash is just a convenience method. Since branches are so cheap and easy to manage in git, I personally almost always prefer creating a new temporary branch than stashing, but it's a matter of taste mostly. The one place I do like stashing is if I discover I forgot something in my last commit and have already started ...
17857723
What's the difference between git reflog and log?
262
2013-07-25 12:13:48
<p>The man page says that log shows the commit logs and reflog manages reflog information. What exactly is reflog information and what does it have that the log doesn't? The log seems far more detailed.</p>
139,093
427,653
2020-07-31 20:56:56
17,860,179
329
2013-07-25 14:01:13
46,545
2016-05-20 08:46:11
https://stackoverflow.com/q/17857723
https://stackoverflow.com/a/17860179
<p><code>git log</code> shows the current HEAD and its ancestry. That is, it prints the commit HEAD points to, then its parent, its parent, and so on. It traverses back through the repo's ancestry, by recursively looking up each commit's parent.</p> <p><em>(In practice, some commits have more than one parent. To see a...
<p><code>git log</code> shows the current HEAD and its ancestry. That is, it prints the commit HEAD points to, then its parent, its parent, and so on. It traverses back through the repo's ancestry, by recursively looking up each commit's parent.</p> <p><em>(In practice, some commits have more than one parent. To see a...
119, 47913, 79719
git, git-log, git-reflog
<h1>What's the difference between git reflog and log?</h1> <p>The man page says that log shows the commit logs and reflog manages reflog information. What exactly is reflog information and what does it have that the log doesn't? The log seems far more detailed.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,637
git
# What's the difference between git reflog and log? The man page says that log shows the commit logs and reflog manages reflog information. What exactly is reflog information and what does it have that the log doesn't? The log seems far more detailed.
`git log` shows the current HEAD and its ancestry. That is, it prints the commit HEAD points to, then its parent, its parent, and so on. It traverses back through the repo's ancestry, by recursively looking up each commit's parent. *(In practice, some commits have more than one parent. To see a more representative log...
7446640
Adding Only Untracked Files
220
2011-09-16 15:01:40
<p>One of the commands I find incredibly useful in Git is <code>git add -u</code> to throw everything but untracked files into the index. Is there an inverse of that?</p> <p>Such as a way to add <strong>only</strong> the untracked files to the index <em>without identifying them individually</em>?</p>
162,874
1,665
2023-09-12 06:54:12
7,446,711
329
2011-09-16 15:06:40
635,608
2017-08-17 20:29:30
https://stackoverflow.com/q/7446640
https://stackoverflow.com/a/7446711
<p>It's easy with <code>git add -i</code>. Type <code>a</code> (for "add untracked"), then <code>*</code> (for "all"), then <code>q</code> (to quit) and you're done.</p> <p>To do it with a single command: <code>echo -e "a\n*\nq\n"|git add -i</code></p>
<p>It's easy with <code>git add -i</code>. Type <code>a</code> (for "add untracked"), then <code>*</code> (for "all"), then <code>q</code> (to quit) and you're done.</p> <p>To do it with a single command: <code>echo -e "a\n*\nq\n"|git add -i</code></p>
119, 34792
git, git-add
<h1>Adding Only Untracked Files</h1> <p>One of the commands I find incredibly useful in Git is <code>git add -u</code> to throw everything but untracked files into the index. Is there an inverse of that?</p> <p>Such as a way to add <strong>only</strong> the untracked files to the index <em>without identifying them indi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,638
git
# Adding Only Untracked Files One of the commands I find incredibly useful in Git is `git add -u` to throw everything but untracked files into the index. Is there an inverse of that? Such as a way to add **only** the untracked files to the index *without identifying them individually*?
It's easy with `git add -i`. Type `a` (for "add untracked"), then `*` (for "all"), then `q` (to quit) and you're done. To do it with a single command: `echo -e "a\n*\nq\n"|git add -i`
2788092
Start a Git commit message with a hashmark (#)
424
2010-05-07 11:19:37
<p>Git treats lines starting with <code>#</code> (hash, number sign, octothorpe, pound sign) as comment lines when committing. This is very annoying when working with a ticket tracking system, and trying to write the ticket number at the beginning of the line, e.g.</p> <pre><code>#123 salt hashed passwords </code></pre...
103,726
112,968
2024-04-07 04:40:27
2,788,642
328
2010-05-07 12:55:04
19,563
2010-05-07 12:55:04
https://stackoverflow.com/q/2788092
https://stackoverflow.com/a/2788642
<p>This behaviour is part of <code>git commit</code>'s default 'clean-up' behaviour. If you want to keep lines starting with <code>#</code> you can use an alternative clean-up mode.</p> <p>E.g.</p> <pre><code>git commit --cleanup=whitespace </code></pre> <p>If you do this you have to be careful to remove all <code>#...
<p>This behaviour is part of <code>git commit</code>'s default 'clean-up' behaviour. If you want to keep lines starting with <code>#</code> you can use an alternative clean-up mode.</p> <p>E.g.</p> <pre><code>git commit --cleanup=whitespace </code></pre> <p>If you do this you have to be careful to remove all <code>#...
119, 3629, 5597, 56095
commit, git, ticket-system, ticket-tracking
<h1>Start a Git commit message with a hashmark (#)</h1> <p>Git treats lines starting with <code>#</code> (hash, number sign, octothorpe, pound sign) as comment lines when committing. This is very annoying when working with a ticket tracking system, and trying to write the ticket number at the beginning of the line, e.g...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,639
git
# Start a Git commit message with a hashmark (#) Git treats lines starting with `#` (hash, number sign, octothorpe, pound sign) as comment lines when committing. This is very annoying when working with a ticket tracking system, and trying to write the ticket number at the beginning of the line, e.g. ``` #123 salt has...
This behaviour is part of `git commit`'s default 'clean-up' behaviour. If you want to keep lines starting with `#` you can use an alternative clean-up mode. E.g. ``` git commit --cleanup=whitespace ``` If you do this you have to be careful to remove all `#` lines that you don't want to appear in the commit.
4873980
Git diff says subproject is dirty
315
2011-02-02 11:36:50
<p>I have just run a git diff, and I am getting the following output for all of my approx 10 submodules </p> <pre><code>diff --git a/.vim/bundle/bufexplorer b/.vim/bundle/bufexplorer --- a/.vim/bundle/bufexplorer +++ b/.vim/bundle/bufexplorer @@ -1 +1 @@ -Subproject commit 8c75e65b647238febd0257658b150f717a136359 +Sub...
178,995
527,749
2025-10-08 21:46:05
4,874,323
328
2011-02-02 12:13:19
6,309
2021-01-28 21:26:30
https://stackoverflow.com/q/4873980
https://stackoverflow.com/a/4874323
<p>Update Jan. 2021, ten years later:</p> <p>&quot;<a href="https://github.com/git/git/blob/080627942802e767b068a491f3d349227f4e2cdc/Documentation/git-diff.txt" rel="noreferrer"><code>git diff</code></a>&quot;<sup>(<a href="https://git-scm.com/docs/git-diff" rel="noreferrer">man</a>)</sup> showed a submodule working tr...
<p>Update Jan. 2021, ten years later:</p> <p>&quot;<a href="https://github.com/git/git/blob/080627942802e767b068a491f3d349227f4e2cdc/Documentation/git-diff.txt" rel="noreferrer"><code>git diff</code></a>&quot;<sup>(<a href="https://git-scm.com/docs/git-diff" rel="noreferrer">man</a>)</sup> showed a submodule working tr...
119, 41612
git, git-submodules
<h1>Git diff says subproject is dirty</h1> <p>I have just run a git diff, and I am getting the following output for all of my approx 10 submodules </p> <pre><code>diff --git a/.vim/bundle/bufexplorer b/.vim/bundle/bufexplorer --- a/.vim/bundle/bufexplorer +++ b/.vim/bundle/bufexplorer @@ -1 +1 @@ -Subproject commit 8c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,640
git
# Git diff says subproject is dirty I have just run a git diff, and I am getting the following output for all of my approx 10 submodules ``` diff --git a/.vim/bundle/bufexplorer b/.vim/bundle/bufexplorer --- a/.vim/bundle/bufexplorer +++ b/.vim/bundle/bufexplorer @@ -1 +1 @@ -Subproject commit 8c75e65b647238febd02576...
Update Jan. 2021, ten years later: "[`git diff`](https://github.com/git/git/blob/080627942802e767b068a491f3d349227f4e2cdc/Documentation/git-diff.txt)"([man](https://git-scm.com/docs/git-diff)) showed a submodule working tree with untracked cruft as Submodule commit `<objectname>-dirty`, but a natural expectation is th...
12470029
How to commit no change and new message?
265
2012-09-18 03:33:57
<p>How can I make a new <code>commit</code> and create a new message if no changes are made to files?</p> <p>Is this not possible since the commit's code (SHA ?) will be the same?</p>
171,127
1,166,285
2024-06-10 14:37:33
12,470,056
328
2012-09-18 03:38:07
1,426,891
2024-06-10 14:37:33
https://stackoverflow.com/q/12470029
https://stackoverflow.com/a/12470056
<p>The parameter is <code>--allow-empty</code> for empty commits (no files changed), in contrast to <code>--allow-empty-message</code> for empty commit messages. You can also read more by typing <code>git help commit</code> or visiting <a href="http://www.kernel.org/pub/software/scm/git/docs/git-commit.html" rel="noref...
<p>The parameter is <code>--allow-empty</code> for empty commits (no files changed), in contrast to <code>--allow-empty-message</code> for empty commit messages. You can also read more by typing <code>git help commit</code> or visiting <a href="http://www.kernel.org/pub/software/scm/git/docs/git-commit.html" rel="noref...
119, 5597
commit, git
<h1>How to commit no change and new message?</h1> <p>How can I make a new <code>commit</code> and create a new message if no changes are made to files?</p> <p>Is this not possible since the commit's code (SHA ?) will be the same?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,641
git
# How to commit no change and new message? How can I make a new `commit` and create a new message if no changes are made to files? Is this not possible since the commit's code (SHA ?) will be the same?
The parameter is `--allow-empty` for empty commits (no files changed), in contrast to `--allow-empty-message` for empty commit messages. You can also read more by typing `git help commit` or visiting [the online documentation](http://www.kernel.org/pub/software/scm/git/docs/git-commit.html). While the tree object (whi...
366860
When would you use the different git merge strategies?
469
2008-12-14 19:12:11
<p>From the man page on git-merge, there are a number of merge strategies you can use. </p> <ul> <li><p><em>resolve</em> - This can only resolve two heads (i.e. the current branch and another branch you pulled from) using 3-way merge algorithm. It tries to carefully detect criss-cross merge ambiguities and is consid...
158,916
9,594
2021-02-07 00:47:16
366,940
327
2008-12-14 20:25:49
39,975
2016-01-13 23:06:20
https://stackoverflow.com/q/366860
https://stackoverflow.com/a/366940
<p>I'm not familiar with resolve, but I've used the others:</p> <h2>Recursive</h2> <p>Recursive is the default for non-fast-forward merges. We're all familiar with that one.</p> <h2>Octopus</h2> <p>I've used octopus when I've had several trees that needed to be merged. You see this in larger projects where many br...
<p>I'm not familiar with resolve, but I've used the others:</p> <h2>Recursive</h2> <p>Recursive is the default for non-fast-forward merges. We're all familiar with that one.</p> <h2>Octopus</h2> <p>I've used octopus when I've had several trees that needed to be merged. You see this in larger projects where many br...
119, 717, 28897
git, git-merge, merge
<h1>When would you use the different git merge strategies?</h1> <p>From the man page on git-merge, there are a number of merge strategies you can use. </p> <ul> <li><p><em>resolve</em> - This can only resolve two heads (i.e. the current branch and another branch you pulled from) using 3-way merge algorithm. It tries...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,644
git
# When would you use the different git merge strategies? From the man page on git-merge, there are a number of merge strategies you can use. - *resolve* - This can only resolve two heads (i.e. the current branch and another branch you pulled from) using 3-way merge algorithm. It tries to carefully detect criss-cros...
I'm not familiar with resolve, but I've used the others: ## Recursive Recursive is the default for non-fast-forward merges. We're all familiar with that one. ## Octopus I've used octopus when I've had several trees that needed to be merged. You see this in larger projects where many branches have had independent de...
655243
Ignore modified (but not committed) files in git?
222
2009-03-17 17:27:00
<p>Can I tell git to ignore files that are modified (deleted) but should not be committed?</p> <p>The situation is that I have a subdirectory in the repo which contains stuff I'm not interested in at all, so I deleted it to prevent it showing up in auto-completions and the like (in the IDE).</p> <p>But now, if I add ...
108,975
null
2021-11-09 01:49:54
761,116
326
2009-04-17 16:22:14
74,059
2021-11-09 01:45:58
https://stackoverflow.com/q/655243
https://stackoverflow.com/a/761116
<p>check out the <a href="https://git-scm.com/docs/git-update-index#_using_assume_unchanged_bit" rel="noreferrer">git-update-index man page</a> and the --assume-unchanged bit and related.</p> <p>when I have your problem I do this</p> <pre><code>git update-index --assume-unchanged dir-im-removing/ </code></pre> <p>or a ...
<p>check out the <a href="https://git-scm.com/docs/git-update-index#_using_assume_unchanged_bit" rel="noreferrer">git-update-index man page</a> and the --assume-unchanged bit and related.</p> <p>when I have your problem I do this</p> <pre><code>git update-index --assume-unchanged dir-im-removing/ </code></pre> <p>or a ...
119, 4333, 6452
git, git-svn, ignore
<h1>Ignore modified (but not committed) files in git?</h1> <p>Can I tell git to ignore files that are modified (deleted) but should not be committed?</p> <p>The situation is that I have a subdirectory in the repo which contains stuff I'm not interested in at all, so I deleted it to prevent it showing up in auto-comple...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,646
git
# Ignore modified (but not committed) files in git? Can I tell git to ignore files that are modified (deleted) but should not be committed? The situation is that I have a subdirectory in the repo which contains stuff I'm not interested in at all, so I deleted it to prevent it showing up in auto-completions and the li...
check out the [git-update-index man page](https://git-scm.com/docs/git-update-index#_using_assume_unchanged_bit) and the --assume-unchanged bit and related. when I have your problem I do this ``` git update-index --assume-unchanged dir-im-removing/ ``` or a specific file ``` git update-index --assume-unchanged conf...
11561498
How to compare two files not in repo using git
185
2012-07-19 13:04:38
<p>I'd like to compare two css files which are not in any git repository. Is there such a functionality in git?</p>
52,885
1,090,166
2018-05-16 09:13:00
17,194,704
325
2013-06-19 15:02:48
19,784
2013-06-19 15:02:48
https://stackoverflow.com/q/11561498
https://stackoverflow.com/a/17194704
<p><code>git</code>'s diff is more functional than the standard unix <code>diff</code>. I often want to do this and since this question ranks highly on google, I want this answer to show up.</p> <p>This question: <a href="https://stackoverflow.com/questions/5637311/how-to-use-git-diff-color-words-outside-a-git-reposi...
<p><code>git</code>'s diff is more functional than the standard unix <code>diff</code>. I often want to do this and since this question ranks highly on google, I want this answer to show up.</p> <p>This question: <a href="https://stackoverflow.com/questions/5637311/how-to-use-git-diff-color-words-outside-a-git-reposi...
119, 606, 2936
compare, diff, git
<h1>How to compare two files not in repo using git</h1> <p>I'd like to compare two css files which are not in any git repository. Is there such a functionality in git?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,647
git
# How to compare two files not in repo using git I'd like to compare two css files which are not in any git repository. Is there such a functionality in git?
`git`'s diff is more functional than the standard unix `diff`. I often want to do this and since this question ranks highly on google, I want this answer to show up. This question: [How to use `git diff --color-words` outside a Git repository?](https://stackoverflow.com/questions/5637311/how-to-use-git-diff-color-word...
2119480
Edit the root commit in Git?
417
2010-01-22 18:21:34
<p>There's ways to change the message from later commits:</p> <pre class="lang-sh prettyprint-override"><code>git commit --amend # for the most recent commit git rebase --interactive master~2 # but requires *parent* </code></pre> <p>How can you change the commit message of the very first commit...
66,162
50,979
2019-12-27 08:37:57
2,119,656
324
2010-01-22 18:53:12
19,563
2014-12-17 09:46:37
https://stackoverflow.com/q/2119480
https://stackoverflow.com/a/2119656
<p>Assuming that you have a clean working tree, you can do the following.</p> <pre class="lang-sh prettyprint-override"><code># checkout the root commit git checkout &lt;sha1-of-root&gt; # amend the commit git commit --amend # rebase all the other commits in master onto the amended root git rebase --onto HEAD HEAD m...
<p>Assuming that you have a clean working tree, you can do the following.</p> <pre class="lang-sh prettyprint-override"><code># checkout the root commit git checkout &lt;sha1-of-root&gt; # amend the commit git commit --amend # rebase all the other commits in master onto the amended root git rebase --onto HEAD HEAD m...
119, 29934, 30968, 53850, 91259
git, git-amend, git-commit, git-rebase, git-rewrite-history
<h1>Edit the root commit in Git?</h1> <p>There's ways to change the message from later commits:</p> <pre class="lang-sh prettyprint-override"><code>git commit --amend # for the most recent commit git rebase --interactive master~2 # but requires *parent* </code></pre> <p>How can you change the c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,649
git
# Edit the root commit in Git? There's ways to change the message from later commits: ``` git commit --amend # for the most recent commit git rebase --interactive master~2 # but requires *parent* ``` How can you change the commit message of the very first commit (which has no parent)?
Assuming that you have a clean working tree, you can do the following. ``` # checkout the root commit git checkout <sha1-of-root> # amend the commit git commit --amend # rebase all the other commits in master onto the amended root git rebase --onto HEAD HEAD master ```
8185276
Find size of Git repository
416
2011-11-18 16:03:24
<p>What's a simple way to find the size of my Git repository?</p> <p>And I don't mean <code>du -h</code> on the root directory of my repository. I have a lot of ignored files, so that size would be different from my total repository size. I essentially want to know how much data would be transferred upon cloning my re...
272,325
485,388
2025-09-06 17:30:23
8,185,326
324
2011-11-18 16:06:09
85,371
2016-05-25 11:55:34
https://stackoverflow.com/q/8185276
https://stackoverflow.com/a/8185326
<blockquote> <p><strong>UPDATE</strong> git 1.8.3 introduced a more efficient way to get a rough size: <code>git count-objects -vH</code> (see answer by @VonC)</p> </blockquote> <p>For different ideas of "complete size" you could use:</p> <pre><code>git bundle create tmp.bundle --all du -sh tmp.bundle </code></pre>...
<blockquote> <p><strong>UPDATE</strong> git 1.8.3 introduced a more efficient way to get a rough size: <code>git count-objects -vH</code> (see answer by @VonC)</p> </blockquote> <p>For different ideas of "complete size" you could use:</p> <pre><code>git bundle create tmp.bundle --all du -sh tmp.bundle </code></pre>...
119, 8071
filesize, git
<h1>Find size of Git repository</h1> <p>What's a simple way to find the size of my Git repository?</p> <p>And I don't mean <code>du -h</code> on the root directory of my repository. I have a lot of ignored files, so that size would be different from my total repository size. I essentially want to know how much data wo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,650
git
# Find size of Git repository What's a simple way to find the size of my Git repository? And I don't mean `du -h` on the root directory of my repository. I have a lot of ignored files, so that size would be different from my total repository size. I essentially want to know how much data would be transferred upon clo...
> **UPDATE** git 1.8.3 introduced a more efficient way to get a rough size: `git count-objects -vH` (see answer by @VonC) For different ideas of "complete size" you could use: ``` git bundle create tmp.bundle --all du -sh tmp.bundle ``` Close (but not exact:) ``` git gc du -sh .git/ ``` With the latter, you would ...
11117823
Git Push error: refusing to update checked out branch
274
2012-06-20 10:40:18
<p>I have solved some merge conflicts, committed then tried to Push my changes and received the following error:</p> <pre><code>c:\Program Files (x86)\Git\bin\git.exe push --recurse-submodules=check "origin" master:master Done remote: error: refusing to update checked out branch: refs/heads/master remote: error: By de...
270,679
545,877
2024-03-11 17:27:22
11,117,928
324
2012-06-20 10:47:46
912,144
2020-04-16 19:26:33
https://stackoverflow.com/q/11117823
https://stackoverflow.com/a/11117928
<p>Reason:You are pushing to a Non-Bare Repository</p> <p>There are two types of repositories: <a href="https://stackoverflow.com/q/5540883/3803682">bare and non-bare</a></p> <p>Bare repositories do not have a working copy and you can push to them. Those are the types of repositories you get in Github! If you want to...
<p>Reason:You are pushing to a Non-Bare Repository</p> <p>There are two types of repositories: <a href="https://stackoverflow.com/q/5540883/3803682">bare and non-bare</a></p> <p>Bare repositories do not have a working copy and you can push to them. Those are the types of repositories you get in Github! If you want to...
119, 28898
git, git-push
<h1>Git Push error: refusing to update checked out branch</h1> <p>I have solved some merge conflicts, committed then tried to Push my changes and received the following error:</p> <pre><code>c:\Program Files (x86)\Git\bin\git.exe push --recurse-submodules=check "origin" master:master Done remote: error: refusing to up...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,651
git
# Git Push error: refusing to update checked out branch I have solved some merge conflicts, committed then tried to Push my changes and received the following error: ``` c:\Program Files (x86)\Git\bin\git.exe push --recurse-submodules=check "origin" master:master Done remote: error: refusing to update checked out bra...
Reason:You are pushing to a Non-Bare Repository There are two types of repositories: [bare and non-bare](https://stackoverflow.com/q/5540883/3803682) Bare repositories do not have a working copy and you can push to them. Those are the types of repositories you get in Github! If you want to create a bare repository, y...
11131197
Undo git update-index --skip-worktree
227
2012-06-21 03:40:58
<p>A while ago I did this to ignore changes to a file tracked by git:</p> <pre><code>git update-index --skip-worktree &lt;file&gt; </code></pre> <p>Now I actually want to commit changes to that file to source. How do I undo the effects of <code>skip-worktree</code>?</p>
63,525
329,700
2024-10-21 10:49:35
11,131,211
323
2012-06-21 03:43:17
329,700
2012-06-21 03:43:17
https://stackoverflow.com/q/11131197
https://stackoverflow.com/a/11131211
<p>Aha! I simply want:</p> <pre><code>git update-index --no-skip-worktree &lt;file&gt; </code></pre>
<p>Aha! I simply want:</p> <pre><code>git update-index --no-skip-worktree &lt;file&gt; </code></pre>
119, 5766
git, undo
<h1>Undo git update-index --skip-worktree</h1> <p>A while ago I did this to ignore changes to a file tracked by git:</p> <pre><code>git update-index --skip-worktree &lt;file&gt; </code></pre> <p>Now I actually want to commit changes to that file to source. How do I undo the effects of <code>skip-worktree</code>?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,653
git
# Undo git update-index --skip-worktree A while ago I did this to ignore changes to a file tracked by git: ``` git update-index --skip-worktree <file> ``` Now I actually want to commit changes to that file to source. How do I undo the effects of `skip-worktree`?
Aha! I simply want: ``` git update-index --no-skip-worktree <file> ```
8329485
"Unable to find remote helper for 'https'" during git clone
287
2011-11-30 16:36:14
<p>I am unable to clone HTTPS repositories. I can clone SSH repos fine, but not HTTPS repos. I cannot test the GIT protocol since I am behind a corporate firewall.</p> <p>This is what I am trying to do:</p> <pre><code>$ git clone https://github.com/nvie/gitflow.git Cloning into gitflow... fatal: Unable to find remote...
336,873
680,335
2024-02-19 22:33:56
13,018,777
322
2012-10-22 19:53:34
949,827
2021-11-04 08:55:07
https://stackoverflow.com/q/8329485
https://stackoverflow.com/a/13018777
<p>It looks like not having (lib)curl-devel installed when you compile git can cause this.</p> <p>If you install (lib)curl-devel, and then rebuild/install git, this should solve the problem:</p> <pre><code>$ yum install curl-devel $ # cd to wherever the source for git is $ cd /usr/local/src/git-1.7.9 $ ./configure $ ...
<p>It looks like not having (lib)curl-devel installed when you compile git can cause this.</p> <p>If you install (lib)curl-devel, and then rebuild/install git, this should solve the problem:</p> <pre><code>$ yum install curl-devel $ # cd to wherever the source for git is $ cd /usr/local/src/git-1.7.9 $ ./configure $ ...
58, 119, 549
git, linux, ubuntu
<h1>"Unable to find remote helper for 'https'" during git clone</h1> <p>I am unable to clone HTTPS repositories. I can clone SSH repos fine, but not HTTPS repos. I cannot test the GIT protocol since I am behind a corporate firewall.</p> <p>This is what I am trying to do:</p> <pre><code>$ git clone https://github.com/...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,654
git
# "Unable to find remote helper for 'https'" during git clone I am unable to clone HTTPS repositories. I can clone SSH repos fine, but not HTTPS repos. I cannot test the GIT protocol since I am behind a corporate firewall. This is what I am trying to do: ``` $ git clone https://github.com/nvie/gitflow.git Cloning in...
It looks like not having (lib)curl-devel installed when you compile git can cause this. If you install (lib)curl-devel, and then rebuild/install git, this should solve the problem: ``` $ yum install curl-devel $ # cd to wherever the source for git is $ cd /usr/local/src/git-1.7.9 $ ./configure $ make $ make install...
14879691
Get number of digits with JavaScript
192
2013-02-14 16:39:18
<p>As the title of my post suggests, I would like to know how many digits <code>var number</code> has. For example: If <code>number = 15;</code> my function should return <code>2</code>. Currently, it looks like this:</p> <pre><code>function getlength(number) { return number.toString().length(); } </code></pre> <p>...
378,670
2,072,733
2024-04-23 20:21:21
14,879,700
322
2013-02-14 16:39:43
1,249,581
2015-11-06 15:37:10
https://stackoverflow.com/q/14879691
https://stackoverflow.com/a/14879700
<p><code>length</code> is a property, not a method. You can't call it, hence you don't need parenthesis <code>()</code>:</p> <pre><code>function getlength(number) { return number.toString().length; } </code></pre> <p><strong>UPDATE:</strong> As discussed in the comments, the above example won't work for float num...
<p><code>length</code> is a property, not a method. You can't call it, hence you don't need parenthesis <code>()</code>:</p> <pre><code>function getlength(number) { return number.toString().length; } </code></pre> <p><strong>UPDATE:</strong> As discussed in the comments, the above example won't work for float num...
3, 7989, 9914
count, digits, javascript
<h1>Get number of digits with JavaScript</h1> <p>As the title of my post suggests, I would like to know how many digits <code>var number</code> has. For example: If <code>number = 15;</code> my function should return <code>2</code>. Currently, it looks like this:</p> <pre><code>function getlength(number) { return nu...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,655
git
# Get number of digits with JavaScript As the title of my post suggests, I would like to know how many digits `var number` has. For example: If `number = 15;` my function should return `2`. Currently, it looks like this: ``` function getlength(number) { return number.toString().length(); } ``` But Safari says it i...
`length` is a property, not a method. You can't call it, hence you don't need parenthesis `()`: ``` function getlength(number) { return number.toString().length; } ``` **UPDATE:** As discussed in the comments, the above example won't work for float numbers. To make it working we can either get rid of a period wit...
2293498
Applying a git post-commit hook to all current and future repositories
354
2010-02-19 01:24:42
<p>I've written a Git post-commit hook and it works correctly. However, I want to add this hook to apply to all current (and future) Git repositories I am working on. I tried adding the hook to my <code>~/.git/hooks/</code> directory instead of in the hooks directory in the project directory, however, this did not se...
117,104
184,609
2025-01-22 06:55:07
37,293,198
320
2016-05-18 07:42:36
6,309
2024-02-15 19:12:21
https://stackoverflow.com/q/2293498
https://stackoverflow.com/a/37293198
<blockquote> <p>I want to add this hook to apply to all current (and future) git repositories I am working on</p> </blockquote> <p>With git 2.9+ (June 2016), all you would do is:</p> <pre><code>git config --global core.hooksPath /path/to/my/centralized/hooks </code></pre> <p>See &quot;<a href="https://stackoverflow.com...
<blockquote> <p>I want to add this hook to apply to all current (and future) git repositories I am working on</p> </blockquote> <p>With git 2.9+ (June 2016), all you would do is:</p> <pre><code>git config --global core.hooksPath /path/to/my/centralized/hooks </code></pre> <p>See &quot;<a href="https://stackoverflow.com...
119, 853, 43087
git, githooks, hook
<h1>Applying a git post-commit hook to all current and future repositories</h1> <p>I've written a Git post-commit hook and it works correctly. However, I want to add this hook to apply to all current (and future) Git repositories I am working on. I tried adding the hook to my <code>~/.git/hooks/</code> directory inst...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,657
git
# Applying a git post-commit hook to all current and future repositories I've written a Git post-commit hook and it works correctly. However, I want to add this hook to apply to all current (and future) Git repositories I am working on. I tried adding the hook to my `~/.git/hooks/` directory instead of in the hooks di...
> I want to add this hook to apply to all current (and future) git repositories I am working on With git 2.9+ (June 2016), all you would do is: ``` git config --global core.hooksPath /path/to/my/centralized/hooks ``` See "[change default git hooks](https://stackoverflow.com/a/37293001/6309)": this has been done to m...
7417166
How to switch back to 'master' with git?
190
2011-09-14 13:32:57
<p>I have made my first commit; then created a branch (let's say branch1).</p> <p>In this branch I've created a directory 'example' and commited. In GitHub I see my new branch and the new directory 'example' that I have added.</p> <p>Now I wonder how can I 'sync' back to master; and so have the 'example' folder delet...
496,473
78,970
2024-12-04 01:54:09
7,417,192
320
2011-09-14 13:34:33
1,836
2022-02-17 21:07:44
https://stackoverflow.com/q/7417166
https://stackoverflow.com/a/7417192
<p>You need to checkout the branch:</p> <pre><code>git checkout master </code></pre> <p>or</p> <pre><code>git checkout main </code></pre> <p>See the <a href="https://help.github.com/articles/git-cheatsheet" rel="noreferrer">Git cheat sheets</a> for more information.</p> <p>Edit: Please note that git does not manage emp...
<p>You need to checkout the branch:</p> <pre><code>git checkout master </code></pre> <p>or</p> <pre><code>git checkout main </code></pre> <p>See the <a href="https://help.github.com/articles/git-cheatsheet" rel="noreferrer">Git cheat sheets</a> for more information.</p> <p>Edit: Please note that git does not manage emp...
119
git
<h1>How to switch back to 'master' with git?</h1> <p>I have made my first commit; then created a branch (let's say branch1).</p> <p>In this branch I've created a directory 'example' and commited. In GitHub I see my new branch and the new directory 'example' that I have added.</p> <p>Now I wonder how can I 'sync' back...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,659
git
# How to switch back to 'master' with git? I have made my first commit; then created a branch (let's say branch1). In this branch I've created a directory 'example' and commited. In GitHub I see my new branch and the new directory 'example' that I have added. Now I wonder how can I 'sync' back to master; and so have...
You need to checkout the branch: ``` git checkout master ``` or ``` git checkout main ``` See the [Git cheat sheets](https://help.github.com/articles/git-cheatsheet) for more information. Edit: Please note that git does not manage empty directories, so you'll have to manage them yourself. If your directory is empt...
933329
Git undo changes in some files
210
2009-06-01 02:09:05
<p>While coding I added print statements into some files to keep track of what was going on.</p> <p>When I am done, is it possible to revert changes in some files, but commit the file I actually worked on? </p> <p>Say I added print in file <code>A</code>, but I modified file <code>B</code>. <code>B</code> is what I w...
204,759
89,904
2018-01-11 10:48:16
933,344
319
2009-06-01 02:16:14
3,146
2009-06-01 07:39:50
https://stackoverflow.com/q/933329
https://stackoverflow.com/a/933344
<p>There are three basic ways to do this depending on what you have done with the changes to the file A. If you have not yet added the changes to the index or committed them, then you just want to use the checkout command - this will change the state of the working copy to match the repository:</p> <pre><code>git chec...
<p>There are three basic ways to do this depending on what you have done with the changes to the file A. If you have not yet added the changes to the index or committed them, then you just want to use the checkout command - this will change the state of the working copy to match the repository:</p> <pre><code>git chec...
119, 456, 5310, 5766, 12309
file, git, revert, undo, version-control
<h1>Git undo changes in some files</h1> <p>While coding I added print statements into some files to keep track of what was going on.</p> <p>When I am done, is it possible to revert changes in some files, but commit the file I actually worked on? </p> <p>Say I added print in file <code>A</code>, but I modified file <c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,662
git
# Git undo changes in some files While coding I added print statements into some files to keep track of what was going on. When I am done, is it possible to revert changes in some files, but commit the file I actually worked on? Say I added print in file `A`, but I modified file `B`. `B` is what I want to commit and...
There are three basic ways to do this depending on what you have done with the changes to the file A. If you have not yet added the changes to the index or committed them, then you just want to use the checkout command - this will change the state of the working copy to match the repository: ``` git checkout A ``` If...
3600728
How to list all unmerged changes in Git?
183
2010-08-30 13:22:41
<p>Creating a branch for various topics, and not regularly deleting them when I don't need them any more, I have now ended up with about 50 branches.</p> <p>I tried deleting branches but some of them have unmerged changes.</p> <p>What I want is the ability to see exactly what changes are there in any branch on my repo ...
65,715
55,562
2024-04-02 18:07:36
3,602,022
319
2010-08-30 15:54:00
138,830
2024-04-02 18:07:36
https://stackoverflow.com/q/3600728
https://stackoverflow.com/a/3602022
<p>To list branches with commits not merged into master:</p> <pre><code>git branch --no-merged master </code></pre> <p>To include remote branches:</p> <pre><code>git branch -a --no-merged master </code></pre> <p>To list the relevant commits:</p> <pre><code>git cherry -v master &lt;branch&gt; </code></pre>
<p>To list branches with commits not merged into master:</p> <pre><code>git branch --no-merged master </code></pre> <p>To include remote branches:</p> <pre><code>git branch -a --no-merged master </code></pre> <p>To list the relevant commits:</p> <pre><code>git cherry -v master &lt;branch&gt; </code></pre>
119, 1879
branch, git
<h1>How to list all unmerged changes in Git?</h1> <p>Creating a branch for various topics, and not regularly deleting them when I don't need them any more, I have now ended up with about 50 branches.</p> <p>I tried deleting branches but some of them have unmerged changes.</p> <p>What I want is the ability to see exactl...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,663
git
# How to list all unmerged changes in Git? Creating a branch for various topics, and not regularly deleting them when I don't need them any more, I have now ended up with about 50 branches. I tried deleting branches but some of them have unmerged changes. What I want is the ability to see exactly what changes are th...
To list branches with commits not merged into master: ``` git branch --no-merged master ``` To include remote branches: ``` git branch -a --no-merged master ``` To list the relevant commits: ``` git cherry -v master <branch> ```
11987914
How do I reword the very first git commit message?
161
2012-08-16 13:11:15
<h2>I have a working tree containing 3 commmits:</h2> <p>➜ ~myproject git:(master) <code>git log</code></p> <pre><code>commit a99cce8240495de29254b5df8745e41815db5a75 Author: My Name &lt;my@mail.com&gt; Date: Thu Aug 16 00:59:05 2012 +0200 .gitignore edits commit 5bccda674c7ca51e849741290530a0d48efd69e8 Auth...
29,708
63,984
2020-04-20 08:43:50
21,048,552
319
2014-01-10 15:48:38
1,075,152
2020-04-20 08:43:50
https://stackoverflow.com/q/11987914
https://stackoverflow.com/a/21048552
<p>Do <code>git rebase -i --root</code></p> <p>(point to <code>root</code> instead of pointing to a specific commit)</p> <p>This way, the first commit is also included and you can just <code>reword</code> it like any other commit.</p> <p>The <code>--root</code> option was introduced in Git <code>v1.7.12</code> (2012...
<p>Do <code>git rebase -i --root</code></p> <p>(point to <code>root</code> instead of pointing to a specific commit)</p> <p>This way, the first commit is also included and you can just <code>reword</code> it like any other commit.</p> <p>The <code>--root</code> option was introduced in Git <code>v1.7.12</code> (2012...
119, 1863, 29934, 53850, 69559
git, git-commit, git-rebase, message, revision-history
<h1>How do I reword the very first git commit message?</h1> <h2>I have a working tree containing 3 commmits:</h2> <p>➜ ~myproject git:(master) <code>git log</code></p> <pre><code>commit a99cce8240495de29254b5df8745e41815db5a75 Author: My Name &lt;my@mail.com&gt; Date: Thu Aug 16 00:59:05 2012 +0200 .gitignore...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,664
git
# How do I reword the very first git commit message? ## I have a working tree containing 3 commmits: ➜ ~myproject git:(master) `git log` ``` commit a99cce8240495de29254b5df8745e41815db5a75 Author: My Name <my@mail.com> Date: Thu Aug 16 00:59:05 2012 +0200 .gitignore edits commit 5bccda674c7ca51e849741290530a...
Do `git rebase -i --root` (point to `root` instead of pointing to a specific commit) This way, the first commit is also included and you can just `reword` it like any other commit. The `--root` option was introduced in Git `v1.7.12` (2012). Before then the only option was to use `filter-branch` or `--amend`, which i...
30208928
Can "git pull" automatically stash and pop pending changes?
212
2015-05-13 07:58:13
<p>I know how to solve this:</p> <pre><code>user@host$ git pull Updating 9386059..6e3ffde error: Your local changes to the following files would be overwritten by merge: foo.bar Please, commit your changes or stash them before you can merge. Aborting </code></pre> <p>But isn't there a way to let <code>git pull</c...
84,147
633,961
2022-09-11 21:25:32
30,209,750
318
2015-05-13 08:39:42
6,309
2022-09-11 21:25:32
https://stackoverflow.com/q/30208928
https://stackoverflow.com/a/30209750
<p><strong>For Git 2.6+ (released 28 Sept 2015)</strong></p> <p>The <del>only</del> <a href="http://git-scm.com/docs/git-config" rel="noreferrer"><code>git config</code></a> setting which would be of interest is:</p> <blockquote> <h2><code>rebase.autostash</code></h2> </blockquote> <p>(with Git 2.27, Q2 2020, you now a...
<p><strong>For Git 2.6+ (released 28 Sept 2015)</strong></p> <p>The <del>only</del> <a href="http://git-scm.com/docs/git-config" rel="noreferrer"><code>git config</code></a> setting which would be of interest is:</p> <blockquote> <h2><code>rebase.autostash</code></h2> </blockquote> <p>(with Git 2.27, Q2 2020, you now a...
119, 13091, 28896
git, git-pull, git-stash
<h1>Can "git pull" automatically stash and pop pending changes?</h1> <p>I know how to solve this:</p> <pre><code>user@host$ git pull Updating 9386059..6e3ffde error: Your local changes to the following files would be overwritten by merge: foo.bar Please, commit your changes or stash them before you can merge. Abor...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,666
git
# Can "git pull" automatically stash and pop pending changes? I know how to solve this: ``` user@host$ git pull Updating 9386059..6e3ffde error: Your local changes to the following files would be overwritten by merge: foo.bar Please, commit your changes or stash them before you can merge. Aborting ``` But isn't ...
**For Git 2.6+ (released 28 Sept 2015)** The ~~only~~ [`git config`](http://git-scm.com/docs/git-config) setting which would be of interest is: > ## `rebase.autostash` (with Git 2.27, Q2 2020, you now also have **`merge.autostash`**, see below) > When set to true, automatically create a temporary stash before the o...
3103589
How can I easily fixup a past commit?
216
2010-06-23 16:32:30
<p>I just read <a href="https://stackoverflow.com/questions/493450/amending-a-single-file-in-a-past-commit-in-git">amending a single file in a past commit in git</a> but unfortunately the accepted solution 'reorders' the commits, which is not what I want. So here's my question:</p> <p>Every now and then, I notice a bu...
179,689
91,757
2025-06-27 05:14:24
3,828,861
317
2010-09-30 08:10:50
91,757
2025-04-09 15:24:10
https://stackoverflow.com/q/3103589
https://stackoverflow.com/a/3828861
<h2>UPDATED ANSWER</h2> <p>A while ago, a new <code>--fixup</code> argument was added to <code>git commit</code> which can be used to construct a commit with a log message suitable for <code>git rebase --interactive --autosquash</code>. So the simplest way to fixup a past commit is now:</p> <pre><code>$ git add ... ...
<h2>UPDATED ANSWER</h2> <p>A while ago, a new <code>--fixup</code> argument was added to <code>git commit</code> which can be used to construct a commit with a log message suitable for <code>git rebase --interactive --autosquash</code>. So the simplest way to fixup a past commit is now:</p> <pre><code>$ git add ... ...
119, 7407
git, url-rewriting
<h1>How can I easily fixup a past commit?</h1> <p>I just read <a href="https://stackoverflow.com/questions/493450/amending-a-single-file-in-a-past-commit-in-git">amending a single file in a past commit in git</a> but unfortunately the accepted solution 'reorders' the commits, which is not what I want. So here's my ques...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,667
git
# How can I easily fixup a past commit? I just read [amending a single file in a past commit in git](https://stackoverflow.com/questions/493450/amending-a-single-file-in-a-past-commit-in-git) but unfortunately the accepted solution 'reorders' the commits, which is not what I want. So here's my question: Every now and...
## UPDATED ANSWER A while ago, a new `--fixup` argument was added to `git commit` which can be used to construct a commit with a log message suitable for `git rebase --interactive --autosquash`. So the simplest way to fixup a past commit is now: ``` $ git add ... # Stage a fix $ git commit -...
6879501
Filter git diff by type of change
173
2011-07-29 22:05:35
<p>Is there a way to limit <code>git diff</code> to changed files?</p> <p>I'd like to see the differences between two commits, but exclude paths that don't exist in one or the other (additions/deletions). The following Perl one-liner illustrates most of what I want:</p> <pre><code>git diff master.. | perl -lnwe 'pri...
96,034
82,723
2022-11-02 11:39:42
6,879,568
317
2011-07-29 22:14:12
226,034
2022-11-02 11:39:42
https://stackoverflow.com/q/6879501
https://stackoverflow.com/a/6879568
<p>You are looking for <code>--diff-filter=M</code> to show only files <strong>M</strong>odified between the two branches.</p> <p>From <code>man git-diff</code></p> <blockquote> <p><code>--diff-filter=[ACDMRTUXB*]</code></p> <p>Select only files that are</p> <ul> <li><code>A</code> Added</li> <li><code>C</code> Copied<...
<p>You are looking for <code>--diff-filter=M</code> to show only files <strong>M</strong>odified between the two branches.</p> <p>From <code>man git-diff</code></p> <blockquote> <p><code>--diff-filter=[ACDMRTUXB*]</code></p> <p>Select only files that are</p> <ul> <li><code>A</code> Added</li> <li><code>C</code> Copied<...
119, 606
diff, git
<h1>Filter git diff by type of change</h1> <p>Is there a way to limit <code>git diff</code> to changed files?</p> <p>I'd like to see the differences between two commits, but exclude paths that don't exist in one or the other (additions/deletions). The following Perl one-liner illustrates most of what I want:</p> <pr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,668
git
# Filter git diff by type of change Is there a way to limit `git diff` to changed files? I'd like to see the differences between two commits, but exclude paths that don't exist in one or the other (additions/deletions). The following Perl one-liner illustrates most of what I want: ``` git diff master.. | perl -lnwe ...
You are looking for `--diff-filter=M` to show only files **M**odified between the two branches. From `man git-diff` > `--diff-filter=[ACDMRTUXB*]` > > Select only files that are > > - `A` Added > - `C` Copied > - `D` Deleted > - `M` Modified > - `R` Renamed > - `T` have their type (mode) changed > - `U` Unmerged > - ...
12132272
How can you undo the last git add?
208
2012-08-26 17:21:05
<p>Is it possible to unstage the last staged (not committed) change in <strong>git</strong>? Suppose there were a lot of files in the current branch, some staged, some not. At some point, some foolish programmer accidentally executed:</p> <pre><code>git add -- . </code></pre> <p>...instead of:</p> <pre><code>git che...
210,156
521,032
2024-05-21 21:52:18
12,132,536
316
2012-08-26 17:59:35
390,522
2012-08-26 17:59:35
https://stackoverflow.com/q/12132272
https://stackoverflow.com/a/12132536
<p>You can use <code>git reset</code>. This will 'unstage' all the files you've added after your last commit.</p> <p>If you want to unstage only some files, use <code>git reset -- &lt;file 1&gt; &lt;file 2&gt; &lt;file n&gt;</code>.</p> <p>Also it's possible to unstage some of the changes in files by using <code>git ...
<p>You can use <code>git reset</code>. This will 'unstage' all the files you've added after your last commit.</p> <p>If you want to unstage only some files, use <code>git reset -- &lt;file 1&gt; &lt;file 2&gt; &lt;file n&gt;</code>.</p> <p>Also it's possible to unstage some of the changes in files by using <code>git ...
119
git
<h1>How can you undo the last git add?</h1> <p>Is it possible to unstage the last staged (not committed) change in <strong>git</strong>? Suppose there were a lot of files in the current branch, some staged, some not. At some point, some foolish programmer accidentally executed:</p> <pre><code>git add -- . </code></pre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,669
git
# How can you undo the last git add? Is it possible to unstage the last staged (not committed) change in **git**? Suppose there were a lot of files in the current branch, some staged, some not. At some point, some foolish programmer accidentally executed: ``` git add -- . ``` ...instead of: ``` git checkout -- . ``...
You can use `git reset`. This will 'unstage' all the files you've added after your last commit. If you want to unstage only some files, use `git reset -- <file 1> <file 2> <file n>`. Also it's possible to unstage some of the changes in files by using `git reset -p`.
13788945
How to cherry-pick from a remote branch?
235
2012-12-09 15:45:55
<p>I'm having trouble performing a cherry-pick. On my local machine, I'm currently on my "master" branch. I want to cherry-pick in a commit from another branch, named "zebra". The "zebra" branch is a remote branch. </p> <p>So git status:</p> <pre><code># On branch master nothing to commit (working directory clean) </...
369,036
291,701
2024-08-23 10:51:38
13,789,405
315
2012-12-09 16:45:09
1,727,593
2012-12-09 16:45:09
https://stackoverflow.com/q/13788945
https://stackoverflow.com/a/13789405
<blockquote> <p>Since "zebra" is a remote branch, I was thinking I don't have its data locally.</p> </blockquote> <p>You are correct that you don't have the right data, but tried to resolve it in the wrong way. To collect data locally from a remote source, you need to use <code>git fetch</code>. When you did <code...
<blockquote> <p>Since "zebra" is a remote branch, I was thinking I don't have its data locally.</p> </blockquote> <p>You are correct that you don't have the right data, but tried to resolve it in the wrong way. To collect data locally from a remote source, you need to use <code>git fetch</code>. When you did <code...
119
git
<h1>How to cherry-pick from a remote branch?</h1> <p>I'm having trouble performing a cherry-pick. On my local machine, I'm currently on my "master" branch. I want to cherry-pick in a commit from another branch, named "zebra". The "zebra" branch is a remote branch. </p> <p>So git status:</p> <pre><code># On branch mas...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,670
git
# How to cherry-pick from a remote branch? I'm having trouble performing a cherry-pick. On my local machine, I'm currently on my "master" branch. I want to cherry-pick in a commit from another branch, named "zebra". The "zebra" branch is a remote branch. So git status: ``` # On branch master nothing to commit (worki...
> Since "zebra" is a remote branch, I was thinking I don't have its data > locally. You are correct that you don't have the right data, but tried to resolve it in the wrong way. To collect data locally from a remote source, you need to use `git fetch`. When you did `git checkout zebra` you switched to whatever the sta...
5669358
Can I do a partial revert in GIT
233
2011-04-14 20:36:49
<p>Is it possible to revert only a single file or certain changes in a file in multi file commit?</p> <p><strong>Full story</strong> I committed a bunch of files. A number of commits later someone who will remain nameless (JACK!!!) copied a file into his repository and committed several files, overwriting some of the ...
66,068
25,143
2024-06-24 07:58:18
5,669,428
315
2011-04-14 20:43:09
144,846
2022-09-28 17:29:24
https://stackoverflow.com/q/5669358
https://stackoverflow.com/a/5669428
<p>You can revert the commit without creating a new one by adding the <code>--no-commit</code> option. This leaves all the reverted files in the staging area.</p> <p>From there, I'd perform a mixed reset (the default for reset) to un-stage the files, and add in the changes I really wanted. Then, commit, (you can add a...
<p>You can revert the commit without creating a new one by adding the <code>--no-commit</code> option. This leaves all the reverted files in the staging area.</p> <p>From there, I'd perform a mixed reset (the default for reset) to un-stage the files, and add in the changes I really wanted. Then, commit, (you can add a...
119
git
<h1>Can I do a partial revert in GIT</h1> <p>Is it possible to revert only a single file or certain changes in a file in multi file commit?</p> <p><strong>Full story</strong> I committed a bunch of files. A number of commits later someone who will remain nameless (JACK!!!) copied a file into his repository and committ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,671
git
# Can I do a partial revert in GIT Is it possible to revert only a single file or certain changes in a file in multi file commit? **Full story** I committed a bunch of files. A number of commits later someone who will remain nameless (JACK!!!) copied a file into his repository and committed several files, overwriting...
You can revert the commit without creating a new one by adding the `--no-commit` option. This leaves all the reverted files in the staging area. From there, I'd perform a mixed reset (the default for reset) to un-stage the files, and add in the changes I really wanted. Then, commit, (you can add and commit more files ...
2945344
How do I select a merge strategy for a git rebase?
191
2010-05-31 18:33:46
<p><code>git-rebase</code> man page mentions <code>-X&lt;option&gt;</code> can be passed to <code>git-merge</code>. When/how exactly?</p> <p>I'd like to rebase by applying patches with <em>recursive</em> strategy and <em>theirs</em> option (apply whatever sticks, rather than skipping entire conflicting commits). I don...
132,979
27,009
2019-10-18 21:28:34
4,273,436
315
2010-11-25 03:11:42
519,614
2019-10-18 21:28:34
https://stackoverflow.com/q/2945344
https://stackoverflow.com/a/4273436
<p>You can use this with Git v1.7.3 or later versions.</p> <pre class="lang-sh prettyprint-override"><code>git rebase --strategy-option theirs ${branch} # Long option git rebase -X theirs ${branch} # Short option </code></pre> <p>(which is a short for <code>git rebase --strategy recursive --strategy-option theirs ${b...
<p>You can use this with Git v1.7.3 or later versions.</p> <pre class="lang-sh prettyprint-override"><code>git rebase --strategy-option theirs ${branch} # Long option git rebase -X theirs ${branch} # Short option </code></pre> <p>(which is a short for <code>git rebase --strategy recursive --strategy-option theirs ${b...
119, 29934
git, git-rebase
<h1>How do I select a merge strategy for a git rebase?</h1> <p><code>git-rebase</code> man page mentions <code>-X&lt;option&gt;</code> can be passed to <code>git-merge</code>. When/how exactly?</p> <p>I'd like to rebase by applying patches with <em>recursive</em> strategy and <em>theirs</em> option (apply whatever sti...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,672
git
# How do I select a merge strategy for a git rebase? `git-rebase` man page mentions `-X<option>` can be passed to `git-merge`. When/how exactly? I'd like to rebase by applying patches with *recursive* strategy and *theirs* option (apply whatever sticks, rather than skipping entire conflicting commits). I don't want m...
You can use this with Git v1.7.3 or later versions. ``` git rebase --strategy-option theirs ${branch} # Long option git rebase -X theirs ${branch} # Short option ``` (which is a short for `git rebase --strategy recursive --strategy-option theirs ${branch}` as stated by the [documentation](https://git-scm.com/docs/git...
4830056
How to discard all changes made to a branch?
195
2011-01-28 15:41:10
<p>I'm working in a branch (i.e. <code>design</code>) and I've made a number of changes, but I need to discard them all and reset it to match the repository version. I thought <code>git checkout design</code> would do it, but it just tells me I'm already in branch <code>design</code> and that I have 3 modified files.</...
424,372
422,109
2024-08-15 12:50:43
4,830,072
313
2011-01-28 15:42:05
35,060
2015-09-23 18:03:42
https://stackoverflow.com/q/4830056
https://stackoverflow.com/a/4830072
<p>Note: You <strong>CANNOT UNDO</strong> this.</p> <p>Try <code>git checkout -f</code> this will discard any local changes which are <em>not</em> committed in <strong>ALL</strong> branches and master.</p>
<p>Note: You <strong>CANNOT UNDO</strong> this.</p> <p>Try <code>git checkout -f</code> this will discard any local changes which are <em>not</em> committed in <strong>ALL</strong> branches and master.</p>
119, 1879, 12196
branch, git, rollback
<h1>How to discard all changes made to a branch?</h1> <p>I'm working in a branch (i.e. <code>design</code>) and I've made a number of changes, but I need to discard them all and reset it to match the repository version. I thought <code>git checkout design</code> would do it, but it just tells me I'm already in branch <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,674
git
# How to discard all changes made to a branch? I'm working in a branch (i.e. `design`) and I've made a number of changes, but I need to discard them all and reset it to match the repository version. I thought `git checkout design` would do it, but it just tells me I'm already in branch `design` and that I have 3 modif...
Note: You **CANNOT UNDO** this. Try `git checkout -f` this will discard any local changes which are *not* committed in **ALL** branches and master.
28375418
Git: How to pull a single file from a server repository in Git?
187
2015-02-06 21:52:00
<p>I am working on a site with a server running Git. I am using Git for deployment (not GitHub). This was set up prior to my involvement using a <a href="https://danbarber.me/using-git-for-deployment/" rel="noreferrer">hook method</a>, and I referred to <a href="https://stackoverflow.com/questions/11245424/pull-single-...
478,642
2,514,911
2023-09-19 20:46:14
28,375,437
313
2015-02-06 21:53:26
3,253,688
2021-05-26 19:07:35
https://stackoverflow.com/q/28375418
https://stackoverflow.com/a/28375437
<h2>Short Answer</h2> <p>It is possible to do (in the deployed repository):</p> <pre><code>git fetch --all // git fetch will download all the recent changes, but it will not put it in your current checked out code (working area). </code></pre> <p>Followed by:</p> <pre><code>git checkout origin/master -- path/to/file //...
<h2>Short Answer</h2> <p>It is possible to do (in the deployed repository):</p> <pre><code>git fetch --all // git fetch will download all the recent changes, but it will not put it in your current checked out code (working area). </code></pre> <p>Followed by:</p> <pre><code>git checkout origin/master -- path/to/file //...
119, 28896, 28897, 33720
git, git-fetch, git-merge, git-pull
<h1>Git: How to pull a single file from a server repository in Git?</h1> <p>I am working on a site with a server running Git. I am using Git for deployment (not GitHub). This was set up prior to my involvement using a <a href="https://danbarber.me/using-git-for-deployment/" rel="noreferrer">hook method</a>, and I refer...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,675
git
# Git: How to pull a single file from a server repository in Git? I am working on a site with a server running Git. I am using Git for deployment (not GitHub). This was set up prior to my involvement using a [hook method](https://danbarber.me/using-git-for-deployment/), and I referred to [this question](https://stacko...
## Short Answer It is possible to do (in the deployed repository): ``` git fetch --all // git fetch will download all the recent changes, but it will not put it in your current checked out code (working area). ``` Followed by: ``` git checkout origin/master -- path/to/file // git checkout <local repo name (default ...
1981830
Undo part of unstaged changes in git
183
2009-12-30 19:00:27
<p>How do I undo parts of my unstaged changes in git but keep the rest as unstaged? The way I figured out is:</p> <pre><code>git commit --interactive # Choose the parts I want to delete # Commit the changes git stash git rebase -i master # (I am an ancestor of master) # Delete the line of the most recent commit git s...
62,389
161,801
2016-01-20 10:48:54
1,981,868
313
2009-12-30 19:08:14
69,755
2010-01-03 17:55:06
https://stackoverflow.com/q/1981830
https://stackoverflow.com/a/1981868
<p>You can use <a href="http://git-scm.com/docs/git-checkout" rel="noreferrer"><code>git checkout -p</code></a>, which lets you choose individual hunks from the diff between your working copy and index to revert. Likewise, <a href="http://www.kernel.org/pub/software/scm/git/docs/git-add.html" rel="noreferrer"><code>git...
<p>You can use <a href="http://git-scm.com/docs/git-checkout" rel="noreferrer"><code>git checkout -p</code></a>, which lets you choose individual hunks from the diff between your working copy and index to revert. Likewise, <a href="http://www.kernel.org/pub/software/scm/git/docs/git-add.html" rel="noreferrer"><code>git...
119
git
<h1>Undo part of unstaged changes in git</h1> <p>How do I undo parts of my unstaged changes in git but keep the rest as unstaged? The way I figured out is:</p> <pre><code>git commit --interactive # Choose the parts I want to delete # Commit the changes git stash git rebase -i master # (I am an ancestor of master) # D...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,676
git
# Undo part of unstaged changes in git How do I undo parts of my unstaged changes in git but keep the rest as unstaged? The way I figured out is: ``` git commit --interactive # Choose the parts I want to delete # Commit the changes git stash git rebase -i master # (I am an ancestor of master) # Delete the line of the...
You can use [`git checkout -p`](http://git-scm.com/docs/git-checkout), which lets you choose individual hunks from the diff between your working copy and index to revert. Likewise, [`git add -p`](http://www.kernel.org/pub/software/scm/git/docs/git-add.html) allows you to choose hunks to add to the index, and [`git rese...
10176875
Add .gitignore to gitignore
255
2012-04-16 15:16:06
<p>Is it possible to add the <code>.gitignore</code> file to <code>.gitignore</code> itself?</p> <pre><code>.gitignore </code></pre> <p>Doesn't work though</p> <p>I don't want to see it in edited files</p>
170,983
null
2023-06-24 14:46:23
10,177,000
312
2012-04-16 15:23:49
1,227,116
2019-05-02 13:22:22
https://stackoverflow.com/q/10176875
https://stackoverflow.com/a/10177000
<p>The <code>.gitignore</code> file's purpose is to prevent everyone who collaborates on a project from accidentally commiting some common files in a project, such as generated cache files. Therefore you should not ignore <code>.gitignore</code>, since it's supposed to be included in the repository.</p> <p>If you want...
<p>The <code>.gitignore</code> file's purpose is to prevent everyone who collaborates on a project from accidentally commiting some common files in a project, such as generated cache files. Therefore you should not ignore <code>.gitignore</code>, since it's supposed to be included in the repository.</p> <p>If you want...
119, 25056
git, gitignore
<h1>Add .gitignore to gitignore</h1> <p>Is it possible to add the <code>.gitignore</code> file to <code>.gitignore</code> itself?</p> <pre><code>.gitignore </code></pre> <p>Doesn't work though</p> <p>I don't want to see it in edited files</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,677
git
# Add .gitignore to gitignore Is it possible to add the `.gitignore` file to `.gitignore` itself? ``` .gitignore ``` Doesn't work though I don't want to see it in edited files
The `.gitignore` file's purpose is to prevent everyone who collaborates on a project from accidentally commiting some common files in a project, such as generated cache files. Therefore you should not ignore `.gitignore`, since it's supposed to be included in the repository. If you want to ignore files in just one rep...
14410421
Git rebase merge conflict cannot continue
187
2013-01-19 02:03:56
<p>I'm trying to rebase 'dev' to catch up to 'master' branch. </p> <pre><code>$ git checkout dev $ git rebase master First, rewinding head to replay your work on top of it... Applying: Corrected compilation problems that came from conversion from SVN. Using index info to reconstruct a base tree... M src/com/.....
164,342
1,044,799
2023-05-04 12:32:00
14,410,559
312
2013-01-19 02:31:31
235,243
2017-08-31 03:53:00
https://stackoverflow.com/q/14410421
https://stackoverflow.com/a/14410559
<p>There are a couple situations where I've seen <code>rebase</code> get stuck. One is if the changes become null (a commit has changes that were already made previously in the rebase) in which case you may have to use <code>git rebase --skip</code>.</p> <p>It's pretty easy to tell. If you do <code>git status</code> i...
<p>There are a couple situations where I've seen <code>rebase</code> get stuck. One is if the changes become null (a commit has changes that were already made previously in the rebase) in which case you may have to use <code>git rebase --skip</code>.</p> <p>It's pretty easy to tell. If you do <code>git status</code> i...
119, 29934
git, git-rebase
<h1>Git rebase merge conflict cannot continue</h1> <p>I'm trying to rebase 'dev' to catch up to 'master' branch. </p> <pre><code>$ git checkout dev $ git rebase master First, rewinding head to replay your work on top of it... Applying: Corrected compilation problems that came from conversion from SVN. Using index in...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,678
git
# Git rebase merge conflict cannot continue I'm trying to rebase 'dev' to catch up to 'master' branch. ``` $ git checkout dev $ git rebase master First, rewinding head to replay your work on top of it... Applying: Corrected compilation problems that came from conversion from SVN. Using index info to reconstruct a b...
There are a couple situations where I've seen `rebase` get stuck. One is if the changes become null (a commit has changes that were already made previously in the rebase) in which case you may have to use `git rebase --skip`. It's pretty easy to tell. If you do `git status` it should show no changes. If so just skip i...
307828
How do you fix a bad merge, and replay your good commits onto a fixed merge?
442
2008-11-21 04:11:21
<p>I accidentally committed an unwanted file (<code>filename.orig</code> while resolving a merge) to my repository several commits ago, without me noticing it until now. I want to completely delete the file from the repository history. </p> <p>Is it possible to rewrite the change history such that <code>filename.orig<...
364,903
27,314
2023-10-30 07:17:02
308,684
311
2008-11-21 13:02:21
19,563
2014-04-04 00:20:19
https://stackoverflow.com/q/307828
https://stackoverflow.com/a/308684
<p><strong>Please don't use this recipe if your situation is not the one described in the question. This recipe is for fixing a bad merge, and replaying your good commits onto a fixed merge.</strong></p> <p>Although <code>filter-branch</code> will do what you want, it is quite a complex command and I would probably ch...
<p><strong>Please don't use this recipe if your situation is not the one described in the question. This recipe is for fixing a bad merge, and replaying your good commits onto a fixed merge.</strong></p> <p>Although <code>filter-branch</code> will do what you want, it is quite a complex command and I would probably ch...
119, 46509, 91259, 112901
git, git-filter-branch, git-rewrite-history, git-rm
<h1>How do you fix a bad merge, and replay your good commits onto a fixed merge?</h1> <p>I accidentally committed an unwanted file (<code>filename.orig</code> while resolving a merge) to my repository several commits ago, without me noticing it until now. I want to completely delete the file from the repository history...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,679
git
# How do you fix a bad merge, and replay your good commits onto a fixed merge? I accidentally committed an unwanted file (`filename.orig` while resolving a merge) to my repository several commits ago, without me noticing it until now. I want to completely delete the file from the repository history. Is it possible to...
**Please don't use this recipe if your situation is not the one described in the question. This recipe is for fixing a bad merge, and replaying your good commits onto a fixed merge.** Although `filter-branch` will do what you want, it is quite a complex command and I would probably choose to do this with `git rebase`....
11168141
Find which commit is currently checked out in Git
264
2012-06-23 08:51:38
<p>I'm in the middle of a <code>git bisect</code> session.</p> <p>What's the command to find out which commit (SHA-1 hash value) I am currently on? <code>git status</code> does not provide this.</p> <p>I guess calling <code>git log</code> and looking at first entry works?</p>
334,374
340,947
2025-05-13 20:50:06
18,160,212
311
2013-08-10 08:46:01
null
2016-11-30 12:57:35
https://stackoverflow.com/q/11168141
https://stackoverflow.com/a/18160212
<p>You have at least 5 different ways to view the commit you currently have checked out into your working copy during a <code>git bisect</code> session (<strong>note that options 1-4 will also work when you're not doing a bisect</strong>):</p> <ol> <li><code>git show</code>.</li> <li><code>git log -1</code>.</li> <li>...
<p>You have at least 5 different ways to view the commit you currently have checked out into your working copy during a <code>git bisect</code> session (<strong>note that options 1-4 will also work when you're not doing a bisect</strong>):</p> <ol> <li><code>git show</code>.</li> <li><code>git log -1</code>.</li> <li>...
119
git
<h1>Find which commit is currently checked out in Git</h1> <p>I'm in the middle of a <code>git bisect</code> session.</p> <p>What's the command to find out which commit (SHA-1 hash value) I am currently on? <code>git status</code> does not provide this.</p> <p>I guess calling <code>git log</code> and looking at first e...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,682
git
# Find which commit is currently checked out in Git I'm in the middle of a `git bisect` session. What's the command to find out which commit (SHA-1 hash value) I am currently on? `git status` does not provide this. I guess calling `git log` and looking at first entry works?
You have at least 5 different ways to view the commit you currently have checked out into your working copy during a `git bisect` session (**note that options 1-4 will also work when you're not doing a bisect**): 1. `git show`. 2. `git log -1`. 3. Bash prompt. 4. `git status`. 5. `git bisect visualize`. I'll explain ...
8196544
What are the git concepts of HEAD, master, origin?
269
2011-11-19 19:11:12
<p>As I'm learning about git, I keep coming across the terms HEAD, master, origin, and I'm not sure what the differences are. If I understand correctly, HEAD is always equal to the latest revision? And if so, is that the latest revision of the whole repository, or of a specific branch or tag? This is so confusing. I've...
160,294
779,159
2018-07-19 15:08:11
8,196,578
310
2011-11-19 19:18:15
194,940
2018-07-19 15:08:11
https://stackoverflow.com/q/8196544
https://stackoverflow.com/a/8196578
<p>I highly recommend the book <a href="http://git-scm.com/book" rel="noreferrer">"Pro Git" by Scott Chacon</a>. Take time and really read it, while exploring an actual git repo as you do. </p> <p><strong>HEAD</strong>: the current commit your repo is on. Most of the time <code>HEAD</code> points to the latest commit...
<p>I highly recommend the book <a href="http://git-scm.com/book" rel="noreferrer">"Pro Git" by Scott Chacon</a>. Take time and really read it, while exploring an actual git repo as you do. </p> <p><strong>HEAD</strong>: the current commit your repo is on. Most of the time <code>HEAD</code> points to the latest commit...
119
git
<h1>What are the git concepts of HEAD, master, origin?</h1> <p>As I'm learning about git, I keep coming across the terms HEAD, master, origin, and I'm not sure what the differences are. If I understand correctly, HEAD is always equal to the latest revision? And if so, is that the latest revision of the whole repository...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,683
git
# What are the git concepts of HEAD, master, origin? As I'm learning about git, I keep coming across the terms HEAD, master, origin, and I'm not sure what the differences are. If I understand correctly, HEAD is always equal to the latest revision? And if so, is that the latest revision of the whole repository, or of a...
I highly recommend the book ["Pro Git" by Scott Chacon](http://git-scm.com/book). Take time and really read it, while exploring an actual git repo as you do. **HEAD**: the current commit your repo is on. Most of the time `HEAD` points to the latest commit in your current branch, but that doesn't have to be the case. `...
2988088
Do git tags get pushed as well?
251
2010-06-07 08:44:58
<p>Since I created my repository it appears that the tags I have been creating are not pushed to the repository. When I do <code>git tag</code> on the local directory all the tags are present, but when I logon to the remote repository and do a <code>git tag</code>, only the first few show up.</p> <p>What could the pro...
113,461
172,406
2023-06-02 19:19:52
2,988,099
310
2010-06-07 08:48:47
351,327
2012-05-16 11:12:19
https://stackoverflow.com/q/2988088
https://stackoverflow.com/a/2988099
<p>You could do this:</p> <pre><code>git push --tags </code></pre>
<p>You could do this:</p> <pre><code>git push --tags </code></pre>
119, 60718
git, git-tag
<h1>Do git tags get pushed as well?</h1> <p>Since I created my repository it appears that the tags I have been creating are not pushed to the repository. When I do <code>git tag</code> on the local directory all the tags are present, but when I logon to the remote repository and do a <code>git tag</code>, only the firs...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,684
git
# Do git tags get pushed as well? Since I created my repository it appears that the tags I have been creating are not pushed to the repository. When I do `git tag` on the local directory all the tags are present, but when I logon to the remote repository and do a `git tag`, only the first few show up. What could the ...
You could do this: ``` git push --tags ```
11542687
git: How to ignore all present untracked files?
176
2012-07-18 13:35:39
<p>Is there a handy way to ignore all untracked files and folders in a git repository?<br/> (I know about the <code>.gitignore</code>.)</p> <p>So <code>git status</code> would provide a clean result again.</p>
254,138
805,284
2025-02-04 23:53:30
15,142,010
310
2013-02-28 17:36:12
813,810
2024-03-18 06:14:40
https://stackoverflow.com/q/11542687
https://stackoverflow.com/a/15142010
<p>As already been said, to exclude from status just use:</p> <pre><code>git status -uno # must be &quot;-uno&quot; , not &quot;-u no&quot; </code></pre> <p>If you instead want to permanently ignore currently untracked files you can, from the root of your project, launch:</p> <pre><code>git status --porcelain | grep '...
<p>As already been said, to exclude from status just use:</p> <pre><code>git status -uno # must be &quot;-uno&quot; , not &quot;-u no&quot; </code></pre> <p>If you instead want to permanently ignore currently untracked files you can, from the root of your project, launch:</p> <pre><code>git status --porcelain | grep '...
119, 25056
git, gitignore
<h1>git: How to ignore all present untracked files?</h1> <p>Is there a handy way to ignore all untracked files and folders in a git repository?<br/> (I know about the <code>.gitignore</code>.)</p> <p>So <code>git status</code> would provide a clean result again.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,685
git
# git: How to ignore all present untracked files? Is there a handy way to ignore all untracked files and folders in a git repository? (I know about the `.gitignore`.) So `git status` would provide a clean result again.
As already been said, to exclude from status just use: ``` git status -uno # must be "-uno" , not "-u no" ``` If you instead want to permanently ignore currently untracked files you can, from the root of your project, launch: ``` git status --porcelain | grep '^??' | cut -c4- >> .gitignore ``` Every subsequent cal...
2527355
Using the slash character in Git branch name
317
2010-03-26 23:07:32
<p>I'm pretty sure I saw somewhere in a popular Git project the branches had a pattern like "feature/xyz".</p> <p>However when I try to create a branch with the slash character, I get an error:</p> <pre><code>$ git branch labs/feature error: unable to resolve reference refs/heads/labs/feature: Not a directory fatal: ...
208,683
null
2025-11-07 19:33:49
2,527,452
309
2010-03-26 23:30:52
6,309
2025-11-07 19:33:49
https://stackoverflow.com/q/2527355
https://stackoverflow.com/a/2527452
<p>Are you sure branch <code>labs</code> does not already exist (as in <a href="http://osdir.com/ml/git/2009-11/msg01037.html" rel="nofollow noreferrer">this thread</a>)?</p> <blockquote> <p><strong>You can't have both a file, and a directory with the same name.</strong></p> <p>You're trying to get git to do basically ...
<p>Are you sure branch <code>labs</code> does not already exist (as in <a href="http://osdir.com/ml/git/2009-11/msg01037.html" rel="nofollow noreferrer">this thread</a>)?</p> <blockquote> <p><strong>You can't have both a file, and a directory with the same name.</strong></p> <p>You're trying to get git to do basically ...
119, 1879
branch, git
<h1>Using the slash character in Git branch name</h1> <p>I'm pretty sure I saw somewhere in a popular Git project the branches had a pattern like "feature/xyz".</p> <p>However when I try to create a branch with the slash character, I get an error:</p> <pre><code>$ git branch labs/feature error: unable to resolve refe...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,686
git
# Using the slash character in Git branch name I'm pretty sure I saw somewhere in a popular Git project the branches had a pattern like "feature/xyz". However when I try to create a branch with the slash character, I get an error: ``` $ git branch labs/feature error: unable to resolve reference refs/heads/labs/featu...
Are you sure branch `labs` does not already exist (as in [this thread](http://osdir.com/ml/git/2009-11/msg01037.html))? > **You can't have both a file, and a directory with the same name.** > > You're trying to get git to do basically this: > > ``` > % cd .git/refs/heads > % ls -l > total 0 > -rw-rw-r-- 1 jhe jhe 41 2...
9189575
git submodule tracking latest
190
2012-02-08 08:00:41
<p>We are moving our (huge) project to git and we are thinking about using submodules. Our plan is to have three different heads in the superproject:</p> <blockquote> <p>release, stable, latest</p> </blockquote> <p>The project leads will handle the release and stable branches. They will move the submodules as required....
165,956
226,889
2021-08-21 11:50:40
9,189,815
309
2012-02-08 08:24:48
6,309
2021-08-21 11:50:40
https://stackoverflow.com/q/9189575
https://stackoverflow.com/a/9189815
<p>Edit (2020.12.28): GitHub change default <strong>master</strong> branch to <strong>main</strong> branch since October 2020. See <a href="https://github.com/github/renaming" rel="noreferrer">https://github.com/github/renaming</a><br /> This answer below still reflect the old naming convention.</p> <hr /> <p>Update Ma...
<p>Edit (2020.12.28): GitHub change default <strong>master</strong> branch to <strong>main</strong> branch since October 2020. See <a href="https://github.com/github/renaming" rel="noreferrer">https://github.com/github/renaming</a><br /> This answer below still reflect the old naming convention.</p> <hr /> <p>Update Ma...
119, 41612, 96541
git, git-submodules, git-track
<h1>git submodule tracking latest</h1> <p>We are moving our (huge) project to git and we are thinking about using submodules. Our plan is to have three different heads in the superproject:</p> <blockquote> <p>release, stable, latest</p> </blockquote> <p>The project leads will handle the release and stable branches. The...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,687
git
# git submodule tracking latest We are moving our (huge) project to git and we are thinking about using submodules. Our plan is to have three different heads in the superproject: > release, stable, latest The project leads will handle the release and stable branches. They will move the submodules as required. The i...
Edit (2020.12.28): GitHub change default **master** branch to **main** branch since October 2020. See <https://github.com/github/renaming> This answer below still reflect the old naming convention. --- Update March 2013 [Git 1.8.2](https://github.com/git/git/blob/master/Documentation/RelNotes/1.8.2.txt) added the ...
26376832
Why does git say "Pull is not possible because you have unmerged files"?
332
2014-10-15 07:28:00
<p>When I try to pull in my project directory in the terminal, I see the following error:</p> <pre><code>harsukh@harsukh-desktop:~/Sites/branch1$ git pull origin master U app/config/app.php U app/config/database.php U app/routes.php Pull is not possible because you have unmerged files. Please, fix them up in the work ...
818,994
4,120,409
2023-12-18 02:21:45
27,187,110
308
2014-11-28 10:51:44
1,860,929
2022-07-18 13:12:42
https://stackoverflow.com/q/26376832
https://stackoverflow.com/a/27187110
<p>What is currently happening is, that you have a certain set of files, which you have tried merging earlier, but they threw up merge conflicts. Ideally, if one gets a merge conflict, they should resolve them manually, and commit the changes using <code>git add file.name &amp;&amp; git commit -m &quot;removed merge co...
<p>What is currently happening is, that you have a certain set of files, which you have tried merging earlier, but they threw up merge conflicts. Ideally, if one gets a merge conflict, they should resolve them manually, and commit the changes using <code>git add file.name &amp;&amp; git commit -m &quot;removed merge co...
119, 28896, 33720, 62599
git, git-fetch, git-pull, merge-conflict-resolution
<h1>Why does git say "Pull is not possible because you have unmerged files"?</h1> <p>When I try to pull in my project directory in the terminal, I see the following error:</p> <pre><code>harsukh@harsukh-desktop:~/Sites/branch1$ git pull origin master U app/config/app.php U app/config/database.php U app/routes.php Pull...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,689
git
# Why does git say "Pull is not possible because you have unmerged files"? When I try to pull in my project directory in the terminal, I see the following error: ``` harsukh@harsukh-desktop:~/Sites/branch1$ git pull origin master U app/config/app.php U app/config/database.php U app/routes.php Pull is not possible bec...
What is currently happening is, that you have a certain set of files, which you have tried merging earlier, but they threw up merge conflicts. Ideally, if one gets a merge conflict, they should resolve them manually, and commit the changes using `git add file.name && git commit -m "removed merge conflicts"`. Now, anoth...
6269927
How can I list all tags in my Git repository by the date they were created?
238
2011-06-07 18:30:50
<p>I need some way to list all tags in my system by the date they were created but am not sure if I can get that data via git-log. Ideas?</p>
116,476
105,698
2024-04-02 14:39:32
6,270,112
308
2011-06-07 18:47:02
19,750
2020-01-31 17:23:33
https://stackoverflow.com/q/6269927
https://stackoverflow.com/a/6270112
<p>Sorting by tag creation date works with annotated and lightweight tags:</p> <pre><code>git for-each-ref --sort=creatordate --format '%(refname) %(creatordate)' refs/tags </code></pre>
<p>Sorting by tag creation date works with annotated and lightweight tags:</p> <pre><code>git for-each-ref --sort=creatordate --format '%(refname) %(creatordate)' refs/tags </code></pre>
119
git
<h1>How can I list all tags in my Git repository by the date they were created?</h1> <p>I need some way to list all tags in my system by the date they were created but am not sure if I can get that data via git-log. Ideas?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,690
git
# How can I list all tags in my Git repository by the date they were created? I need some way to list all tags in my system by the date they were created but am not sure if I can get that data via git-log. Ideas?
Sorting by tag creation date works with annotated and lightweight tags: ``` git for-each-ref --sort=creatordate --format '%(refname) %(creatordate)' refs/tags ```
9776527
Merging without whitespace conflicts
227
2012-03-19 19:24:41
<p>I've got a problem, where a large commit which changes about a thousand lines of code, removing whitespace from the end of lines and removing spaces before tabs.</p> <p>There are also about 50 pull requests for this project, in which all will get conflicts, when my commit is merged. Is there any way that git can be ...
106,686
902,207
2022-03-16 02:40:56
9,784,089
307
2012-03-20 09:21:32
6,309
2016-05-20 15:47:34
https://stackoverflow.com/q/9776527
https://stackoverflow.com/a/9784089
<pre><code> git merge -Xignore-all-space </code></pre> <p>Or (more precise)</p> <pre><code> git merge -Xignore-space-change </code></pre> <p>should be enough to ignore all space related conflicts during the merge.</p> <p>See <a href="http://linux.die.net/man/1/git-diff" rel="noreferrer">git diff</a>:</p> <pre><cod...
<pre><code> git merge -Xignore-all-space </code></pre> <p>Or (more precise)</p> <pre><code> git merge -Xignore-space-change </code></pre> <p>should be enough to ignore all space related conflicts during the merge.</p> <p>See <a href="http://linux.die.net/man/1/git-diff" rel="noreferrer">git diff</a>:</p> <pre><cod...
119, 1084, 28897
git, git-merge, whitespace
<h1>Merging without whitespace conflicts</h1> <p>I've got a problem, where a large commit which changes about a thousand lines of code, removing whitespace from the end of lines and removing spaces before tabs.</p> <p>There are also about 50 pull requests for this project, in which all will get conflicts, when my commi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,692
git
# Merging without whitespace conflicts I've got a problem, where a large commit which changes about a thousand lines of code, removing whitespace from the end of lines and removing spaces before tabs. There are also about 50 pull requests for this project, in which all will get conflicts, when my commit is merged. Is...
``` git merge -Xignore-all-space ``` Or (more precise) ``` git merge -Xignore-space-change ``` should be enough to ignore all space related conflicts during the merge. See [git diff](http://linux.die.net/man/1/git-diff): ``` --ignore-space-change ``` > Ignore changes in amount of whitespace. > This ignores wh...
296975
How do I tell git-svn about a remote branch created after I fetched the repo?
206
2008-11-17 21:19:50
<p>I'm using <code>git-svn</code> to work against my company's central Subversion repository. We've recently created a new feature branch in the central repo. </p> <p>How do I tell Git about it? When I run <code>git branch -r</code> I can only see the branches that existed when I ran <code>fetch</code> against the Sub...
82,386
4,203
2019-10-30 13:48:54
1,430,782
307
2009-09-16 03:23:25
76,516
2009-09-16 03:23:25
https://stackoverflow.com/q/296975
https://stackoverflow.com/a/1430782
<p>You can manually add the remote branch,</p> <pre><code>git config --add svn-remote.newbranch.url https://svn/path_to_newbranch/ git config --add svn-remote.newbranch.fetch :refs/remotes/newbranch git svn fetch newbranch [-r&lt;rev&gt;] git checkout -b local-newbranch -t newbranch git svn rebase newbranch </code></p...
<p>You can manually add the remote branch,</p> <pre><code>git config --add svn-remote.newbranch.url https://svn/path_to_newbranch/ git config --add svn-remote.newbranch.fetch :refs/remotes/newbranch git svn fetch newbranch [-r&lt;rev&gt;] git checkout -b local-newbranch -t newbranch git svn rebase newbranch </code></p...
119, 6452
git, git-svn
<h1>How do I tell git-svn about a remote branch created after I fetched the repo?</h1> <p>I'm using <code>git-svn</code> to work against my company's central Subversion repository. We've recently created a new feature branch in the central repo. </p> <p>How do I tell Git about it? When I run <code>git branch -r</code>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,693
git
# How do I tell git-svn about a remote branch created after I fetched the repo? I'm using `git-svn` to work against my company's central Subversion repository. We've recently created a new feature branch in the central repo. How do I tell Git about it? When I run `git branch -r` I can only see the branches that exist...
You can manually add the remote branch, ``` git config --add svn-remote.newbranch.url https://svn/path_to_newbranch/ git config --add svn-remote.newbranch.fetch :refs/remotes/newbranch git svn fetch newbranch [-r<rev>] git checkout -b local-newbranch -t newbranch git svn rebase newbranch ```
41863484
Clear git local cache
201
2017-01-25 23:19:32
<p>I have a Webstorm project that I was about to commit, but before pressing the commit button in the Git Windows GUI, I remembered that I don't want to commit my <code>.idea</code> folder content. </p> <p>So I used the website that auto generates <code>.gitignores</code> for certain IDEs and added it to my <code>.git...
641,980
7,169,206
2025-11-19 14:28:02
41,863,575
307
2017-01-25 23:27:21
1,755,598
2020-01-28 23:11:33
https://stackoverflow.com/q/41863484
https://stackoverflow.com/a/41863575
<blockquote> <p>All .idea files that are explicitly ignored are still showing up to commit</p> </blockquote> <p>you have to remove them from the staging area</p> <pre><code>git rm --cached .idea </code></pre> <p>now you have to commit those changes and they will be ignored from this point on.<br> Once git start to...
<blockquote> <p>All .idea files that are explicitly ignored are still showing up to commit</p> </blockquote> <p>you have to remove them from the staging area</p> <pre><code>git rm --cached .idea </code></pre> <p>now you have to commit those changes and they will be ignored from this point on.<br> Once git start to...
119
git
<h1>Clear git local cache</h1> <p>I have a Webstorm project that I was about to commit, but before pressing the commit button in the Git Windows GUI, I remembered that I don't want to commit my <code>.idea</code> folder content. </p> <p>So I used the website that auto generates <code>.gitignores</code> for certain IDE...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,694
git
# Clear git local cache I have a Webstorm project that I was about to commit, but before pressing the commit button in the Git Windows GUI, I remembered that I don't want to commit my `.idea` folder content. So I used the website that auto generates `.gitignores` for certain IDEs and added it to my `.gitignore` file....
> All .idea files that are explicitly ignored are still showing up to commit you have to remove them from the staging area ``` git rm --cached .idea ``` now you have to commit those changes and they will be ignored from this point on. Once git start to track changes it will not "stop" tracking them even if they we...
25322335
Git change branch when file of same name is present
184
2014-08-15 06:50:21
<p>I have in my git repo, a file named xyz. Coincidently, I also have a branch named xyz. Presently I am on master, but I want to checkout to branch xyz. The command to be used is simple</p> <pre><code>$ git checkout xyz </code></pre> <p>But this would checkout the file <code>xyz</code> to the present HEAD. How would...
105,887
2,801,303
2023-02-15 19:11:23
25,322,508
307
2014-08-15 07:07:32
6,309
2019-10-30 21:50:10
https://stackoverflow.com/q/25322335
https://stackoverflow.com/a/25322508
<p>As illustrated by <a href="https://github.com/git/git/commit/a047fafc7866cc4087201e284dc1f53e8f9a32d5" rel="noreferrer">commit a047faf</a> (git 1.8.4.3+), you can also try:</p> <pre><code>git checkout xyz -- </code></pre> <p>(Note: the <a href="https://stackoverflow.com/a/54058395/6309">error message will be clear...
<p>As illustrated by <a href="https://github.com/git/git/commit/a047fafc7866cc4087201e284dc1f53e8f9a32d5" rel="noreferrer">commit a047faf</a> (git 1.8.4.3+), you can also try:</p> <pre><code>git checkout xyz -- </code></pre> <p>(Note: the <a href="https://stackoverflow.com/a/54058395/6309">error message will be clear...
119, 37230, 76220
git, git-branch, git-checkout
<h1>Git change branch when file of same name is present</h1> <p>I have in my git repo, a file named xyz. Coincidently, I also have a branch named xyz. Presently I am on master, but I want to checkout to branch xyz. The command to be used is simple</p> <pre><code>$ git checkout xyz </code></pre> <p>But this would chec...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,695
git
# Git change branch when file of same name is present I have in my git repo, a file named xyz. Coincidently, I also have a branch named xyz. Presently I am on master, but I want to checkout to branch xyz. The command to be used is simple ``` $ git checkout xyz ``` But this would checkout the file `xyz` to the presen...
As illustrated by [commit a047faf](https://github.com/git/git/commit/a047fafc7866cc4087201e284dc1f53e8f9a32d5) (git 1.8.4.3+), you can also try: ``` git checkout xyz -- ``` (Note: the [error message will be clearer with Git 2.21, Q1 2019](https://stackoverflow.com/a/54058395/6309)) That would make clear that the `xy...
55515678
How do I export my project as a .zip of git repository?
163
2019-04-04 12:08:53
<p>I was recently asked to export as a <code>.zip</code> file one of my projects on my Git repository.</p> <p>I have actually never had to do this in the 4 years I have been using Git.</p> <p>I would prefer an answer that is all done inside command line terminal.</p>
106,433
6,719,819
2023-10-28 07:36:46
55,515,739
307
2019-04-04 12:12:02
11,239,008
2023-02-01 01:29:21
https://stackoverflow.com/q/55515678
https://stackoverflow.com/a/55515739
<p><code>git archive --format=zip --output /full/path/to/zipfile.zip master</code></p>
<p><code>git archive --format=zip --output /full/path/to/zipfile.zip master</code></p>
119, 881, 4167
export, git, zip
<h1>How do I export my project as a .zip of git repository?</h1> <p>I was recently asked to export as a <code>.zip</code> file one of my projects on my Git repository.</p> <p>I have actually never had to do this in the 4 years I have been using Git.</p> <p>I would prefer an answer that is all done inside command line...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,696
git
# How do I export my project as a .zip of git repository? I was recently asked to export as a `.zip` file one of my projects on my Git repository. I have actually never had to do this in the 4 years I have been using Git. I would prefer an answer that is all done inside command line terminal.
`git archive --format=zip --output /full/path/to/zipfile.zip master`
16037787
Convert Mercurial project to Git
304
2013-04-16 13:01:07
<p>I need to convert a mercurial project to a git project, but I would like to keep the commit history intact. My current solution was to just remove hg related files and then git init &amp;&amp; add manually the files I needed, but that would not keep the history. Are there any solutions to this?</p>
131,261
253,805
2020-04-30 19:40:07
16,037,861
305
2013-04-16 13:04:42
1,616,951
2020-04-30 19:40:07
https://stackoverflow.com/q/16037787
https://stackoverflow.com/a/16037861
<p>You can try using <a href="https://github.com/frej/fast-export" rel="noreferrer">fast-export</a>:</p> <pre><code>cd ~ git clone https://github.com/frej/fast-export.git git init git_repo cd git_repo ~/fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo git checkout HEAD </code></pre> <p>Also have a look at...
<p>You can try using <a href="https://github.com/frej/fast-export" rel="noreferrer">fast-export</a>:</p> <pre><code>cd ~ git clone https://github.com/frej/fast-export.git git init git_repo cd git_repo ~/fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo git checkout HEAD </code></pre> <p>Also have a look at...
119, 802
git, mercurial
<h1>Convert Mercurial project to Git</h1> <p>I need to convert a mercurial project to a git project, but I would like to keep the commit history intact. My current solution was to just remove hg related files and then git init &amp;&amp; add manually the files I needed, but that would not keep the history. Are there an...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,700
git
# Convert Mercurial project to Git I need to convert a mercurial project to a git project, but I would like to keep the commit history intact. My current solution was to just remove hg related files and then git init && add manually the files I needed, but that would not keep the history. Are there any solutions to th...
You can try using [fast-export](https://github.com/frej/fast-export): ``` cd ~ git clone https://github.com/frej/fast-export.git git init git_repo cd git_repo ~/fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo git checkout HEAD ``` Also have a look at [this SO question](https://stackoverflow.com/questions...
2421011
Output of git branch in tree like fashion
242
2010-03-10 22:10:26
<p>Right now, when I type "git branch"</p> <p>it lists my branches in an arbitrary order.</p> <p>What I would prefer would be if "git branch" listed my output in a tree like fasion, somethign like:</p> <pre><code>master |-- foo |-- foo1 |-- foo2 |-- bar |-- bar4 </code></pre> <p>Where here, foo &amp; bar were...
276,658
247,265
2024-05-28 15:11:56
2,421,063
305
2010-03-10 22:16:38
6,309
2015-01-14 19:24:53
https://stackoverflow.com/q/2421011
https://stackoverflow.com/a/2421063
<p>The <a href="https://stackoverflow.com/a/9726638/6309">answer below</a> uses <a href="http://git-scm.com/docs/git-log" rel="noreferrer"><code>git log</code></a>:</p> <p>I mentioned a similar approach in 2009 with "<a href="https://stackoverflow.com/a/1064431/6309">Unable to show a Git tree in terminal</a>":</p> <p...
<p>The <a href="https://stackoverflow.com/a/9726638/6309">answer below</a> uses <a href="http://git-scm.com/docs/git-log" rel="noreferrer"><code>git log</code></a>:</p> <p>I mentioned a similar approach in 2009 with "<a href="https://stackoverflow.com/a/1064431/6309">Unable to show a Git tree in terminal</a>":</p> <p...
119
git
<h1>Output of git branch in tree like fashion</h1> <p>Right now, when I type "git branch"</p> <p>it lists my branches in an arbitrary order.</p> <p>What I would prefer would be if "git branch" listed my output in a tree like fasion, somethign like:</p> <pre><code>master |-- foo |-- foo1 |-- foo2 |-- bar |-- ba...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,702
git
# Output of git branch in tree like fashion Right now, when I type "git branch" it lists my branches in an arbitrary order. What I would prefer would be if "git branch" listed my output in a tree like fasion, somethign like: ``` master |-- foo |-- foo1 |-- foo2 |-- bar |-- bar4 ``` Where here, foo & bar were...
The [answer below](https://stackoverflow.com/a/9726638/6309) uses [`git log`](http://git-scm.com/docs/git-log): I mentioned a similar approach in 2009 with "[Unable to show a Git tree in terminal](https://stackoverflow.com/a/1064431/6309)": ``` git log --graph --pretty=oneline --abbrev-commit ``` But the full one I ...
1818895
Keep ignored files out of git status
181
2009-11-30 10:02:26
<p>I would like to stop Git from showing ignored files in <code>git status</code>, because having tons of documentation and config files in the list of <em>Changed but not updated</em> files, renders the list half-useless.</p> <p>Is it normal for Git to show these files? </p> <p>I put the ignore information in a <cod...
113,770
4,991
2021-01-25 05:40:39
1,818,975
305
2009-11-30 10:21:05
219,217
2020-04-05 12:05:57
https://stackoverflow.com/q/1818895
https://stackoverflow.com/a/1818975
<p>As I found <a href="https://web.archive.org/web/20090926065622/http://www.pagebakers.nl/2009/01/29/git-ignoring-changes-in-tracked-files/" rel="noreferrer">in this post</a>, <code>.gitignore</code> only works for untracked files. If you added files to repository, you can:</p> <pre><code>git update-index --assume-un...
<p>As I found <a href="https://web.archive.org/web/20090926065622/http://www.pagebakers.nl/2009/01/29/git-ignoring-changes-in-tracked-files/" rel="noreferrer">in this post</a>, <code>.gitignore</code> only works for untracked files. If you added files to repository, you can:</p> <pre><code>git update-index --assume-un...
119, 25056
git, gitignore
<h1>Keep ignored files out of git status</h1> <p>I would like to stop Git from showing ignored files in <code>git status</code>, because having tons of documentation and config files in the list of <em>Changed but not updated</em> files, renders the list half-useless.</p> <p>Is it normal for Git to show these files? <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,703
git
# Keep ignored files out of git status I would like to stop Git from showing ignored files in `git status`, because having tons of documentation and config files in the list of *Changed but not updated* files, renders the list half-useless. Is it normal for Git to show these files? I put the ignore information in a ...
As I found [in this post](https://web.archive.org/web/20090926065622/http://www.pagebakers.nl/2009/01/29/git-ignoring-changes-in-tracked-files/), `.gitignore` only works for untracked files. If you added files to repository, you can: ``` git update-index --assume-unchanged <file> ``` or remove them from repository by...
2514270
How to check for changes on remote (origin) Git repository
309
2010-03-25 09:22:51
<p>What are the Git commands to do the following workflow?</p> <p><strong>Scenario</strong></p> <p>I cloned from a repository and did some commits of my own to my local repository. In the meantime, my colleagues made commits to the remote repository. Now, I want to:</p> <ol> <li><p>Check whether there are any new commi...
387,771
33,311
2025-01-01 00:54:38
2,514,299
304
2010-03-25 09:28:44
66,353
2010-03-25 09:28:44
https://stackoverflow.com/q/2514270
https://stackoverflow.com/a/2514299
<p>You could <code>git fetch origin</code> to update the remote branch in your repository to point to the latest version. For a diff against the remote:</p> <pre><code>git diff origin/master </code></pre> <p>Yes, you can use caret notation as well.</p> <p>If you want to accept the remote changes:</p> <pre><code>git...
<p>You could <code>git fetch origin</code> to update the remote branch in your repository to point to the latest version. For a diff against the remote:</p> <pre><code>git diff origin/master </code></pre> <p>Yes, you can use caret notation as well.</p> <p>If you want to accept the remote changes:</p> <pre><code>git...
119
git
<h1>How to check for changes on remote (origin) Git repository</h1> <p>What are the Git commands to do the following workflow?</p> <p><strong>Scenario</strong></p> <p>I cloned from a repository and did some commits of my own to my local repository. In the meantime, my colleagues made commits to the remote repository. N...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,704
git
# How to check for changes on remote (origin) Git repository What are the Git commands to do the following workflow? **Scenario** I cloned from a repository and did some commits of my own to my local repository. In the meantime, my colleagues made commits to the remote repository. Now, I want to: 1. Check whether t...
You could `git fetch origin` to update the remote branch in your repository to point to the latest version. For a diff against the remote: ``` git diff origin/master ``` Yes, you can use caret notation as well. If you want to accept the remote changes: ``` git merge origin/master ```
5724513
In Git, how do I figure out what my current revision is?
216
2011-04-20 01:10:52
<p>I just want to know what my current revision number is.</p>
286,760
179,736
2024-01-22 21:20:34
5,724,755
304
2011-04-20 01:59:40
140,750
2021-04-23 06:15:57
https://stackoverflow.com/q/5724513
https://stackoverflow.com/a/5724755
<p>What do you mean by &quot;version number&quot;? It is quite common to tag a commit with a version number and then use</p> <pre><code>$ git describe --tags </code></pre> <p>to identify the current HEAD w.r.t. any tags. If you mean you want to know the hash of the current HEAD, you probably want:</p> <pre><code>$ gi...
<p>What do you mean by &quot;version number&quot;? It is quite common to tag a commit with a version number and then use</p> <pre><code>$ git describe --tags </code></pre> <p>to identify the current HEAD w.r.t. any tags. If you mean you want to know the hash of the current HEAD, you probably want:</p> <pre><code>$ gi...
119
git
<h1>In Git, how do I figure out what my current revision is?</h1> <p>I just want to know what my current revision number is.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,706
git
# In Git, how do I figure out what my current revision is? I just want to know what my current revision number is.
What do you mean by "version number"? It is quite common to tag a commit with a version number and then use ``` $ git describe --tags ``` to identify the current HEAD w.r.t. any tags. If you mean you want to know the hash of the current HEAD, you probably want: ``` $ git rev-parse HEAD ``` or for the short revision...
9063176
git multiple user names for the different projects within the same system
163
2012-01-30 11:32:51
<p>I have a different git repository for my office and a different git repo for my hobby projects. </p> <p>When I do <code>git config --global user.name</code> the user name changes globally and this creates a confusion of committing to a repo with user name. </p> <p>Hence the question is how can i have the same user...
84,724
648,866
2014-06-03 17:29:02
9,063,238
304
2012-01-30 11:36:25
63,034
2013-03-07 13:54:33
https://stackoverflow.com/q/9063176
https://stackoverflow.com/a/9063238
<p>Just use <code>--local</code> instead of <code>--global</code>. In fact, local is the default so you can just do </p> <pre><code>git config user.email personal@example.org git config user.name "whatf hobbyist" </code></pre> <p>in one repo, and</p> <pre><code>git config user.email work@example.com git config user....
<p>Just use <code>--local</code> instead of <code>--global</code>. In fact, local is the default so you can just do </p> <pre><code>git config user.email personal@example.org git config user.name "whatf hobbyist" </code></pre> <p>in one repo, and</p> <pre><code>git config user.email work@example.com git config user....
119, 32868
git, git-config
<h1>git multiple user names for the different projects within the same system</h1> <p>I have a different git repository for my office and a different git repo for my hobby projects. </p> <p>When I do <code>git config --global user.name</code> the user name changes globally and this creates a confusion of committing to...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,707
git
# git multiple user names for the different projects within the same system I have a different git repository for my office and a different git repo for my hobby projects. When I do `git config --global user.name` the user name changes globally and this creates a confusion of committing to a repo with user name. Hen...
Just use `--local` instead of `--global`. In fact, local is the default so you can just do ``` git config user.email personal@example.org git config user.name "whatf hobbyist" ``` in one repo, and ``` git config user.email work@example.com git config user.name "whatf at work" ``` in another repo The values will th...
2500296
Can I make fast forwarding be off by default in Git?
308
2010-03-23 13:38:45
<p>I can't really ever think of a time when I would use <code>git merge</code> rather than <code>git rebase</code> and <em>not</em> want to have a commit show up. Is there any way to configure Git to have <em>fast forwarding</em> off by default?</p> <p>The fact that there's an <code>--ff</code> option would seem to imp...
121,139
2,147
2025-12-18 17:47:19
2,500,446
303
2010-03-23 13:58:18
23,023
2020-06-08 14:16:31
https://stackoverflow.com/q/2500296
https://stackoverflow.com/a/2500446
<p>Yes, there is <code>--no-ff</code>. You can configure merge options per branch, e.g.</p> <pre><code>git config branch.master.mergeoptions "--no-ff" </code></pre> <p>adds the following to your <code>$(REPO)/.git/config</code> file:</p> <pre><code>[branch "master"] mergeoptions = --no-ff </code></pre> <hr> <...
<p>Yes, there is <code>--no-ff</code>. You can configure merge options per branch, e.g.</p> <pre><code>git config branch.master.mergeoptions "--no-ff" </code></pre> <p>adds the following to your <code>$(REPO)/.git/config</code> file:</p> <pre><code>[branch "master"] mergeoptions = --no-ff </code></pre> <hr> <...
119, 717, 1879, 8974, 52842
branch, fast-forward, git, merge, rebase
<h1>Can I make fast forwarding be off by default in Git?</h1> <p>I can't really ever think of a time when I would use <code>git merge</code> rather than <code>git rebase</code> and <em>not</em> want to have a commit show up. Is there any way to configure Git to have <em>fast forwarding</em> off by default?</p> <p>The f...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,708
git
# Can I make fast forwarding be off by default in Git? I can't really ever think of a time when I would use `git merge` rather than `git rebase` and *not* want to have a commit show up. Is there any way to configure Git to have *fast forwarding* off by default? The fact that there's an `--ff` option would seem to imp...
Yes, there is `--no-ff`. You can configure merge options per branch, e.g. ``` git config branch.master.mergeoptions "--no-ff" ``` adds the following to your `$(REPO)/.git/config` file: ``` [branch "master"] mergeoptions = --no-ff ``` --- *Footnote: speaking of my experience, I eventually found switching fast-...
180272
How to preview git-pull?
263
2008-10-07 20:30:30
<p>Is it even possible?</p> <p>Basically, there's a remote repository from which I pull using just:</p> <pre><code>git pull </code></pre> <p>Now, I'd like to preview what this pull would change (a diff) without touching anything on my side. The reason is that thing I'm pulling might not be "good" and I want someone ...
172,093
14,690
2023-02-08 17:33:45
180,368
303
2008-10-07 20:53:18
893
2019-02-18 23:54:59
https://stackoverflow.com/q/180272
https://stackoverflow.com/a/180368
<p>After doing a <code>git fetch</code>, do a <code>git log HEAD..origin/master</code> to show the log entries between your last common commit and the origin's master branch. To show the diffs, use either <code>git log -p HEAD..origin/master</code> to show each patch, or <code>git diff HEAD...origin/master</code> (thre...
<p>After doing a <code>git fetch</code>, do a <code>git log HEAD..origin/master</code> to show the log entries between your last common commit and the origin's master branch. To show the diffs, use either <code>git log -p HEAD..origin/master</code> to show each patch, or <code>git diff HEAD...origin/master</code> (thre...
119, 456
git, version-control
<h1>How to preview git-pull?</h1> <p>Is it even possible?</p> <p>Basically, there's a remote repository from which I pull using just:</p> <pre><code>git pull </code></pre> <p>Now, I'd like to preview what this pull would change (a diff) without touching anything on my side. The reason is that thing I'm pulling might...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,709
git
# How to preview git-pull? Is it even possible? Basically, there's a remote repository from which I pull using just: ``` git pull ``` Now, I'd like to preview what this pull would change (a diff) without touching anything on my side. The reason is that thing I'm pulling might not be "good" and I want someone else t...
After doing a `git fetch`, do a `git log HEAD..origin/master` to show the log entries between your last common commit and the origin's master branch. To show the diffs, use either `git log -p HEAD..origin/master` to show each patch, or `git diff HEAD...origin/master` (three dots not two) to show a single diff. There n...
3051461
git rebase, keeping track of 'local' and 'remote'
214
2010-06-16 07:43:04
<p>When doing a <code>git rebase</code>, I often have difficulty working out what is happening with the 'local' and 'remote' when resolving conflicts. I sometimes have the impression that they swap sides from one commit to the next.</p> <p>This is probably (definitely) because I still don't properly understand the para...
53,681
11,410
2025-04-03 22:07:42
3,052,118
303
2010-06-16 09:37:15
6,309
2025-04-03 22:07:42
https://stackoverflow.com/q/3051461
https://stackoverflow.com/a/3052118
<h2>TL;DR;</h2> <p>To summarize (As <a href="https://stackoverflow.com/users/494643/benubird">Benubird</a> <a href="https://stackoverflow.com/questions/3051461/git-rebase-keeping-track-of-local-and-remote/3052118?noredirect=1#comment27248064_3052118">comments</a>):</p> <p>When resolving conflicts during:</p> <pre><code...
<h2>TL;DR;</h2> <p>To summarize (As <a href="https://stackoverflow.com/users/494643/benubird">Benubird</a> <a href="https://stackoverflow.com/questions/3051461/git-rebase-keeping-track-of-local-and-remote/3052118?noredirect=1#comment27248064_3052118">comments</a>):</p> <p>When resolving conflicts during:</p> <pre><code...
119, 8974, 62599
git, merge-conflict-resolution, rebase
<h1>git rebase, keeping track of 'local' and 'remote'</h1> <p>When doing a <code>git rebase</code>, I often have difficulty working out what is happening with the 'local' and 'remote' when resolving conflicts. I sometimes have the impression that they swap sides from one commit to the next.</p> <p>This is probably (def...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,710
git
# git rebase, keeping track of 'local' and 'remote' When doing a `git rebase`, I often have difficulty working out what is happening with the 'local' and 'remote' when resolving conflicts. I sometimes have the impression that they swap sides from one commit to the next. This is probably (definitely) because I still d...
## TL;DR; To summarize (As [Benubird](https://stackoverflow.com/users/494643/benubird) [comments](https://stackoverflow.com/questions/3051461/git-rebase-keeping-track-of-local-and-remote/3052118?noredirect=1#comment27248064_3052118)): When resolving conflicts during: ``` git checkout A git rebase B # rebase A onto...
8594758
Undoing a Git bisect mistake
240
2011-12-21 18:45:01
<p>I'm doing a nonautomated Git bisect via the command line. All is going well until I accidentally hit return on the wrong line in my command history, and rather than running the test, I run 'git bisect good' (or bad). Oops; I don't yet know if this commit should be marked good or bad, yet that's what I've done.</p> <...
24,936
434,004
2025-07-13 01:18:03
8,594,800
302
2011-12-21 18:48:24
526,535
2020-02-08 17:40:59
https://stackoverflow.com/q/8594758
https://stackoverflow.com/a/8594800
<p>From the <a href="https://git-scm.com/docs/git-bisect#_bisect_log_and_bisect_replay" rel="noreferrer">git-bisect documentation</a>:</p> <blockquote> <p><strong>Bisect log and bisect replay</strong></p> <p>After having marked revisions as good or bad, issue the following command to show what has been done so ...
<p>From the <a href="https://git-scm.com/docs/git-bisect#_bisect_log_and_bisect_replay" rel="noreferrer">git-bisect documentation</a>:</p> <blockquote> <p><strong>Bisect log and bisect replay</strong></p> <p>After having marked revisions as good or bad, issue the following command to show what has been done so ...
119, 47326
git, git-bisect
<h1>Undoing a Git bisect mistake</h1> <p>I'm doing a nonautomated Git bisect via the command line. All is going well until I accidentally hit return on the wrong line in my command history, and rather than running the test, I run 'git bisect good' (or bad). Oops; I don't yet know if this commit should be marked good or...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,711
git
# Undoing a Git bisect mistake I'm doing a nonautomated Git bisect via the command line. All is going well until I accidentally hit return on the wrong line in my command history, and rather than running the test, I run 'git bisect good' (or bad). Oops; I don't yet know if this commit should be marked good or bad, yet...
From the [git-bisect documentation](https://git-scm.com/docs/git-bisect#_bisect_log_and_bisect_replay): > **Bisect log and bisect replay** > > After having marked revisions as good or bad, issue the following command to show what has been done so far: > > ``` > $ git bisect log > ``` > > If you discover that you made ...
11792671
How to git bundle a complete repo
190
2012-08-03 09:07:37
<p>I need to transfer a complete repo to a new non-networked machine, preferable as a single file entity. The git bundle allows a <code>git fetch</code>, <code>git pull</code> style operation in a sneakernet environment but appears to assume that you already have a working version of the repo on the destination machine...
139,673
717,355
2024-05-05 18:25:33
11,795,549
302
2012-08-03 12:14:48
46,058
2012-08-03 12:14:48
https://stackoverflow.com/q/11792671
https://stackoverflow.com/a/11795549
<blockquote> <p>What is the right invocation to:</p> <ul> <li>Bundle all the branches in the current repo</li> </ul> </blockquote> <p>Simple:</p> <pre><code>$ git bundle create repo.bundle --all </code></pre> <p>Here <code>repo.bundle</code> is the name of bundle file you want to create. Note that <code>...
<blockquote> <p>What is the right invocation to:</p> <ul> <li>Bundle all the branches in the current repo</li> </ul> </blockquote> <p>Simple:</p> <pre><code>$ git bundle create repo.bundle --all </code></pre> <p>Here <code>repo.bundle</code> is the name of bundle file you want to create. Note that <code>...
119
git
<h1>How to git bundle a complete repo</h1> <p>I need to transfer a complete repo to a new non-networked machine, preferable as a single file entity. The git bundle allows a <code>git fetch</code>, <code>git pull</code> style operation in a sneakernet environment but appears to assume that you already have a working ver...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,712
git
# How to git bundle a complete repo I need to transfer a complete repo to a new non-networked machine, preferable as a single file entity. The git bundle allows a `git fetch`, `git pull` style operation in a sneakernet environment but appears to assume that you already have a working version of the repo on the destina...
> What is the right invocation to: > > - Bundle all the branches in the current repo Simple: ``` $ git bundle create repo.bundle --all ``` Here `repo.bundle` is the name of bundle file you want to create. Note that `--all` would not include remote-tracking branches... just like ordinary clone wouldn't either. > - S...