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
17843384
How to stash changes while keeping the changes in the working directory? (Git)
311
2013-07-24 19:39:12
<p>Is there a <code>git stash</code> command that stashes your changes, but keeps them in the working directory too? So basically a <code>git stash; git stash apply</code> in one step?</p>
95,788
1,291,990
2024-06-02 19:06:09
17,848,537
301
2013-07-25 03:31:10
null
2020-07-10 17:46:40
https://stackoverflow.com/q/17843384
https://stackoverflow.com/a/17848537
<p>For what it's worth, another way to do this is to stage the changes you want to keep, and then stash everything using <code>--keep-index</code>:</p> <pre class="lang-bash prettyprint-override"><code>$ git add modified-file.txt $ git stash push --keep-index </code></pre> <p>The commands above will stash everything, b...
<p>For what it's worth, another way to do this is to stage the changes you want to keep, and then stash everything using <code>--keep-index</code>:</p> <pre class="lang-bash prettyprint-override"><code>$ git add modified-file.txt $ git stash push --keep-index </code></pre> <p>The commands above will stash everything, b...
119, 13091
git, git-stash
<h1>How to stash changes while keeping the changes in the working directory? (Git)</h1> <p>Is there a <code>git stash</code> command that stashes your changes, but keeps them in the working directory too? So basically a <code>git stash; git stash apply</code> in one step?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,714
git
# How to stash changes while keeping the changes in the working directory? (Git) Is there a `git stash` command that stashes your changes, but keeps them in the working directory too? So basically a `git stash; git stash apply` in one step?
For what it's worth, another way to do this is to stage the changes you want to keep, and then stash everything using `--keep-index`: ``` $ git add modified-file.txt $ git stash push --keep-index ``` The commands above will stash everything, but it will leave the files staged in your working directory. From the [off...
15034390
How to create a new (and empty!) "root" branch?
199
2013-02-22 22:37:57
<p>I would like to define a new "root" branch in this git repository. By "root" branch I mean a branch that is entirely independent of all the other branches in the repository<sup>1</sup>.</p> <p>Unfortunately, even the commit (let's call it <code>A</code>) at the very base of the repo's commit tree contains a lot of...
52,869
559,827
2020-09-21 14:31:09
15,034,426
301
2013-02-22 22:41:09
492,405
2015-09-14 20:28:06
https://stackoverflow.com/q/15034390
https://stackoverflow.com/a/15034426
<p>Use the <code>--orphan</code> when creating the branch:</p> <pre><code>git checkout --orphan YourBranchName </code></pre> <p>This will create a new branch with zero commits on it, however all of your files will be staged. At that point you could just remove them.<br> ("remove them": A <code>git reset --hard</code>...
<p>Use the <code>--orphan</code> when creating the branch:</p> <pre><code>git checkout --orphan YourBranchName </code></pre> <p>This will create a new branch with zero commits on it, however all of your files will be staged. At that point you could just remove them.<br> ("remove them": A <code>git reset --hard</code>...
119
git
<h1>How to create a new (and empty!) "root" branch?</h1> <p>I would like to define a new "root" branch in this git repository. By "root" branch I mean a branch that is entirely independent of all the other branches in the repository<sup>1</sup>.</p> <p>Unfortunately, even the commit (let's call it <code>A</code>) at ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,715
git
# How to create a new (and empty!) "root" branch? I would like to define a new "root" branch in this git repository. By "root" branch I mean a branch that is entirely independent of all the other branches in the repository1. Unfortunately, even the commit (let's call it `A`) at the very base of the repo's commit tree...
Use the `--orphan` when creating the branch: ``` git checkout --orphan YourBranchName ``` This will create a new branch with zero commits on it, however all of your files will be staged. At that point you could just remove them. ("remove them": A `git reset --hard` will empty the index, leaving you with an empty wo...
14337945
How do I resolve cherry-pick conflicts using their changes?
163
2013-01-15 12:39:40
<p>My <code>git cherry-pick FOO</code> produced a conflict.</p> <p>I could go through the conflicting files and delete the lines between <code>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code> and <code>=======</code>, and the conflict markers themselves, but I'm hoping there's an easier way.</p> <p>I think the <code>svn</code> eq...
135,962
1,036,728
2023-03-13 21:54:40
14,339,572
301
2013-01-15 14:12:27
530,424
2014-05-08 16:21:48
https://stackoverflow.com/q/14337945
https://stackoverflow.com/a/14339572
<p>First you should undo your cherry-pick, try to run this</p> <pre><code>git cherry-pick --abort </code></pre> <p>Second, try to make cherry-pick, but in this time you get their changes not yours, so make this:</p> <pre><code>git cherry-pick --strategy=recursive -X theirs {Imported_Commit} </code></pre>
<p>First you should undo your cherry-pick, try to run this</p> <pre><code>git cherry-pick --abort </code></pre> <p>Second, try to make cherry-pick, but in this time you get their changes not yours, so make this:</p> <pre><code>git cherry-pick --strategy=recursive -X theirs {Imported_Commit} </code></pre>
119
git
<h1>How do I resolve cherry-pick conflicts using their changes?</h1> <p>My <code>git cherry-pick FOO</code> produced a conflict.</p> <p>I could go through the conflicting files and delete the lines between <code>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code> and <code>=======</code>, and the conflict markers themselves, but I'm ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,716
git
# How do I resolve cherry-pick conflicts using their changes? My `git cherry-pick FOO` produced a conflict. I could go through the conflicting files and delete the lines between `<<<<<<<` and `=======`, and the conflict markers themselves, but I'm hoping there's an easier way. I think the `svn` equivalent was choosi...
First you should undo your cherry-pick, try to run this ``` git cherry-pick --abort ``` Second, try to make cherry-pick, but in this time you get their changes not yours, so make this: ``` git cherry-pick --strategy=recursive -X theirs {Imported_Commit} ```
462974
What are the differences between double-dot ".." and triple-dot "..." in Git commit ranges?
649
2009-01-20 20:32:18
<p>Some Git commands take commit ranges and one valid syntax is to separate two commit names with two dots <code>..</code>, and another syntax uses three dots <code>...</code>.</p> <p>What are the differences between the two?</p>
120,878
825
2023-04-17 07:13:01
463,027
298
2009-01-20 20:46:40
49,401
2015-12-08 15:21:30
https://stackoverflow.com/q/462974
https://stackoverflow.com/a/463027
<p>It depends on whether you're using a <code>log</code> command or a <code>diff</code> command. In the <code>log</code> case, it's in the <code>man git-rev-parse</code> documentation:</p> <blockquote> <p>To exclude commits reachable from a commit, a prefix ^ notation is used. E.g. ^r1 r2 means commits reachable fro...
<p>It depends on whether you're using a <code>log</code> command or a <code>diff</code> command. In the <code>log</code> case, it's in the <code>man git-rev-parse</code> documentation:</p> <blockquote> <p>To exclude commits reachable from a commit, a prefix ^ notation is used. E.g. ^r1 r2 means commits reachable fro...
119, 9033, 37230, 47913, 85577
git, git-checkout, git-diff, git-log, git-rev-list
<h1>What are the differences between double-dot ".." and triple-dot "..." in Git commit ranges?</h1> <p>Some Git commands take commit ranges and one valid syntax is to separate two commit names with two dots <code>..</code>, and another syntax uses three dots <code>...</code>.</p> <p>What are the differences between t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,719
git
# What are the differences between double-dot ".." and triple-dot "..." in Git commit ranges? Some Git commands take commit ranges and one valid syntax is to separate two commit names with two dots `..`, and another syntax uses three dots `...`. What are the differences between the two?
It depends on whether you're using a `log` command or a `diff` command. In the `log` case, it's in the `man git-rev-parse` documentation: > To exclude commits reachable from a commit, a prefix ^ notation is used. E.g. ^r1 r2 means commits reachable from r2 but exclude the ones reachable from r1. > > This set operation...
10914022
How do I check out a specific version of a submodule using 'git submodule'?
248
2012-06-06 12:14:54
<p>How would I go about adding a Git submodule for a specific tag or commit?</p>
315,610
null
2020-12-03 13:51:59
10,916,398
297
2012-06-06 14:34:36
503,463
2012-06-06 14:34:36
https://stackoverflow.com/q/10914022
https://stackoverflow.com/a/10916398
<p>Submodule repositories stay in a detached HEAD state pointing to a specific commit. Changing that commit simply involves checking out a different tag or commit then adding the change to the parent repository.</p> <pre><code>$ cd submodule $ git checkout v2.0 Previous HEAD position was 5c1277e... bumped version to 2...
<p>Submodule repositories stay in a detached HEAD state pointing to a specific commit. Changing that commit simply involves checking out a different tag or commit then adding the change to the parent repository.</p> <pre><code>$ cd submodule $ git checkout v2.0 Previous HEAD position was 5c1277e... bumped version to 2...
119, 456, 41612
git, git-submodules, version-control
<h1>How do I check out a specific version of a submodule using 'git submodule'?</h1> <p>How would I go about adding a Git submodule for a specific tag or commit?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,721
git
# How do I check out a specific version of a submodule using 'git submodule'? How would I go about adding a Git submodule for a specific tag or commit?
Submodule repositories stay in a detached HEAD state pointing to a specific commit. Changing that commit simply involves checking out a different tag or commit then adding the change to the parent repository. ``` $ cd submodule $ git checkout v2.0 Previous HEAD position was 5c1277e... bumped version to 2.0.5 HEAD is n...
33840617
How do I rename a git remote?
214
2015-11-21 06:54:34
<p>I currently have a git remote called <code>heroku</code> and I'd like to rename it to <code>production</code>.</p> <pre><code>$ git remote -v heroku https://git.heroku.com/example.git (fetch) heroku https://git.heroku.com/example.git (push) </code></pre>
109,174
1,688,034
2023-09-05 13:24:14
33,840,618
297
2015-11-21 06:54:34
1,688,034
2023-09-05 13:24:14
https://stackoverflow.com/q/33840617
https://stackoverflow.com/a/33840618
<pre><code>$ git remote rename &lt;old-name&gt; &lt;new-name&gt; </code></pre> <p>So, for this example:</p> <pre><code>$ git remote rename heroku production </code></pre> <p>Useful docs here: <a href="https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories#renaming-a-remote-reposito...
<pre><code>$ git remote rename &lt;old-name&gt; &lt;new-name&gt; </code></pre> <p>So, for this example:</p> <pre><code>$ git remote rename heroku production </code></pre> <p>Useful docs here: <a href="https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories#renaming-a-remote-reposito...
119
git
<h1>How do I rename a git remote?</h1> <p>I currently have a git remote called <code>heroku</code> and I'd like to rename it to <code>production</code>.</p> <pre><code>$ git remote -v heroku https://git.heroku.com/example.git (fetch) heroku https://git.heroku.com/example.git (push) </code></pre>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,723
git
# How do I rename a git remote? I currently have a git remote called `heroku` and I'd like to rename it to `production`. ``` $ git remote -v heroku https://git.heroku.com/example.git (fetch) heroku https://git.heroku.com/example.git (push) ```
``` $ git remote rename <old-name> <new-name> ``` So, for this example: ``` $ git remote rename heroku production ``` Useful docs here: <https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories#renaming-a-remote-repository>
4965639
Rollback to last git commit
162
2011-02-11 04:30:37
<p>I just did a </p> <pre><code>git commit -m "blah" </code></pre> <p>then I added some files, how do I rollback and remove what is in my current files that have not yet been added/committed?</p>
245,559
39,677
2024-03-25 19:24:23
4,965,713
297
2011-02-11 04:48:21
560,585
2023-04-03 15:17:06
https://stackoverflow.com/q/4965639
https://stackoverflow.com/a/4965713
<p><strong>Edited Answer</strong> - edited over time to be more helpful</p> <p><strong>Caveat Emptor</strong> - <em>Destructive commands ahead.</em></p> <p><strong>Mitigation</strong> - <code>git reflog</code> <em>can save you if you need it.</em></p> <hr /> <ol> <li><p><strong>UNDO</strong> local file changes and <str...
<p><strong>Edited Answer</strong> - edited over time to be more helpful</p> <p><strong>Caveat Emptor</strong> - <em>Destructive commands ahead.</em></p> <p><strong>Mitigation</strong> - <code>git reflog</code> <em>can save you if you need it.</em></p> <hr /> <ol> <li><p><strong>UNDO</strong> local file changes and <str...
119
git
<h1>Rollback to last git commit</h1> <p>I just did a </p> <pre><code>git commit -m "blah" </code></pre> <p>then I added some files, how do I rollback and remove what is in my current files that have not yet been added/committed?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,724
git
# Rollback to last git commit I just did a ``` git commit -m "blah" ``` then I added some files, how do I rollback and remove what is in my current files that have not yet been added/committed?
**Edited Answer** - edited over time to be more helpful **Caveat Emptor** - *Destructive commands ahead.* **Mitigation** - `git reflog` *can save you if you need it.* --- 1. **UNDO** local file changes and **KEEP** your last commit git reset --hard 2. **UNDO** local file changes and **REMOVE** your last commit ...
12476239
git stash and git pull
130
2012-09-18 11:35:30
<p>I am new to Git and I am using EGit eclipse plugin to commit.</p> <p>I modified few files and I stashed the changes, then I did <code>git pull</code> in command line which pulled up all the latest commits. Then I did <code>Apply stashed changes</code> from EGit. Now it applied my changes and the changes which pulle...
212,824
646,276
2024-03-21 15:29:31
12,476,984
297
2012-09-18 12:24:43
350,127
2014-04-30 11:17:42
https://stackoverflow.com/q/12476239
https://stackoverflow.com/a/12476984
<p>When you have changes on your working copy, from command line do:</p> <pre><code>git stash </code></pre> <p>This will stash your changes and clear your status report</p> <pre><code>git pull </code></pre> <p>This will pull changes from upstream branch. Make sure it says fast-forward in the report. If it doesn't,...
<p>When you have changes on your working copy, from command line do:</p> <pre><code>git stash </code></pre> <p>This will stash your changes and clear your status report</p> <pre><code>git pull </code></pre> <p>This will pull changes from upstream branch. Make sure it says fast-forward in the report. If it doesn't,...
119, 13091, 43702
egit, git, git-stash
<h1>git stash and git pull</h1> <p>I am new to Git and I am using EGit eclipse plugin to commit.</p> <p>I modified few files and I stashed the changes, then I did <code>git pull</code> in command line which pulled up all the latest commits. Then I did <code>Apply stashed changes</code> from EGit. Now it applied my cha...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,725
git
# git stash and git pull I am new to Git and I am using EGit eclipse plugin to commit. I modified few files and I stashed the changes, then I did `git pull` in command line which pulled up all the latest commits. Then I did `Apply stashed changes` from EGit. Now it applied my changes and the changes which pulled from...
When you have changes on your working copy, from command line do: ``` git stash ``` This will stash your changes and clear your status report ``` git pull ``` This will pull changes from upstream branch. Make sure it says fast-forward in the report. If it doesn't, you are probably doing an unintended merge ``` git...
35769330
Git LFS track folder recursively
201
2016-03-03 10:20:08
<p>Is it possible to track recursively all files contained in a folder and its subfolders with Git LFS ?</p> <p>I would like to do something like this :</p> <pre><code>git lfs track myfolder/* </code></pre>
110,060
2,938,550
2021-01-07 11:00:50
35,769,868
296
2016-03-03 10:41:45
1,127,485
2018-04-23 06:48:44
https://stackoverflow.com/q/35769330
https://stackoverflow.com/a/35769868
<p>Use <code>git lfs track "myfolder/**"</code>, with quotes to avoid the shell already expanding the pattern. All that the <code>track</code> command does is to write to <code>.gitattributes</code>, which in turn uses (almost) the same pattern matching rules as <code>.gitignore</code>, see the <a href="https://git-scm...
<p>Use <code>git lfs track "myfolder/**"</code>, with quotes to avoid the shell already expanding the pattern. All that the <code>track</code> command does is to write to <code>.gitattributes</code>, which in turn uses (almost) the same pattern matching rules as <code>.gitignore</code>, see the <a href="https://git-scm...
119, 115244
git, git-lfs
<h1>Git LFS track folder recursively</h1> <p>Is it possible to track recursively all files contained in a folder and its subfolders with Git LFS ?</p> <p>I would like to do something like this :</p> <pre><code>git lfs track myfolder/* </code></pre>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,727
git
# Git LFS track folder recursively Is it possible to track recursively all files contained in a folder and its subfolders with Git LFS ? I would like to do something like this : ``` git lfs track myfolder/* ```
Use `git lfs track "myfolder/**"`, with quotes to avoid the shell already expanding the pattern. All that the `track` command does is to write to `.gitattributes`, which in turn uses (almost) the same pattern matching rules as `.gitignore`, see the [PATTERN FORMAT](https://git-scm.com/docs/gitignore#_pattern_format) de...
45272492
Git is refusing to merge unrelated histories. What are 'unrelated histories'?
190
2017-07-24 04:11:08
<p>I created a local repo with <code>git remote origin https:////...</code>.</p> <p>Then, in that local repo, I made a new text file → <code>git add newfile.txt</code> → <code>git commit -m &quot;...&quot;</code> → <code>git pull origin main</code> → ERROR!</p> <p>&quot;refusing to merge unrelated histories&quot;.</p> ...
219,489
9,279,003
2024-07-30 08:44:00
45,272,685
296
2017-07-24 04:34:22
7,628,863
2024-07-30 08:42:51
https://stackoverflow.com/q/45272492
https://stackoverflow.com/a/45272685
<p>I think you have committed in the remote repository, and when you pull, this error happens.</p> <p>Use this command:</p> <pre><code>git pull origin main --allow-unrelated-histories git merge origin origin/main </code></pre>
<p>I think you have committed in the remote repository, and when you pull, this error happens.</p> <p>Use this command:</p> <pre><code>git pull origin main --allow-unrelated-histories git merge origin origin/main </code></pre>
119, 28896
git, git-pull
<h1>Git is refusing to merge unrelated histories. What are 'unrelated histories'?</h1> <p>I created a local repo with <code>git remote origin https:////...</code>.</p> <p>Then, in that local repo, I made a new text file → <code>git add newfile.txt</code> → <code>git commit -m &quot;...&quot;</code> → <code>git pull ori...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,728
git
# Git is refusing to merge unrelated histories. What are 'unrelated histories'? I created a local repo with `git remote origin https:////...`. Then, in that local repo, I made a new text file → `git add newfile.txt` → `git commit -m "..."` → `git pull origin main` → ERROR! "refusing to merge unrelated histories". W...
I think you have committed in the remote repository, and when you pull, this error happens. Use this command: ``` git pull origin main --allow-unrelated-histories git merge origin origin/main ```
30986376
How to undo a successful "git cherry-pick"?
204
2015-06-22 17:38:26
<p>On a local repo, I've just executed <code>git cherry-pick SHA</code> without any conflicts or problems. I then realized I didn't want to do what I just did. I have not pushed this anywhere.</p> <p>How can I remove just this cherry pick?</p> <p>I'd like to know if there's a way to do this:</p> <ul> <li>when I have...
373,639
26,510
2023-11-14 18:00:16
30,986,481
295
2015-06-22 17:44:15
1,843,331
2017-04-13 08:35:07
https://stackoverflow.com/q/30986376
https://stackoverflow.com/a/30986481
<p>A cherry-pick is basically a commit, so if you want to undo it, you just undo the commit.</p> <blockquote> <p>when I have other local changes</p> </blockquote> <p>Stash your current changes so you can reapply them after resetting the commit.</p> <pre><code>$ git stash $ git reset --hard HEAD^ $ git stash pop #...
<p>A cherry-pick is basically a commit, so if you want to undo it, you just undo the commit.</p> <blockquote> <p>when I have other local changes</p> </blockquote> <p>Stash your current changes so you can reapply them after resetting the commit.</p> <pre><code>$ git stash $ git reset --hard HEAD^ $ git stash pop #...
119
git
<h1>How to undo a successful "git cherry-pick"?</h1> <p>On a local repo, I've just executed <code>git cherry-pick SHA</code> without any conflicts or problems. I then realized I didn't want to do what I just did. I have not pushed this anywhere.</p> <p>How can I remove just this cherry pick?</p> <p>I'd like to know i...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,731
git
# How to undo a successful "git cherry-pick"? On a local repo, I've just executed `git cherry-pick SHA` without any conflicts or problems. I then realized I didn't want to do what I just did. I have not pushed this anywhere. How can I remove just this cherry pick? I'd like to know if there's a way to do this: - whe...
A cherry-pick is basically a commit, so if you want to undo it, you just undo the commit. > when I have other local changes Stash your current changes so you can reapply them after resetting the commit. ``` $ git stash $ git reset --hard HEAD^ $ git stash pop # or `git stash apply`, if you want to keep the changese...
7736781
How can I make "git log" not prompt to continue?
192
2011-10-12 07:45:19
<p>I have a couple of Git repositories that belong together, and simple batch/Bash file to loop over them. I often loop over them with a log command to quickly see what state they are in. This works nicely, except for one thing: if the commit message is longer than the number of characters my console is wide (or has mu...
99,583
128,384
2025-05-04 17:59:11
7,737,071
295
2011-10-12 08:16:07
743,897
2021-02-20 17:57:54
https://stackoverflow.com/q/7736781
https://stackoverflow.com/a/7737071
<p>Git has an option to disable the pager:</p> <pre><code>git --no-pager log --decorate=short --pretty=oneline -n1 </code></pre> <p>If your pager cuts lines and you want to retain that behaviour, either pipe to <code>cut</code>...</p> <pre><code>git --no-pager log --decorate=short --pretty=oneline -n1 | cut -c 1-$COLUM...
<p>Git has an option to disable the pager:</p> <pre><code>git --no-pager log --decorate=short --pretty=oneline -n1 </code></pre> <p>If your pager cuts lines and you want to retain that behaviour, either pipe to <code>cut</code>...</p> <pre><code>git --no-pager log --decorate=short --pretty=oneline -n1 | cut -c 1-$COLUM...
119
git
<h1>How can I make "git log" not prompt to continue?</h1> <p>I have a couple of Git repositories that belong together, and simple batch/Bash file to loop over them. I often loop over them with a log command to quickly see what state they are in. This works nicely, except for one thing: if the commit message is longer t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,732
git
# How can I make "git log" not prompt to continue? I have a couple of Git repositories that belong together, and simple batch/Bash file to loop over them. I often loop over them with a log command to quickly see what state they are in. This works nicely, except for one thing: if the commit message is longer than the n...
Git has an option to disable the pager: ``` git --no-pager log --decorate=short --pretty=oneline -n1 ``` If your pager cuts lines and you want to retain that behaviour, either pipe to `cut`... ``` git --no-pager log --decorate=short --pretty=oneline -n1 | cut -c 1-$COLUMNS ``` ...or set the environment variable `GI...
15150671
Delete branches in Bitbucket
184
2013-03-01 04:46:54
<p>I've created lots of branches in one of our repositories. Those branches are for testing before it will be pulled to the master. Now I see lots of them on the list and they we will never use it again. How to delete those branches directly to Bitbucket?</p>
431,911
2,008,506
2025-04-12 15:40:56
15,229,430
295
2013-03-05 16:45:30
316,950
2016-03-20 17:18:22
https://stackoverflow.com/q/15150671
https://stackoverflow.com/a/15229430
<p>If the branches are only local, you can use <strong>-d</strong> if the branch has been merged, like</p> <pre><code>git branch -d branch-name </code></pre> <p>If the branch contains code you never plan on merging, use <strong>-D</strong> instead.</p> <p>If the branch is in the upstream repo (on Bitbucket) you can ...
<p>If the branches are only local, you can use <strong>-d</strong> if the branch has been merged, like</p> <pre><code>git branch -d branch-name </code></pre> <p>If the branch contains code you never plan on merging, use <strong>-D</strong> instead.</p> <p>If the branch is in the upstream repo (on Bitbucket) you can ...
119, 8337, 76220
bitbucket, git, git-branch
<h1>Delete branches in Bitbucket</h1> <p>I've created lots of branches in one of our repositories. Those branches are for testing before it will be pulled to the master. Now I see lots of them on the list and they we will never use it again. How to delete those branches directly to Bitbucket?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,733
git
# Delete branches in Bitbucket I've created lots of branches in one of our repositories. Those branches are for testing before it will be pulled to the master. Now I see lots of them on the list and they we will never use it again. How to delete those branches directly to Bitbucket?
If the branches are only local, you can use **-d** if the branch has been merged, like ``` git branch -d branch-name ``` If the branch contains code you never plan on merging, use **-D** instead. If the branch is in the upstream repo (on Bitbucket) you can remove the remote reference by ``` git push origin :branch-...
22630404
git push: refs/heads/my/subbranch exists, cannot create
180
2014-03-25 09:33:57
<p>Is this not possible to create somme sub-sub-folder in a repo on a server?</p> <p>if i do:</p> <pre><code>git push origin dev/master </code></pre> <p>everything work find</p> <p>but if i do</p> <pre><code>git push origin dev/sub/master </code></pre> <p>i got this:</p> <pre><code>error: 'refs/heads/dev/sub' exists; ...
171,655
3,458,953
2023-11-13 05:50:24
22,630,664
295
2014-03-25 09:44:40
1,256,452
2016-12-22 13:03:01
https://stackoverflow.com/q/22630404
https://stackoverflow.com/a/22630664
<p>It's not a <em>folder</em> that exists, it's a <em>branch</em>. (Well, there may be a folder/directory involved somewhere—or maybe not, as references get "packed" and stop existing as files within directories.)</p> <ul> <li><strong>If branch <code>b</code> exists, no branch named <code>b/anything</code> can be cre...
<p>It's not a <em>folder</em> that exists, it's a <em>branch</em>. (Well, there may be a folder/directory involved somewhere—or maybe not, as references get "packed" and stop existing as files within directories.)</p> <ul> <li><strong>If branch <code>b</code> exists, no branch named <code>b/anything</code> can be cre...
119
git
<h1>git push: refs/heads/my/subbranch exists, cannot create</h1> <p>Is this not possible to create somme sub-sub-folder in a repo on a server?</p> <p>if i do:</p> <pre><code>git push origin dev/master </code></pre> <p>everything work find</p> <p>but if i do</p> <pre><code>git push origin dev/sub/master </code></pre> <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,734
git
# git push: refs/heads/my/subbranch exists, cannot create Is this not possible to create somme sub-sub-folder in a repo on a server? if i do: ``` git push origin dev/master ``` everything work find but if i do ``` git push origin dev/sub/master ``` i got this: ``` error: 'refs/heads/dev/sub' exists; cannot crea...
It's not a *folder* that exists, it's a *branch*. (Well, there may be a folder/directory involved somewhere—or maybe not, as references get "packed" and stop existing as files within directories.) - **If branch `b` exists, no branch named `b/anything` can be created.** - **Likewise, if branch `dev/b` exists, `dev/b/c`...
6612630
git add all except ignoring files in .gitignore file
159
2011-07-07 14:54:51
<p>I am adding source control to a project that had none. The problem is that there are a lot of files to initially add to git with a <em>.gitignore</em> file, but I can't figure out how to add all files without including the files matching something in the <em>.gitignore</em> file.</p> <pre><code>git add * </code></p...
114,197
561,624
2024-05-13 05:43:00
6,612,693
295
2011-07-07 14:59:15
356,746
2011-07-07 15:04:17
https://stackoverflow.com/q/6612630
https://stackoverflow.com/a/6612693
<p>I think you mean <code>git add .</code> which will add all of the files to the repo that AREN'T specified in the <code>.gitignore</code> - you can see these changes by typing <code>git status</code></p> <p>The <code>.</code> in bash usually means this directory and all other directories recursively, so if you do th...
<p>I think you mean <code>git add .</code> which will add all of the files to the repo that AREN'T specified in the <code>.gitignore</code> - you can see these changes by typing <code>git status</code></p> <p>The <code>.</code> in bash usually means this directory and all other directories recursively, so if you do th...
119, 7280, 25056
git, gitignore, init
<h1>git add all except ignoring files in .gitignore file</h1> <p>I am adding source control to a project that had none. The problem is that there are a lot of files to initially add to git with a <em>.gitignore</em> file, but I can't figure out how to add all files without including the files matching something in the ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,735
git
# git add all except ignoring files in .gitignore file I am adding source control to a project that had none. The problem is that there are a lot of files to initially add to git with a *.gitignore* file, but I can't figure out how to add all files without including the files matching something in the *.gitignore* fil...
I think you mean `git add .` which will add all of the files to the repo that AREN'T specified in the `.gitignore` - you can see these changes by typing `git status` The `.` in bash usually means this directory and all other directories recursively, so if you do this from the bottom level of your repo, you should add ...
7693249
How to list commits since certain commit?
262
2011-10-07 21:56:54
<p>Is there anyway to get a list of commits from a given commit number to HEAD?</p> <p>I know this is possible by the commit date, but I need it by the commit number and I can't seem to find any documentation, or even if this is possible.</p>
139,689
634,972
2024-11-15 14:28:35
7,693,298
294
2011-10-07 22:04:16
526,535
2011-10-07 22:04:16
https://stackoverflow.com/q/7693249
https://stackoverflow.com/a/7693298
<pre><code>git rev-list &lt;since_hash&gt;..HEAD </code></pre> <p>or to include the commit:</p> <pre><code>git rev-list &lt;since_hash&gt;^..HEAD </code></pre> <p>You can use <code>git log</code> instead of <code>git rev-list</code> as well to get additional details.</p>
<pre><code>git rev-list &lt;since_hash&gt;..HEAD </code></pre> <p>or to include the commit:</p> <pre><code>git rev-list &lt;since_hash&gt;^..HEAD </code></pre> <p>You can use <code>git log</code> instead of <code>git rev-list</code> as well to get additional details.</p>
119
git
<h1>How to list commits since certain commit?</h1> <p>Is there anyway to get a list of commits from a given commit number to HEAD?</p> <p>I know this is possible by the commit date, but I need it by the commit number and I can't seem to find any documentation, or even if this is possible.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,736
git
# How to list commits since certain commit? Is there anyway to get a list of commits from a given commit number to HEAD? I know this is possible by the commit date, but I need it by the commit number and I can't seem to find any documentation, or even if this is possible.
``` git rev-list <since_hash>..HEAD ``` or to include the commit: ``` git rev-list <since_hash>^..HEAD ``` You can use `git log` instead of `git rev-list` as well to get additional details.
9237348
What does FETCH_HEAD in Git mean?
305
2012-02-11 02:35:31
<p><code>git pull --help</code> says:</p> <blockquote> <p>In its default mode, <code>git pull</code> is shorthand for <code>git fetch</code> followed by <code>git merge FETCH_HEAD</code>.</p> </blockquote> <p>What is this <code>FETCH_HEAD</code> and what is actually merged during <code>git pull</code>?</p>
327,595
247,243
2024-12-16 14:03:50
9,237,511
293
2012-02-11 03:11:37
119,963
2024-12-16 04:53:12
https://stackoverflow.com/q/9237348
https://stackoverflow.com/a/9237511
<p><code>FETCH_HEAD</code> is a short-lived ref, to keep track of what has just been fetched from the remote repository. <code>git pull</code> first invokes <code>git fetch</code>, in normal cases fetching a branch from the remote; <code>FETCH_HEAD</code> points to the tip of this branch (it stores the SHA1 of the comm...
<p><code>FETCH_HEAD</code> is a short-lived ref, to keep track of what has just been fetched from the remote repository. <code>git pull</code> first invokes <code>git fetch</code>, in normal cases fetching a branch from the remote; <code>FETCH_HEAD</code> points to the tip of this branch (it stores the SHA1 of the comm...
119, 28896, 33720
git, git-fetch, git-pull
<h1>What does FETCH_HEAD in Git mean?</h1> <p><code>git pull --help</code> says:</p> <blockquote> <p>In its default mode, <code>git pull</code> is shorthand for <code>git fetch</code> followed by <code>git merge FETCH_HEAD</code>.</p> </blockquote> <p>What is this <code>FETCH_HEAD</code> and what is actually merged...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,737
git
# What does FETCH_HEAD in Git mean? `git pull --help` says: > In its default mode, `git pull` is shorthand for `git fetch` followed by `git merge FETCH_HEAD`. What is this `FETCH_HEAD` and what is actually merged during `git pull`?
`FETCH_HEAD` is a short-lived ref, to keep track of what has just been fetched from the remote repository. `git pull` first invokes `git fetch`, in normal cases fetching a branch from the remote; `FETCH_HEAD` points to the tip of this branch (it stores the SHA1 of the commit, just as branches do). `git pull` then invok...
8131135
Git: How to diff two different files in different branches?
233
2011-11-15 03:32:44
<p>I have two different files in different branches. How can I diff them in one command?</p> <p>Something like</p> <pre><code># git diff branch1/foo.txt branch2/foo-another.txt </code></pre> <p>I could check out the other file, diff it and restore, but that's quite dirty solution.</p>
59,639
145,989
2022-03-30 12:49:53
8,131,164
293
2011-11-15 03:36:45
1,046,560
2014-09-11 14:47:48
https://stackoverflow.com/q/8131135
https://stackoverflow.com/a/8131164
<pre><code>git diff branch1:full/path/to/foo.txt branch2:full/path/to/foo-another.txt </code></pre> <p>You can also use relative paths:</p> <pre><code>git diff branch1:./relative/path/to/foo.txt branch2:./relative/path/to/foo-another.txt </code></pre>
<pre><code>git diff branch1:full/path/to/foo.txt branch2:full/path/to/foo-another.txt </code></pre> <p>You can also use relative paths:</p> <pre><code>git diff branch1:./relative/path/to/foo.txt branch2:./relative/path/to/foo-another.txt </code></pre>
119, 9033
git, git-diff
<h1>Git: How to diff two different files in different branches?</h1> <p>I have two different files in different branches. How can I diff them in one command?</p> <p>Something like</p> <pre><code># git diff branch1/foo.txt branch2/foo-another.txt </code></pre> <p>I could check out the other file, diff it and restore,...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,738
git
# Git: How to diff two different files in different branches? I have two different files in different branches. How can I diff them in one command? Something like ``` # git diff branch1/foo.txt branch2/foo-another.txt ``` I could check out the other file, diff it and restore, but that's quite dirty solution.
``` git diff branch1:full/path/to/foo.txt branch2:full/path/to/foo-another.txt ``` You can also use relative paths: ``` git diff branch1:./relative/path/to/foo.txt branch2:./relative/path/to/foo-another.txt ```
22366034
Git create branch where detached HEAD is
168
2014-03-12 23:29:25
<p>I tried something like this:</p> <pre><code>git branch temp </code></pre> <p>to create a new branch but <em>don't</em> move the <code>HEAD</code>. But I get:</p> <pre><code># Not currently on any branch. </code></pre> <p>I don't want to merge anything, I just want a new branch at the current <code>HEAD</code>.</...
114,479
3,122,885
2022-07-26 14:35:50
22,366,171
293
2014-03-12 23:39:07
506,338
2014-03-12 23:39:07
https://stackoverflow.com/q/22366034
https://stackoverflow.com/a/22366171
<p>You're sitting on a detached <code>HEAD</code>:</p> <pre><code>git checkout &lt;sha&gt; </code></pre> <p>You want to make a branch at that commit:</p> <pre><code>git branch my-new-branch </code></pre> <p>And now switch to that branch:</p> <pre><code>git checkout my-new-branch </code></pre>
<p>You're sitting on a detached <code>HEAD</code>:</p> <pre><code>git checkout &lt;sha&gt; </code></pre> <p>You want to make a branch at that commit:</p> <pre><code>git branch my-new-branch </code></pre> <p>And now switch to that branch:</p> <pre><code>git checkout my-new-branch </code></pre>
119, 76220, 98582
git, git-branch, git-detached-head
<h1>Git create branch where detached HEAD is</h1> <p>I tried something like this:</p> <pre><code>git branch temp </code></pre> <p>to create a new branch but <em>don't</em> move the <code>HEAD</code>. But I get:</p> <pre><code># Not currently on any branch. </code></pre> <p>I don't want to merge anything, I just wan...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,739
git
# Git create branch where detached HEAD is I tried something like this: ``` git branch temp ``` to create a new branch but *don't* move the `HEAD`. But I get: ``` # Not currently on any branch. ``` I don't want to merge anything, I just want a new branch at the current `HEAD`.
You're sitting on a detached `HEAD`: ``` git checkout <sha> ``` You want to make a branch at that commit: ``` git branch my-new-branch ``` And now switch to that branch: ``` git checkout my-new-branch ```
50525244
Git command output is in editor (vim) and not directly to terminal output
125
2018-05-25 08:54:36
<p>I don't know why but the output from some git command are in editor (vim) and not directly to the terminal output.</p> <p>For example, the command <code>git branch</code> open vim and list the branches but I would like that the output are directly in the terminal.</p> <p>I didn't set vim as default editor on the git...
24,303
9,845,670
2023-08-27 11:58:38
50,600,369
293
2018-05-30 08:52:42
9,845,670
2018-05-30 08:52:42
https://stackoverflow.com/q/50525244
https://stackoverflow.com/a/50600369
<p>Reply to myself.</p> <p>It is a default behavior change introduced in git 2.16.</p> <p>With <code>git --no-pager branch</code> or <code>git config --global pager.branch false</code> it's ok</p>
<p>Reply to myself.</p> <p>It is a default behavior change introduced in git 2.16.</p> <p>With <code>git --no-pager branch</code> or <code>git config --global pager.branch false</code> it's ok</p>
119, 370
git, vim
<h1>Git command output is in editor (vim) and not directly to terminal output</h1> <p>I don't know why but the output from some git command are in editor (vim) and not directly to the terminal output.</p> <p>For example, the command <code>git branch</code> open vim and list the branches but I would like that the output...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,740
git
# Git command output is in editor (vim) and not directly to terminal output I don't know why but the output from some git command are in editor (vim) and not directly to the terminal output. For example, the command `git branch` open vim and list the branches but I would like that the output are directly in the termi...
Reply to myself. It is a default behavior change introduced in git 2.16. With `git --no-pager branch` or `git config --global pager.branch false` it's ok
279169
Deploy a project using Git push
421
2008-11-10 21:04:51
<p>Is it possible to deploy a website using <code>git push</code>? I have a hunch it has something to do with using <a href="http://www.git-scm.com/book/en/v2/Customizing-Git-Git-Hooks" rel="noreferrer">git hooks</a> to perform a <code>git reset --hard</code> on the server side, but how would I go about accomplishing t...
129,698
658
2020-03-25 08:00:54
327,315
292
2008-11-29 07:37:25
658
2014-03-27 19:22:15
https://stackoverflow.com/q/279169
https://stackoverflow.com/a/327315
<p>I found <a href="https://stackoverflow.com/questions/279169/deploy-php-using-git/3387030#3387030">this script</a> on <a href="http://git.or.cz/gitwiki/GitFaq#head-b96f48bc9c925074be9f95c0fce69bcece5f6e73" rel="noreferrer">this site</a> and it seems to work quite well.</p> <ol> <li>Copy over your .git directory to y...
<p>I found <a href="https://stackoverflow.com/questions/279169/deploy-php-using-git/3387030#3387030">this script</a> on <a href="http://git.or.cz/gitwiki/GitFaq#head-b96f48bc9c925074be9f95c0fce69bcece5f6e73" rel="noreferrer">this site</a> and it seems to work quite well.</p> <ol> <li>Copy over your .git directory to y...
119, 190, 1074, 43087
deployment, git, githooks, webserver
<h1>Deploy a project using Git push</h1> <p>Is it possible to deploy a website using <code>git push</code>? I have a hunch it has something to do with using <a href="http://www.git-scm.com/book/en/v2/Customizing-Git-Git-Hooks" rel="noreferrer">git hooks</a> to perform a <code>git reset --hard</code> on the server side,...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,741
git
# Deploy a project using Git push Is it possible to deploy a website using `git push`? I have a hunch it has something to do with using [git hooks](http://www.git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) to perform a `git reset --hard` on the server side, but how would I go about accomplishing this?
I found [this script](https://stackoverflow.com/questions/279169/deploy-php-using-git/3387030#3387030) on [this site](http://git.or.cz/gitwiki/GitFaq#head-b96f48bc9c925074be9f95c0fce69bcece5f6e73) and it seems to work quite well. 1. Copy over your .git directory to your web server 2. On your local copy, modify your .g...
15715825
How do you get the Git repository's name in some Git repository?
288
2013-03-30 06:47:04
<p>When you are working in some Git directory, how can you get the Git repository name in some Git repository? Are there any Git commands?</p> <pre><code># I did check out bar repository and working in somewhere # under bar directory at this moment such as below. $ git clone git://github.com/foo/bar.git $ cd bar/baz...
495,904
688,608
2025-06-26 13:17:43
15,716,016
292
2013-03-30 07:09:46
1,512,161
2023-02-22 01:12:26
https://stackoverflow.com/q/15715825
https://stackoverflow.com/a/15716016
<p>In Git, there's no concept of a repository name. The repository itself is kept under a directory in the file system (the one that contains the <code>.git</code> directory) and you can get the name of that directory with the following command:</p> <pre class="lang-bash prettyprint-override"><code>basename `git rev-pa...
<p>In Git, there's no concept of a repository name. The repository itself is kept under a directory in the file system (the one that contains the <code>.git</code> directory) and you can get the name of that directory with the following command:</p> <pre class="lang-bash prettyprint-override"><code>basename `git rev-pa...
119, 7330
git, repository
<h1>How do you get the Git repository's name in some Git repository?</h1> <p>When you are working in some Git directory, how can you get the Git repository name in some Git repository? Are there any Git commands?</p> <pre><code># I did check out bar repository and working in somewhere # under bar directory at this mo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,742
git
# How do you get the Git repository's name in some Git repository? When you are working in some Git directory, how can you get the Git repository name in some Git repository? Are there any Git commands? ``` # I did check out bar repository and working in somewhere # under bar directory at this moment such as below. ...
In Git, there's no concept of a repository name. The repository itself is kept under a directory in the file system (the one that contains the `.git` directory) and you can get the name of that directory with the following command: ``` basename `git rev-parse --show-toplevel` ``` The `git rev-parse --show-toplevel` p...
14207414
How to show changed file name only with 'git log'
202
2013-01-08 02:40:29
<p>Is it able to show changed <strong>file name</strong> only with <code>git log</code>?</p>
179,186
380,774
2021-07-04 19:51:29
14,227,496
291
2013-01-09 02:40:28
380,774
2021-07-04 19:48:09
https://stackoverflow.com/q/14207414
https://stackoverflow.com/a/14227496
<p>I use</p> <pre><code>git log --name-only </code></pre> <p>or</p> <pre><code>git log --name-only --oneline </code></pre> <p>for short.</p>
<p>I use</p> <pre><code>git log --name-only </code></pre> <p>or</p> <pre><code>git log --name-only --oneline </code></pre> <p>for short.</p>
119
git
<h1>How to show changed file name only with 'git log'</h1> <p>Is it able to show changed <strong>file name</strong> only with <code>git log</code>?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,745
git
# How to show changed file name only with 'git log' Is it able to show changed **file name** only with `git log`?
I use ``` git log --name-only ``` or ``` git log --name-only --oneline ``` for short.
25430600
Difference between git pull --rebase and git pull --ff-only
265
2014-08-21 15:47:03
<p>Let's say <code>origin/master</code> has commit <code>A--B--C</code> and my <code>local/master</code> has commit <code>A--B--D</code>.</p> <p>What will happen if I use <code>git pull --rebase</code> ?</p> <p>What will happen if I use <code>git pull --ff-only</code> ?</p> <p>Is there any difference in the resultin...
230,770
1,546,701
2014-08-21 16:04:36
25,430,795
290
2014-08-21 15:57:23
846,273
2014-08-21 16:04:36
https://stackoverflow.com/q/25430600
https://stackoverflow.com/a/25430795
<blockquote> <p>What will happen if I use git pull --rebase ?</p> </blockquote> <p><code>git pull --rebase</code> is roughly equivalent to</p> <pre><code>git fetch git rebase origin/master </code></pre> <p>i.e. your remote changes (<code>C</code>) will be applied before the local changes (<code>D</code>), resultin...
<blockquote> <p>What will happen if I use git pull --rebase ?</p> </blockquote> <p><code>git pull --rebase</code> is roughly equivalent to</p> <pre><code>git fetch git rebase origin/master </code></pre> <p>i.e. your remote changes (<code>C</code>) will be applied before the local changes (<code>D</code>), resultin...
119, 28896, 29934
git, git-pull, git-rebase
<h1>Difference between git pull --rebase and git pull --ff-only</h1> <p>Let's say <code>origin/master</code> has commit <code>A--B--C</code> and my <code>local/master</code> has commit <code>A--B--D</code>.</p> <p>What will happen if I use <code>git pull --rebase</code> ?</p> <p>What will happen if I use <code>git pu...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,746
git
# Difference between git pull --rebase and git pull --ff-only Let's say `origin/master` has commit `A--B--C` and my `local/master` has commit `A--B--D`. What will happen if I use `git pull --rebase` ? What will happen if I use `git pull --ff-only` ? Is there any difference in the resulting commit tree ?
> What will happen if I use git pull --rebase ? `git pull --rebase` is roughly equivalent to ``` git fetch git rebase origin/master ``` i.e. your remote changes (`C`) will be applied before the local changes (`D`), resulting in the following tree ``` A -- B -- C -- D ``` --- > What will happen if I use git pull -...
18329621
How to store a git config as part of the repository?
256
2013-08-20 07:48:27
<p>I'm using filters to mangle files during checkout like described <a href="https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#Keyword-Expansion" rel="noreferrer">here</a>. Now the problem is that filter definition is only stored in my local configuration file:</p> <pre><code>$ cat .git/config .... [filter...
102,933
360,390
2024-06-26 19:35:24
18,330,114
290
2013-08-20 08:15:20
2,648,942
2024-06-26 19:35:24
https://stackoverflow.com/q/18329621
https://stackoverflow.com/a/18330114
<p>There are 3 supported scopes of <code>.gitconfig</code> file: <code>--system</code>, <code>--global</code>, <code>--local</code>. You can also create a custom configuration file, and include it in one of the supported files.</p> <p>For your needs <em>custom</em> is the right choice. Instead of writing your filter in...
<p>There are 3 supported scopes of <code>.gitconfig</code> file: <code>--system</code>, <code>--global</code>, <code>--local</code>. You can also create a custom configuration file, and include it in one of the supported files.</p> <p>For your needs <em>custom</em> is the right choice. Instead of writing your filter in...
119
git
<h1>How to store a git config as part of the repository?</h1> <p>I'm using filters to mangle files during checkout like described <a href="https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#Keyword-Expansion" rel="noreferrer">here</a>. Now the problem is that filter definition is only stored in my local conf...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,747
git
# How to store a git config as part of the repository? I'm using filters to mangle files during checkout like described [here](https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#Keyword-Expansion). Now the problem is that filter definition is only stored in my local configuration file: ``` $ cat .git/confi...
There are 3 supported scopes of `.gitconfig` file: `--system`, `--global`, `--local`. You can also create a custom configuration file, and include it in one of the supported files. For your needs *custom* is the right choice. Instead of writing your filter in `.git/config` you should save it in `.gitconfig` file in yo...
10349302
How to git log from all branches for the author at once?
303
2012-04-27 10:52:35
<p>I need to get the report of all commits that the author did. So far, I have the script that wraps the following command:</p> <pre><code>git log --pretty=format:&quot;%ad:%an:%d:%B&quot; --date=short --reverse --all --since=2.months.ago --author=Petr </code></pre> <p>It works fine. However, it reports only the acti...
153,616
1,346,705
2023-11-30 20:26:08
10,351,263
289
2012-04-27 13:11:53
11,343
2023-11-30 20:25:24
https://stackoverflow.com/q/10349302
https://stackoverflow.com/a/10351263
<p>Your command is right, since you use the <code>--all</code> switch which gives all commits from all branches. To answer the question in your comment, it works also in bare repositories.</p> <pre><code>git log --all --author=Petr </code></pre>
<p>Your command is right, since you use the <code>--all</code> switch which gives all commits from all branches. To answer the question in your comment, it works also in bare repositories.</p> <pre><code>git log --all --author=Petr </code></pre>
119
git
<h1>How to git log from all branches for the author at once?</h1> <p>I need to get the report of all commits that the author did. So far, I have the script that wraps the following command:</p> <pre><code>git log --pretty=format:&quot;%ad:%an:%d:%B&quot; --date=short --reverse --all --since=2.months.ago --author=Petr ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,748
git
# How to git log from all branches for the author at once? I need to get the report of all commits that the author did. So far, I have the script that wraps the following command: ``` git log --pretty=format:"%ad:%an:%d:%B" --date=short --reverse --all --since=2.months.ago --author=Petr ``` It works fine. However, i...
Your command is right, since you use the `--all` switch which gives all commits from all branches. To answer the question in your comment, it works also in bare repositories. ``` git log --all --author=Petr ```
4858047
.gitignore and "The following untracked working tree files would be overwritten by checkout"
1,050
2011-02-01 01:39:44
<p>So I added a folder to my .gitignore file.</p> <p>Once I do a <code>git status</code> it tells me</p> <pre><code># On branch latest nothing to commit (working directory clean) </code></pre> <p>However, when I try to change branches I get the following:</p> <pre><code>My-MacBook-Pro:webapp marcamillion$ git check...
1,683,418
91,970
2025-01-21 20:25:25
4,858,141
288
2011-02-01 01:59:22
227,513
2016-10-11 08:25:15
https://stackoverflow.com/q/4858047
https://stackoverflow.com/a/4858141
<p>It seems like you want the files ignored but they have already been commited. .gitignore has no effect on files that are already in the repo so they need to be removed with <code>git rm --cached</code>. The <code>--cached</code> will prevent it from having any effect on your working copy and it will just mark as rem...
<p>It seems like you want the files ignored but they have already been commited. .gitignore has no effect on files that are already in the repo so they need to be removed with <code>git rm --cached</code>. The <code>--cached</code> will prevent it from having any effect on your working copy and it will just mark as rem...
119, 25056, 28897
git, gitignore, git-merge
<h1>.gitignore and "The following untracked working tree files would be overwritten by checkout"</h1> <p>So I added a folder to my .gitignore file.</p> <p>Once I do a <code>git status</code> it tells me</p> <pre><code># On branch latest nothing to commit (working directory clean) </code></pre> <p>However, when I try...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,749
git
# .gitignore and "The following untracked working tree files would be overwritten by checkout" So I added a folder to my .gitignore file. Once I do a `git status` it tells me ``` # On branch latest nothing to commit (working directory clean) ``` However, when I try to change branches I get the following: ``` My-Ma...
It seems like you want the files ignored but they have already been commited. .gitignore has no effect on files that are already in the repo so they need to be removed with `git rm --cached`. The `--cached` will prevent it from having any effect on your working copy and it will just mark as removed the next time you co...
8475958
How can I find out what version of git I'm running?
184
2011-12-12 14:37:51
<p>I'm trying to follow some tutorials to learn how to use Git but some of the instructions are for specific versions.</p> <p>Is there a command that I can use find out what version I have installed?</p>
192,110
28,672
2024-12-30 03:05:33
8,475,994
288
2011-12-12 14:39:49
31,582
2011-12-12 14:39:49
https://stackoverflow.com/q/8475958
https://stackoverflow.com/a/8475994
<pre><code>$ git --version git version 1.7.3.4 </code></pre> <p><code>git help</code> and <code>man git</code> both hint at the available arguments you can pass to the command-line tool</p>
<pre><code>$ git --version git version 1.7.3.4 </code></pre> <p><code>git help</code> and <code>man git</code> both hint at the available arguments you can pass to the command-line tool</p>
119
git
<h1>How can I find out what version of git I'm running?</h1> <p>I'm trying to follow some tutorials to learn how to use Git but some of the instructions are for specific versions.</p> <p>Is there a command that I can use find out what version I have installed?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,750
git
# How can I find out what version of git I'm running? I'm trying to follow some tutorials to learn how to use Git but some of the instructions are for specific versions. Is there a command that I can use find out what version I have installed?
``` $ git --version git version 1.7.3.4 ``` `git help` and `man git` both hint at the available arguments you can pass to the command-line tool
10461214
Why is git push gerrit HEAD:refs/for/master used instead of git push origin master
172
2012-05-05 11:05:05
<p>I've just started using gerrit and I want to know why we need to do <code>git push gerrit HEAD:refs/for/master</code> instead of doing <code>git push origin master</code></p> <p>If I do <code>git push origin master</code> I get the error saying <code>! [remote rejected] master -&gt; master (prohibited by Gerrit)</c...
226,785
235,055
2022-10-28 01:50:00
10,461,674
288
2012-05-05 12:05:08
1,084,945
2016-05-19 05:34:53
https://stackoverflow.com/q/10461214
https://stackoverflow.com/a/10461674
<p>The documentation for Gerrit, in particular the <a href="https://gerrit-review.googlesource.com/Documentation/user-upload.html" rel="noreferrer">"Push changes"</a> section, explains that you push to the "magical <code>refs/for/'branch'</code> ref using any Git client tool".</p> <p>The following image is taken from ...
<p>The documentation for Gerrit, in particular the <a href="https://gerrit-review.googlesource.com/Documentation/user-upload.html" rel="noreferrer">"Push changes"</a> section, explains that you push to the "magical <code>refs/for/'branch'</code> ref using any Git client tool".</p> <p>The following image is taken from ...
119, 52272
gerrit, git
<h1>Why is git push gerrit HEAD:refs/for/master used instead of git push origin master</h1> <p>I've just started using gerrit and I want to know why we need to do <code>git push gerrit HEAD:refs/for/master</code> instead of doing <code>git push origin master</code></p> <p>If I do <code>git push origin master</code> I ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,751
git
# Why is git push gerrit HEAD:refs/for/master used instead of git push origin master I've just started using gerrit and I want to know why we need to do `git push gerrit HEAD:refs/for/master` instead of doing `git push origin master` If I do `git push origin master` I get the error saying `! [remote rejected] master ...
The documentation for Gerrit, in particular the ["Push changes"](https://gerrit-review.googlesource.com/Documentation/user-upload.html) section, explains that you push to the "magical `refs/for/'branch'` ref using any Git client tool". The following image is taken from [the Intro to Gerrit](https://gerrit-review.googl...
6403601
Purging file from Git repo failed, unable to create new backup
158
2011-06-19 16:24:17
<p>I tried to remove a file from my remote repo by running:</p> <pre><code>git filter-branch --index-filter 'git rm --cached --ignore-unmatch Rakefile' HEAD </code></pre> <p>But Git complains that </p> <blockquote> <p>Cannot create new backup. A previous backup already exists in refs/original/<br> Force overwrit...
63,610
225,769
2016-02-10 20:13:38
6,404,368
288
2011-06-19 18:37:05
112,968
2014-04-04 00:53:09
https://stackoverflow.com/q/6403601
https://stackoverflow.com/a/6404368
<p>You have already performed a filter-branch operation. After filter-branch, Git keeps refs to the old commits around, in case something goes wrong. </p> <p>You can find those in <code>.git/refs/original/…</code>. Either delete that directory and all files within, or use the <code>-f</code> flag to force Git to delet...
<p>You have already performed a filter-branch operation. After filter-branch, Git keeps refs to the old commits around, in case something goes wrong. </p> <p>You can find those in <code>.git/refs/original/…</code>. Either delete that directory and all files within, or use the <code>-f</code> flag to force Git to delet...
119, 46509, 53850, 91259
git, git-commit, git-filter-branch, git-rewrite-history
<h1>Purging file from Git repo failed, unable to create new backup</h1> <p>I tried to remove a file from my remote repo by running:</p> <pre><code>git filter-branch --index-filter 'git rm --cached --ignore-unmatch Rakefile' HEAD </code></pre> <p>But Git complains that </p> <blockquote> <p>Cannot create new backup....
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,752
git
# Purging file from Git repo failed, unable to create new backup I tried to remove a file from my remote repo by running: ``` git filter-branch --index-filter 'git rm --cached --ignore-unmatch Rakefile' HEAD ``` But Git complains that > Cannot create new backup. A previous backup already exists in refs/original/ ...
You have already performed a filter-branch operation. After filter-branch, Git keeps refs to the old commits around, in case something goes wrong. You can find those in `.git/refs/original/…`. Either delete that directory and all files within, or use the `-f` flag to force Git to delete the old references. ``` git fi...
9984223
What happens to git commits created in a detached HEAD state?
202
2012-04-02 21:38:04
<p>This is what happened:</p> <p>I have a branch A. On branch A I committed a bunch of changes. I was not happy with the code, so I checked out the previous commit in branch A. I then made a bunch more changes and committed them on branch A. Now I can not find this commit anywhere. Did I lose this code?</p>
75,557
321,721
2022-03-28 14:00:01
9,984,260
287
2012-04-02 21:40:48
82,294
2012-04-02 21:40:48
https://stackoverflow.com/q/9984223
https://stackoverflow.com/a/9984260
<p>The old commit is still in the reflog.</p> <pre><code>git reflog </code></pre> <p>This will show a list of commits, and the "lost" commit should be in there. You can make it into a new branch. For example, if the SHA-1 is ba5a739, then you can make a new branch named "new-branch" at the old commit with:</p> <pr...
<p>The old commit is still in the reflog.</p> <pre><code>git reflog </code></pre> <p>This will show a list of commits, and the "lost" commit should be in there. You can make it into a new branch. For example, if the SHA-1 is ba5a739, then you can make a new branch named "new-branch" at the old commit with:</p> <pr...
119
git
<h1>What happens to git commits created in a detached HEAD state?</h1> <p>This is what happened:</p> <p>I have a branch A. On branch A I committed a bunch of changes. I was not happy with the code, so I checked out the previous commit in branch A. I then made a bunch more changes and committed them on branch A. Now I ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,753
git
# What happens to git commits created in a detached HEAD state? This is what happened: I have a branch A. On branch A I committed a bunch of changes. I was not happy with the code, so I checked out the previous commit in branch A. I then made a bunch more changes and committed them on branch A. Now I can not find thi...
The old commit is still in the reflog. ``` git reflog ``` This will show a list of commits, and the "lost" commit should be in there. You can make it into a new branch. For example, if the SHA-1 is ba5a739, then you can make a new branch named "new-branch" at the old commit with: ``` git branch new-branch ba5a739 ``...
8786564
Cannot push to Heroku because key fingerprint
131
2012-01-09 09:55:27
<p>I am new to Rails, and I was trying to deploy a very simple app to Heroku. This is the second app that I deploy, and the first one I was able to do it just fine. However I am having some issues with this one. Whenever I "<strong>git push heroku master</strong>", I get this error:</p> <blockquote> <p>! Your key w...
45,716
1,138,379
2022-12-23 01:54:17
9,149,518
287
2012-02-05 13:13:32
288,379
2022-12-23 01:54:17
https://stackoverflow.com/q/8786564
https://stackoverflow.com/a/9149518
<p>I had to add my new rsa identity in my machine!</p> <p>So, first of all I created a new rsa key:</p> <pre><code>ssh-keygen -t rsa -C &quot;giordano.scalzo[at]gmail.com&quot; -f ~/.ssh/id_rsa_heroku </code></pre> <p>then added it to my machine</p> <pre><code>ssh-add ~/.ssh/id_rsa_heroku </code></pre> <p>and, finally...
<p>I had to add my new rsa identity in my machine!</p> <p>So, first of all I created a new rsa key:</p> <pre><code>ssh-keygen -t rsa -C &quot;giordano.scalzo[at]gmail.com&quot; -f ~/.ssh/id_rsa_heroku </code></pre> <p>then added it to my machine</p> <pre><code>ssh-add ~/.ssh/id_rsa_heroku </code></pre> <p>and, finally...
119, 386, 8279, 28898
git, git-push, heroku, ssh
<h1>Cannot push to Heroku because key fingerprint</h1> <p>I am new to Rails, and I was trying to deploy a very simple app to Heroku. This is the second app that I deploy, and the first one I was able to do it just fine. However I am having some issues with this one. Whenever I "<strong>git push heroku master</strong>",...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,755
git
# Cannot push to Heroku because key fingerprint I am new to Rails, and I was trying to deploy a very simple app to Heroku. This is the second app that I deploy, and the first one I was able to do it just fine. However I am having some issues with this one. Whenever I "**git push heroku master**", I get this error: > ...
I had to add my new rsa identity in my machine! So, first of all I created a new rsa key: ``` ssh-keygen -t rsa -C "giordano.scalzo[at]gmail.com" -f ~/.ssh/id_rsa_heroku ``` then added it to my machine ``` ssh-add ~/.ssh/id_rsa_heroku ``` and, finally, to Heroku ``` heroku keys:add ~/.ssh/id_rsa_heroku.pub ``` ...
4348590
How can I make git ignore future revisions to a file?
250
2010-12-03 18:23:49
<p>I have created a default version of a file included in a git repository. It's important that when someone clones the repository, they get a copy of this file. However, I would like to set git so that it ignores changes to this file later. <code>.gitignore</code> works only on untracked files.</p> <p>My motivatio...
48,555
287,289
2020-01-09 20:55:42
39,776,107
286
2016-09-29 17:03:05
717,274
2020-01-09 20:55:42
https://stackoverflow.com/q/4348590
https://stackoverflow.com/a/39776107
<p>As many others have mentioned, a good modern solution is:</p> <pre class="lang-sh prettyprint-override"><code>git update-index --skip-worktree default_values.txt </code></pre> <p>That will ignore changes to that file, both local and upstream, until you decide to allow them again with:</p> <pre class="lang-sh pr...
<p>As many others have mentioned, a good modern solution is:</p> <pre class="lang-sh prettyprint-override"><code>git update-index --skip-worktree default_values.txt </code></pre> <p>That will ignore changes to that file, both local and upstream, until you decide to allow them again with:</p> <pre class="lang-sh pr...
119, 56102
git, gitattributes
<h1>How can I make git ignore future revisions to a file?</h1> <p>I have created a default version of a file included in a git repository. It's important that when someone clones the repository, they get a copy of this file. However, I would like to set git so that it ignores changes to this file later. <code>.gitig...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,756
git
# How can I make git ignore future revisions to a file? I have created a default version of a file included in a git repository. It's important that when someone clones the repository, they get a copy of this file. However, I would like to set git so that it ignores changes to this file later. `.gitignore` works only ...
As many others have mentioned, a good modern solution is: ``` git update-index --skip-worktree default_values.txt ``` That will ignore changes to that file, both local and upstream, until you decide to allow them again with: ``` git update-index --no-skip-worktree default_values.txt ``` You can get a list of files ...
9368205
Given a number, find the next higher number which has the exact same set of digits as the original number
238
2012-02-20 20:50:03
<p>I just bombed an interview and made pretty much zero progress on my interview question.</p> <blockquote> <p>Given a number, find the next higher number which has the exact same set of digits as the original number. For example: given 38276 return 38627</p> </blockquote> <p>I wanted to begin by finding the index of t...
106,562
1,222,002
2022-04-18 18:51:13
9,368,616
286
2012-02-20 21:23:44
238,419
2016-09-02 16:21:08
https://stackoverflow.com/q/9368205
https://stackoverflow.com/a/9368616
<p>You can do it in <code>O(n)</code> (where <code>n</code> is the number of digits) like this:</p> <p>Starting from the right, you find the first pair-of-digits such that the left-digit is smaller than the right-digit. Let's refer to the left-digit by "digit-x". Find the smallest number larger than digit-x to the r...
<p>You can do it in <code>O(n)</code> (where <code>n</code> is the number of digits) like this:</p> <p>Starting from the right, you find the first pair-of-digits such that the left-digit is smaller than the right-digit. Let's refer to the left-digit by "digit-x". Find the smallest number larger than digit-x to the r...
248, 9914
algorithm, digits
<h1>Given a number, find the next higher number which has the exact same set of digits as the original number</h1> <p>I just bombed an interview and made pretty much zero progress on my interview question.</p> <blockquote> <p>Given a number, find the next higher number which has the exact same set of digits as the orig...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,757
git
# Given a number, find the next higher number which has the exact same set of digits as the original number I just bombed an interview and made pretty much zero progress on my interview question. > Given a number, find the next higher number which has the exact same > set of digits as the original number. For example...
You can do it in `O(n)` (where `n` is the number of digits) like this: Starting from the right, you find the first pair-of-digits such that the left-digit is smaller than the right-digit. Let's refer to the left-digit by "digit-x". Find the smallest number larger than digit-x to the right of digit-x, and place it imme...
10292480
When deleting remote git branch "error: unable to push to unqualified destination"
150
2012-04-24 05:59:51
<p>I'm trying to delete a remote git branch with </p> <pre><code>git push origin :my_remote_branch </code></pre> <p>and getting:</p> <pre><code>error: unable to push to unqualified destination: my_remote_branch The destination refspec neither matches an existing ref on the remote nor begins with refs/, and we are un...
58,692
335,523
2018-05-29 10:07:50
10,293,324
286
2012-04-24 07:11:57
201,725
2012-04-25 06:41:45
https://stackoverflow.com/q/10292480
https://stackoverflow.com/a/10293324
<p>The fact that <code>refs/remotes/origin/my_remote_branch</code> exists in your local repository does not imply <code>refs/heads/my_remote_branch</code> exists in the <code>origin</code> remote repository.</p> <p>Do <code>git fetch -p origin</code> to make <code>refs/remotes/origin/my_remote_branch</code> go away if...
<p>The fact that <code>refs/remotes/origin/my_remote_branch</code> exists in your local repository does not imply <code>refs/heads/my_remote_branch</code> exists in the <code>origin</code> remote repository.</p> <p>Do <code>git fetch -p origin</code> to make <code>refs/remotes/origin/my_remote_branch</code> go away if...
119
git
<h1>When deleting remote git branch "error: unable to push to unqualified destination"</h1> <p>I'm trying to delete a remote git branch with </p> <pre><code>git push origin :my_remote_branch </code></pre> <p>and getting:</p> <pre><code>error: unable to push to unqualified destination: my_remote_branch The destinatio...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,759
git
# When deleting remote git branch "error: unable to push to unqualified destination" I'm trying to delete a remote git branch with ``` git push origin :my_remote_branch ``` and getting: ``` error: unable to push to unqualified destination: my_remote_branch The destination refspec neither matches an existing ref on ...
The fact that `refs/remotes/origin/my_remote_branch` exists in your local repository does not imply `refs/heads/my_remote_branch` exists in the `origin` remote repository. Do `git fetch -p origin` to make `refs/remotes/origin/my_remote_branch` go away if it's already deleted in origin. The `-p` option tells fetch to d...
4902795
Undo git mv (rename)
183
2011-02-04 20:49:56
<p>What is the right way to undo a rename in git, like:</p> <pre><code>git mv file1 file2 </code></pre>
93,016
318,760
2022-11-02 20:52:22
4,902,817
284
2011-02-04 20:52:27
424,509
2020-07-23 16:21:45
https://stackoverflow.com/q/4902795
https://stackoverflow.com/a/4902817
<p>Non-cheeky answer:</p> <pre><code>git mv file2 file1 </code></pre> <blockquote> <p>Updates the index for both old and new paths automatically.</p> </blockquote> <p>Check documentation of <a href="https://git-scm.com/docs/git-mv" rel="noreferrer">git mv</a></p>
<p>Non-cheeky answer:</p> <pre><code>git mv file2 file1 </code></pre> <blockquote> <p>Updates the index for both old and new paths automatically.</p> </blockquote> <p>Check documentation of <a href="https://git-scm.com/docs/git-mv" rel="noreferrer">git mv</a></p>
119, 4510, 5766, 12668
git, mv, rename, undo
<h1>Undo git mv (rename)</h1> <p>What is the right way to undo a rename in git, like:</p> <pre><code>git mv file1 file2 </code></pre>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,760
git
# Undo git mv (rename) What is the right way to undo a rename in git, like: ``` git mv file1 file2 ```
Non-cheeky answer: ``` git mv file2 file1 ``` > Updates the index for both old and new paths automatically. Check documentation of [git mv](https://git-scm.com/docs/git-mv)
35945860
View git log without merge commits
173
2016-03-11 17:00:16
<p>I'm trying to view commits made by a specific user, and want to remove any merges done by the user from the output. How can I do so?</p> <p>I can check for the commits of a user using <code>git log --author=&lt;name&gt;</code>, but can't remove the merge commits in the output.</p> <p>PS: Merge conflicts do not ha...
87,781
1,860,929
2023-07-06 04:27:19
35,946,023
284
2016-03-11 17:09:03
274,299
2023-07-06 04:27:19
https://stackoverflow.com/q/35945860
https://stackoverflow.com/a/35946023
<p>use</p> <pre><code>git log --author=&lt;name&gt; --no-merges </code></pre> <p>Additionally the <code>--first-parent</code> option may give useful result for you:</p> <blockquote> <p><code>--first-parent</code></p> <p>Follow only the first parent commit upon seeing a merge commit. This option can give a better overvi...
<p>use</p> <pre><code>git log --author=&lt;name&gt; --no-merges </code></pre> <p>Additionally the <code>--first-parent</code> option may give useful result for you:</p> <blockquote> <p><code>--first-parent</code></p> <p>Follow only the first parent commit upon seeing a merge commit. This option can give a better overvi...
119, 47913
git, git-log
<h1>View git log without merge commits</h1> <p>I'm trying to view commits made by a specific user, and want to remove any merges done by the user from the output. How can I do so?</p> <p>I can check for the commits of a user using <code>git log --author=&lt;name&gt;</code>, but can't remove the merge commits in the o...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,761
git
# View git log without merge commits I'm trying to view commits made by a specific user, and want to remove any merges done by the user from the output. How can I do so? I can check for the commits of a user using `git log --author=<name>`, but can't remove the merge commits in the output. PS: Merge conflicts do not...
use ``` git log --author=<name> --no-merges ``` Additionally the `--first-parent` option may give useful result for you: > `--first-parent` > > Follow only the first parent commit upon seeing a merge commit. This option can give a better overview when viewing the > evolution of a particular topic branch, because mer...
3555107
Git clone particular version of remote repository
249
2010-08-24 09:26:18
<p>I cloned a remote git repository about a month ago. The remote repository has undergone many changes and has now become unstable. Now I need another copy of the repository, version identical to the one I cloned a month ago.</p> <p>How do I do this?</p>
406,575
341,078
2019-08-17 14:22:58
3,555,202
283
2010-08-24 09:41:20
72,824
2010-08-24 09:41:20
https://stackoverflow.com/q/3555107
https://stackoverflow.com/a/3555202
<p>You could "reset" your repository to any commit you want (e.g. 1 month ago). </p> <p>Use <a href="http://git-scm.com/docs/git-reset" rel="noreferrer">git-reset</a> for that:</p> <pre><code>git clone [remote_address_here] my_repo cd my_repo git reset --hard [ENTER HERE THE COMMIT HASH YOU WANT] </code></pre>
<p>You could "reset" your repository to any commit you want (e.g. 1 month ago). </p> <p>Use <a href="http://git-scm.com/docs/git-reset" rel="noreferrer">git-reset</a> for that:</p> <pre><code>git clone [remote_address_here] my_repo cd my_repo git reset --hard [ENTER HERE THE COMMIT HASH YOU WANT] </code></pre>
119, 34099
git, git-clone
<h1>Git clone particular version of remote repository</h1> <p>I cloned a remote git repository about a month ago. The remote repository has undergone many changes and has now become unstable. Now I need another copy of the repository, version identical to the one I cloned a month ago.</p> <p>How do I do this?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,762
git
# Git clone particular version of remote repository I cloned a remote git repository about a month ago. The remote repository has undergone many changes and has now become unstable. Now I need another copy of the repository, version identical to the one I cloned a month ago. How do I do this?
You could "reset" your repository to any commit you want (e.g. 1 month ago). Use [git-reset](http://git-scm.com/docs/git-reset) for that: ``` git clone [remote_address_here] my_repo cd my_repo git reset --hard [ENTER HERE THE COMMIT HASH YOU WANT] ```
6229764
Overwriting my local branch with remote branch
169
2011-06-03 16:12:24
<p>I have completely fubar'd my local branch, and would like to start over. The version on the server is correct. </p> <p>I don't want to start over, I would like to use my local history to fix my huge screwup. (I can if I have to.)</p> <p><code>git fetch branchname</code>, and <code>git pull branchname</code> don't ...
140,844
4,140
2023-10-01 12:55:43
6,229,837
283
2011-06-03 16:20:39
112,968
2023-10-01 12:55:43
https://stackoverflow.com/q/6229764
https://stackoverflow.com/a/6229837
<p>First, create a new branch in the current position (in case you need your old 'meesed up' history):</p> <pre><code>git branch fubar-pin </code></pre> <p>Update your list of remote branches and sync new commits:</p> <pre><code>git fetch --all </code></pre> <p>Then, reset your branch to the point where origin/branch p...
<p>First, create a new branch in the current position (in case you need your old 'meesed up' history):</p> <pre><code>git branch fubar-pin </code></pre> <p>Update your list of remote branches and sync new commits:</p> <pre><code>git fetch --all </code></pre> <p>Then, reset your branch to the point where origin/branch p...
119
git
<h1>Overwriting my local branch with remote branch</h1> <p>I have completely fubar'd my local branch, and would like to start over. The version on the server is correct. </p> <p>I don't want to start over, I would like to use my local history to fix my huge screwup. (I can if I have to.)</p> <p><code>git fetch branch...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,763
git
# Overwriting my local branch with remote branch I have completely fubar'd my local branch, and would like to start over. The version on the server is correct. I don't want to start over, I would like to use my local history to fix my huge screwup. (I can if I have to.) `git fetch branchname`, and `git pull branchna...
First, create a new branch in the current position (in case you need your old 'meesed up' history): ``` git branch fubar-pin ``` Update your list of remote branches and sync new commits: ``` git fetch --all ``` Then, reset your branch to the point where origin/branch points to: ``` git reset --hard origin/branch `...
4735556
Git: "Not currently on any branch." Is there an easy way to get back on a branch, while keeping the changes?
264
2011-01-19 13:05:21
<p>So I've done some work in the repository and when I'm about to commit I realize that I'm not currently on any branch.</p> <p>This happens a lot when working with submodules and I am able to solve it, but the process is tedious and I've been thinking that there must be an easier way to do this. </p> <p>Is there an ...
308,079
310,121
2021-05-27 11:13:37
4,735,584
282
2011-01-19 13:08:02
85,134
2017-02-23 06:58:26
https://stackoverflow.com/q/4735556
https://stackoverflow.com/a/4735584
<p>If you have not committed:</p> <pre><code>git stash git checkout some-branch git stash pop </code></pre> <p>If you have committed and have not changed anything since:</p> <pre><code>git log --oneline -n1 # this will give you the SHA git checkout some-branch git merge ${commit-sha} </code></pre> <p>If you have co...
<p>If you have not committed:</p> <pre><code>git stash git checkout some-branch git stash pop </code></pre> <p>If you have committed and have not changed anything since:</p> <pre><code>git log --oneline -n1 # this will give you the SHA git checkout some-branch git merge ${commit-sha} </code></pre> <p>If you have co...
119, 1879, 37230
branch, git, git-checkout
<h1>Git: "Not currently on any branch." Is there an easy way to get back on a branch, while keeping the changes?</h1> <p>So I've done some work in the repository and when I'm about to commit I realize that I'm not currently on any branch.</p> <p>This happens a lot when working with submodules and I am able to solve it...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,764
git
# Git: "Not currently on any branch." Is there an easy way to get back on a branch, while keeping the changes? So I've done some work in the repository and when I'm about to commit I realize that I'm not currently on any branch. This happens a lot when working with submodules and I am able to solve it, but the proces...
If you have not committed: ``` git stash git checkout some-branch git stash pop ``` If you have committed and have not changed anything since: ``` git log --oneline -n1 # this will give you the SHA git checkout some-branch git merge ${commit-sha} ``` If you have committed and then done extra work: ``` git stash gi...
21022638
Pod install is staying on "Setting up CocoaPods Master repo"
261
2014-01-09 14:15:04
<p>I'm cloning a project from a git repo, but when I execute <code>pod install</code> the first line I see is "Setting up CocoaPods Master repo" and after that I can't see anything more, the console stops there.</p> <p>I don't know what is happening. Anyone knows what's happening here? Why Does CocoaPods stop there?</...
138,317
1,336,608
2023-01-17 13:11:14
21,852,985
282
2014-02-18 11:54:52
228,109
2020-10-22 02:54:08
https://stackoverflow.com/q/21022638
https://stackoverflow.com/a/21852985
<p>You could try running in verbose mode:</p> <pre><code>pod install --verbose </code></pre> <p>That'll show you what cocoa pods are up to:</p> <pre><code>Setting up CocoaPods master repo Cloning spec repo `master` from `https://github.com/CocoaPods/Specs.git` (branch `master`) $ /usr/bin/git clone 'https://github.c...
<p>You could try running in verbose mode:</p> <pre><code>pod install --verbose </code></pre> <p>That'll show you what cocoa pods are up to:</p> <pre><code>Setting up CocoaPods master repo Cloning spec repo `master` from `https://github.com/CocoaPods/Specs.git` (branch `master`) $ /usr/bin/git clone 'https://github.c...
119, 7003, 58338, 77741, 143563
cocoapods, git, ios, objective-c, pod-install
<h1>Pod install is staying on "Setting up CocoaPods Master repo"</h1> <p>I'm cloning a project from a git repo, but when I execute <code>pod install</code> the first line I see is "Setting up CocoaPods Master repo" and after that I can't see anything more, the console stops there.</p> <p>I don't know what is happening...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,765
git
# Pod install is staying on "Setting up CocoaPods Master repo" I'm cloning a project from a git repo, but when I execute `pod install` the first line I see is "Setting up CocoaPods Master repo" and after that I can't see anything more, the console stops there. I don't know what is happening. Anyone knows what's happe...
You could try running in verbose mode: ``` pod install --verbose ``` That'll show you what cocoa pods are up to: ``` Setting up CocoaPods master repo Cloning spec repo `master` from `https://github.com/CocoaPods/Specs.git` (branch `master`) $ /usr/bin/git clone 'https://github.com/CocoaPods/Specs.git' master Cl...
14096721
How to add file to a previous commit?
166
2012-12-31 02:13:37
<p>In last hour or so i have modified files </p> <pre><code>A ATest B BTest </code></pre> <p>In order to make sure my commit messages line up with the actual change, committed <code>A</code> with a description. Unfortunately i have not included <code>ATest</code> into that commit.</p> <p>Meanwhile, still not committ...
88,247
359,862
2024-11-13 01:17:40
14,096,741
282
2012-12-31 02:17:58
140,750
2020-03-08 01:12:47
https://stackoverflow.com/q/14096721
https://stackoverflow.com/a/14096741
<p>To add a new file to the previous commit:</p> <pre><code>$ git add new-file $ git commit --amend </code></pre> <p>You can use <code>git commit --amend --no-edit</code> if you don't want to change the commit message.</p>
<p>To add a new file to the previous commit:</p> <pre><code>$ git add new-file $ git commit --amend </code></pre> <p>You can use <code>git commit --amend --no-edit</code> if you don't want to change the commit message.</p>
119
git
<h1>How to add file to a previous commit?</h1> <p>In last hour or so i have modified files </p> <pre><code>A ATest B BTest </code></pre> <p>In order to make sure my commit messages line up with the actual change, committed <code>A</code> with a description. Unfortunately i have not included <code>ATest</code> into th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,768
git
# How to add file to a previous commit? In last hour or so i have modified files ``` A ATest B BTest ``` In order to make sure my commit messages line up with the actual change, committed `A` with a description. Unfortunately i have not included `ATest` into that commit. Meanwhile, still not committed are `B` and `...
To add a new file to the previous commit: ``` $ git add new-file $ git commit --amend ``` You can use `git commit --amend --no-edit` if you don't want to change the commit message.
11050265
Remove large .pack file created by Git
213
2012-06-15 12:02:09
<p>I checked a load of files into a branch and merged. And then I had to remove them and now I'm left with a large <em>.pack</em> file that I don't know how to get rid of.</p> <p>I deleted all the files using <code>git rm -rf xxxxxx</code>, and I also ran the <code>--cached</code> option as well.</p> <p>How can I remov...
252,214
1,116,573
2025-05-18 22:10:39
11,277,929
281
2012-06-30 21:45:51
785,065
2025-05-18 22:08:08
https://stackoverflow.com/q/11050265
https://stackoverflow.com/a/11277929
<p>The issue is that, even though you removed the files, they are still present in previous revisions. That's the whole point of Git, is that even if you delete something, you can still get it back by accessing the history.</p> <p>What you are looking to do is called rewriting history, and it involved the <code>git fil...
<p>The issue is that, even though you removed the files, they are still present in previous revisions. That's the whole point of Git, is that even if you delete something, you can still get it back by accessing the history.</p> <p>What you are looking to do is called rewriting history, and it involved the <code>git fil...
119, 21567, 53847
branching-and-merging, git, pack
<h1>Remove large .pack file created by Git</h1> <p>I checked a load of files into a branch and merged. And then I had to remove them and now I'm left with a large <em>.pack</em> file that I don't know how to get rid of.</p> <p>I deleted all the files using <code>git rm -rf xxxxxx</code>, and I also ran the <code>--cach...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,769
git
# Remove large .pack file created by Git I checked a load of files into a branch and merged. And then I had to remove them and now I'm left with a large *.pack* file that I don't know how to get rid of. I deleted all the files using `git rm -rf xxxxxx`, and I also ran the `--cached` option as well. How can I remove ...
The issue is that, even though you removed the files, they are still present in previous revisions. That's the whole point of Git, is that even if you delete something, you can still get it back by accessing the history. What you are looking to do is called rewriting history, and it involved the `git filter-branch` co...
40462111
Prevent commits in master branch
170
2016-11-07 09:47:42
<p>(For simplicity) I have a <code>master</code> branch and a <code>dev</code> in my Git repository. I want to ensure the <code>master</code> branch is always working, so all work I do should be in the <code>dev</code> branch.</p> <p>However, when I merge my changes in with a <code>--no-ff</code> merge, I tend to stay ...
104,808
6,796,618
2025-04-05 14:21:37
40,465,455
281
2016-11-07 12:40:35
5,508,756
2025-04-05 14:21:37
https://stackoverflow.com/q/40462111
https://stackoverflow.com/a/40465455
<p>Yes, it is possible. You must create a pre-commit hook which rejects commits to the master branch. Git doesn't call a pre-commit hook when you call the <em>merge</em> command, so this hook will be rejecting only regular commits.</p> <ol> <li><p>Go to your repository.</p> </li> <li><p>Create a file, <em>.git/hooks/pr...
<p>Yes, it is possible. You must create a pre-commit hook which rejects commits to the master branch. Git doesn't call a pre-commit hook when you call the <em>merge</em> command, so this hook will be rejecting only regular commits.</p> <ol> <li><p>Go to your repository.</p> </li> <li><p>Create a file, <em>.git/hooks/pr...
119, 717, 52842
fast-forward, git, merge
<h1>Prevent commits in master branch</h1> <p>(For simplicity) I have a <code>master</code> branch and a <code>dev</code> in my Git repository. I want to ensure the <code>master</code> branch is always working, so all work I do should be in the <code>dev</code> branch.</p> <p>However, when I merge my changes in with a <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,770
git
# Prevent commits in master branch (For simplicity) I have a `master` branch and a `dev` in my Git repository. I want to ensure the `master` branch is always working, so all work I do should be in the `dev` branch. However, when I merge my changes in with a `--no-ff` merge, I tend to stay in the `master` branch, and ...
Yes, it is possible. You must create a pre-commit hook which rejects commits to the master branch. Git doesn't call a pre-commit hook when you call the *merge* command, so this hook will be rejecting only regular commits. 1. Go to your repository. 2. Create a file, *.git/hooks/pre-commit*, with the following content: ...
9436405
Why is git is ignoring files that aren't in the .gitignore file?
168
2012-02-24 18:56:07
<p>I have a git repository that is ignoring image files as well as a few other files, but my <code>.gitignore</code> file only has it ignoring a <code>config.php</code> file. Is there some global ignore file somewhere that I can't seem to find? I have to specify files to add them now, and it's giving me this warning:...
72,927
390,977
2022-10-31 09:39:13
28,918,880
281
2015-03-07 19:12:37
55,075
2017-10-21 21:22:28
https://stackoverflow.com/q/9436405
https://stackoverflow.com/a/28918880
<h3><code>git check-ignore</code></h3> <p>Use <a href="https://git-scm.com/docs/git-check-ignore" rel="noreferrer"><code>git check-ignore</code> command</a> to debug your gitignore file (exclude files).</p> <p>For example:</p> <pre><code>$ git check-ignore -v config.php .gitignore:2:src config.php </code></pre> <p>T...
<h3><code>git check-ignore</code></h3> <p>Use <a href="https://git-scm.com/docs/git-check-ignore" rel="noreferrer"><code>git check-ignore</code> command</a> to debug your gitignore file (exclude files).</p> <p>For example:</p> <pre><code>$ git check-ignore -v config.php .gitignore:2:src config.php </code></pre> <p>T...
119, 25056
git, gitignore
<h1>Why is git is ignoring files that aren't in the .gitignore file?</h1> <p>I have a git repository that is ignoring image files as well as a few other files, but my <code>.gitignore</code> file only has it ignoring a <code>config.php</code> file. Is there some global ignore file somewhere that I can't seem to find? ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,771
git
# Why is git is ignoring files that aren't in the .gitignore file? I have a git repository that is ignoring image files as well as a few other files, but my `.gitignore` file only has it ignoring a `config.php` file. Is there some global ignore file somewhere that I can't seem to find? I have to specify files to add t...
### `git check-ignore` Use [`git check-ignore` command](https://git-scm.com/docs/git-check-ignore) to debug your gitignore file (exclude files). For example: ``` $ git check-ignore -v config.php .gitignore:2:src config.php ``` The above output details about the matching pattern (if any) for each given pathname (...
10641361
Get all files that have been modified in git branch
389
2012-05-17 18:22:58
<p>Is there a way to see what files have changed in a branch?</p>
281,575
494,150
2025-11-02 09:00:08
10,641,810
280
2012-05-17 18:53:56
1,253,222
2025-09-09 01:56:23
https://stackoverflow.com/q/10641361
https://stackoverflow.com/a/10641810
<p>An alternative to the answer by @Marco Ponti, and avoiding the checkout:</p> <pre><code>git diff --name-only &lt;notMainDev&gt; $(git merge-base &lt;notMainDev&gt; &lt;mainDev&gt;) </code></pre> <p>If your particular shell doesn't understand the $() construct, use back-ticks instead.</p> <p>For current branch you ca...
<p>An alternative to the answer by @Marco Ponti, and avoiding the checkout:</p> <pre><code>git diff --name-only &lt;notMainDev&gt; $(git merge-base &lt;notMainDev&gt; &lt;mainDev&gt;) </code></pre> <p>If your particular shell doesn't understand the $() construct, use back-ticks instead.</p> <p>For current branch you ca...
119, 1879
branch, git
<h1>Get all files that have been modified in git branch</h1> <p>Is there a way to see what files have changed in a branch?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,773
git
# Get all files that have been modified in git branch Is there a way to see what files have changed in a branch?
An alternative to the answer by @Marco Ponti, and avoiding the checkout: ``` git diff --name-only <notMainDev> $(git merge-base <notMainDev> <mainDev>) ``` If your particular shell doesn't understand the $() construct, use back-ticks instead. For current branch you can use: ``` git diff --name-only $(git merge-base...
2466735
How to sparsely checkout only one single file from a git repository?
610
2010-03-17 23:52:14
<p>How do I checkout just one file from a git repo?</p>
769,894
90,801
2023-10-19 07:48:40
2,467,629
279
2010-03-18 04:58:25
6,309
2023-01-19 23:34:58
https://stackoverflow.com/q/2466735
https://stackoverflow.com/a/2467629
<p>Originally, I mentioned in 2012 <a href="https://git-scm.com/docs/git-archive" rel="noreferrer"><strong><code>git archive</code></strong></a> (see <a href="https://stackoverflow.com/users/290784/jared-forsyth">Jared Forsyth</a>'s <a href="https://stackoverflow.com/a/18712703/6309">answer</a> and <a href="https://sta...
<p>Originally, I mentioned in 2012 <a href="https://git-scm.com/docs/git-archive" rel="noreferrer"><strong><code>git archive</code></strong></a> (see <a href="https://stackoverflow.com/users/290784/jared-forsyth">Jared Forsyth</a>'s <a href="https://stackoverflow.com/a/18712703/6309">answer</a> and <a href="https://sta...
119, 5310, 37230, 50925
file, git, git-checkout, sparse-checkout
<h1>How to sparsely checkout only one single file from a git repository?</h1> <p>How do I checkout just one file from a git repo?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,775
git
# How to sparsely checkout only one single file from a git repository? How do I checkout just one file from a git repo?
Originally, I mentioned in 2012 [**`git archive`**](https://git-scm.com/docs/git-archive) (see [Jared Forsyth](https://stackoverflow.com/users/290784/jared-forsyth)'s [answer](https://stackoverflow.com/a/18712703/6309) and [Robert Knight](https://stackoverflow.com/users/434243/robert-knight)'s [answer](https://stackove...
10176601
'git diff file' against its last change
285
2012-04-16 14:59:54
<p>Is it possible to get Git to produce a diff between a specific file as it exists now, and as it existed before the last commit that changed it?</p> <p>That is, if we know:</p> <pre class="lang-none prettyprint-override"><code>git log --oneline myfile </code></pre> <p>Output:</p> <pre class="lang-none prettyprint-ove...
226,548
93,884
2024-04-29 23:04:14
22,412,252
279
2014-03-14 17:47:49
1,858,225
2021-09-02 16:15:07
https://stackoverflow.com/q/10176601
https://stackoverflow.com/a/22412252
<p>This does exist, but it's actually a feature of <code>git log</code>:</p> <pre><code>git log -p [-m] [--follow] [-1] &lt;path&gt; </code></pre> <p>Note that <code>-p</code> can also be used to show the inline diff from a single commit:</p> <pre><code>git log -p -1 &lt;commit&gt; </code></pre> <p>Options used:</p> <u...
<p>This does exist, but it's actually a feature of <code>git log</code>:</p> <pre><code>git log -p [-m] [--follow] [-1] &lt;path&gt; </code></pre> <p>Note that <code>-p</code> can also be used to show the inline diff from a single commit:</p> <pre><code>git log -p -1 &lt;commit&gt; </code></pre> <p>Options used:</p> <u...
119, 9033
git, git-diff
<h1>'git diff file' against its last change</h1> <p>Is it possible to get Git to produce a diff between a specific file as it exists now, and as it existed before the last commit that changed it?</p> <p>That is, if we know:</p> <pre class="lang-none prettyprint-override"><code>git log --oneline myfile </code></pre> <p>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,776
git
# 'git diff file' against its last change Is it possible to get Git to produce a diff between a specific file as it exists now, and as it existed before the last commit that changed it? That is, if we know: ``` git log --oneline myfile ``` Output: ``` 123abc Fix some stuff 456def Frobble the foos 789dba Initial co...
This does exist, but it's actually a feature of `git log`: ``` git log -p [-m] [--follow] [-1] <path> ``` Note that `-p` can also be used to show the inline diff from a single commit: ``` git log -p -1 <commit> ``` Options used: - `-p` (also `-u` or `--patch`) is hidden deeeeeeeep in the `git-log` man page, and is...
7279196
Git: How to edit/reword a merge commit's message?
229
2011-09-02 04:18:40
<p>How do I edit or reword a merge commit's message?</p> <p><code>git commit --amend</code> works if it's the last commit made (<code>HEAD</code>), but what if it comes before <code>HEAD</code>?</p> <p><code>git rebase -i HEAD~5</code> doesn't list the merge commits.</p>
145,622
242,933
2022-12-08 11:54:20
7,279,322
279
2011-09-02 04:47:46
223,092
2021-06-23 15:34:41
https://stackoverflow.com/q/7279196
https://stackoverflow.com/a/7279322
<p>If you add the <code>--preserve-merges</code> option (or its synonym, <code>-p</code>) to the <code>git rebase -i</code> command then git will try to preserve the merges when rebasing, rather than linearizing the history, and you should be able to amend the merge commits as well:</p> <pre><code>git rebase -i -p HEAD...
<p>If you add the <code>--preserve-merges</code> option (or its synonym, <code>-p</code>) to the <code>git rebase -i</code> command then git will try to preserve the merges when rebasing, rather than linearizing the history, and you should be able to amend the merge commits as well:</p> <pre><code>git rebase -i -p HEAD...
119, 5597, 30968
commit, git, git-amend
<h1>Git: How to edit/reword a merge commit's message?</h1> <p>How do I edit or reword a merge commit's message?</p> <p><code>git commit --amend</code> works if it's the last commit made (<code>HEAD</code>), but what if it comes before <code>HEAD</code>?</p> <p><code>git rebase -i HEAD~5</code> doesn't list the merge ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,777
git
# Git: How to edit/reword a merge commit's message? How do I edit or reword a merge commit's message? `git commit --amend` works if it's the last commit made (`HEAD`), but what if it comes before `HEAD`? `git rebase -i HEAD~5` doesn't list the merge commits.
If you add the `--preserve-merges` option (or its synonym, `-p`) to the `git rebase -i` command then git will try to preserve the merges when rebasing, rather than linearizing the history, and you should be able to amend the merge commits as well: ``` git rebase -i -p HEAD~5 ``` Note. `--perserve-merges` has been dep...
6561142
Difference between "git checkout <filename>" and "git checkout -​- <filename>"
144
2011-07-03 04:45:42
<p><a href="http://norbauer.com/notebooks/code/notes/git-revert-reset-a-single-file" rel="noreferrer">http://norbauer.com/notebooks/code/notes/git-revert-reset-a-single-file</a></p> <p>I have found a post. </p> <p>But still don't know what is the difference between</p> <ol> <li><p><code>git checkout &lt;filename&gt;...
79,269
514,316
2023-01-31 20:33:33
6,561,160
279
2011-07-03 04:51:51
388,520
2016-09-08 13:47:22
https://stackoverflow.com/q/6561142
https://stackoverflow.com/a/6561160
<p>The special "option" <code>--</code> means "treat every argument after this point as a file name, no matter what it looks like." This is not Git-specific, it's a general Unix command line convention. Normally you use it to clarify that an argument is a file name rather than an <em>option</em>, e.g.</p> <pre><code...
<p>The special "option" <code>--</code> means "treat every argument after this point as a file name, no matter what it looks like." This is not Git-specific, it's a general Unix command line convention. Normally you use it to clarify that an argument is a file name rather than an <em>option</em>, e.g.</p> <pre><code...
119
git
<h1>Difference between "git checkout <filename>" and "git checkout -​- <filename>"</h1> <p><a href="http://norbauer.com/notebooks/code/notes/git-revert-reset-a-single-file" rel="noreferrer">http://norbauer.com/notebooks/code/notes/git-revert-reset-a-single-file</a></p> <p>I have found a post. </p> <p>But still don't ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,778
git
# Difference between "git checkout " and "git checkout -​- " <http://norbauer.com/notebooks/code/notes/git-revert-reset-a-single-file> I have found a post. But still don't know what is the difference between 1. `git checkout <filename>` 2. `git checkout -- <filename>` In what situation I should use first one and s...
The special "option" `--` means "treat every argument after this point as a file name, no matter what it looks like." This is not Git-specific, it's a general Unix command line convention. Normally you use it to clarify that an argument is a file name rather than an *option*, e.g. ``` rm -f # does nothing rm -- -...
21045061
git clone from another directory
265
2014-01-10 13:01:39
<p>I am trying to clone repo from another directory.</p> <p>Lets say I have one repo in <code>C:/folder1</code> and <code>C:/folder2</code></p> <p>I want to clone the work in <code>folder1</code> into <code>folder2</code>.</p> <p>What would I type into the command prompt to do this? </p> <p>It seems that often when...
241,894
2,020,869
2025-11-24 02:28:19
21,045,596
278
2014-01-10 13:29:03
354,577
2014-01-10 14:03:49
https://stackoverflow.com/q/21045061
https://stackoverflow.com/a/21045596
<pre><code>cd /d c:\ git clone C:\folder1 folder2 </code></pre> <p>From the <a href="https://www.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS">documentation for <code>git clone</code></a>:</p> <blockquote> <p>For local repositories, also supported by git natively, the following syntaxes may be used:</p>...
<pre><code>cd /d c:\ git clone C:\folder1 folder2 </code></pre> <p>From the <a href="https://www.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS">documentation for <code>git clone</code></a>:</p> <blockquote> <p>For local repositories, also supported by git natively, the following syntaxes may be used:</p>...
119, 34099
git, git-clone
<h1>git clone from another directory</h1> <p>I am trying to clone repo from another directory.</p> <p>Lets say I have one repo in <code>C:/folder1</code> and <code>C:/folder2</code></p> <p>I want to clone the work in <code>folder1</code> into <code>folder2</code>.</p> <p>What would I type into the command prompt to ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,779
git
# git clone from another directory I am trying to clone repo from another directory. Lets say I have one repo in `C:/folder1` and `C:/folder2` I want to clone the work in `folder1` into `folder2`. What would I type into the command prompt to do this? It seems that often when cloning a URL is provided rather then a...
``` cd /d c:\ git clone C:\folder1 folder2 ``` From the [documentation for `git clone`](https://www.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS): > For local repositories, also supported by git natively, the following syntaxes may be used: > > ``` > /path/to/repo.git/ > > file:///path/to/repo.git/ > ``` ...
495345
How to remove selected commit log entries from a Git repository while keeping their changes?
250
2009-01-30 12:23:01
<p>I would like to remove selected commit log entries from a linear commit tree, so that the entries do not show in the commit log.</p> <p>My commit tree looks something like:</p> <pre><code>R--A--B--C--D--E--HEAD </code></pre> <p>I would like to remove the B and C entries so that they do not show in the commit log,...
224,701
29,096
2019-10-15 22:45:59
495,352
278
2009-01-30 12:26:03
4,279
2012-02-28 12:54:24
https://stackoverflow.com/q/495345
https://stackoverflow.com/a/495352
<p><a href="http://schacon.github.com/git/git-rebase.html" rel="noreferrer">git-rebase(1)</a> does exactly that. </p> <pre><code>$ git rebase -i HEAD~5 </code></pre> <p><a href="http://web.archive.org/web/20100213104931/http://blog.madism.org/index.php/2007/09/09/138-git-awsome-ness-git-rebase-interactive" rel="noref...
<p><a href="http://schacon.github.com/git/git-rebase.html" rel="noreferrer">git-rebase(1)</a> does exactly that. </p> <pre><code>$ git rebase -i HEAD~5 </code></pre> <p><a href="http://web.archive.org/web/20100213104931/http://blog.madism.org/index.php/2007/09/09/138-git-awsome-ness-git-rebase-interactive" rel="noref...
119, 5597
commit, git
<h1>How to remove selected commit log entries from a Git repository while keeping their changes?</h1> <p>I would like to remove selected commit log entries from a linear commit tree, so that the entries do not show in the commit log.</p> <p>My commit tree looks something like:</p> <pre><code>R--A--B--C--D--E--HEAD </...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,780
git
# How to remove selected commit log entries from a Git repository while keeping their changes? I would like to remove selected commit log entries from a linear commit tree, so that the entries do not show in the commit log. My commit tree looks something like: ``` R--A--B--C--D--E--HEAD ``` I would like to remove t...
[git-rebase(1)](http://schacon.github.com/git/git-rebase.html) does exactly that. ``` $ git rebase -i HEAD~5 ``` [git awsome-ness [git rebase --interactive]](http://web.archive.org/web/20100213104931/http://blog.madism.org/index.php/2007/09/09/138-git-awsome-ness-git-rebase-interactive) contains an example. 1. Don't...
16683121
git diff between two different files
308
2013-05-22 03:43:48
<p>In <code>HEAD</code> (the latest commit), I have a file named <code>foo</code>. In my current working tree, I renamed it to <code>bar</code>, and also edited it.</p> <p>I want to <code>git diff</code> between <code>foo</code> in <code>HEAD</code>, and <code>bar</code> in my current working tree.</p>
344,956
999,400
2024-06-01 06:27:37
16,683,184
277
2013-05-22 03:52:48
471,321
2024-01-16 10:51:41
https://stackoverflow.com/q/16683121
https://stackoverflow.com/a/16683184
<p>Specify the paths explicitly:</p> <p><code>git diff HEAD:full/path/to/foo full/path/to/bar</code></p> <p>Check out the <code>--find-renames</code> option in the <code>git-diff</code> <a href="https://www.kernel.org/pub/software/scm/git/docs/git-diff.html" rel="noreferrer">docs</a>.</p> <p>Credit: <a href="https://st...
<p>Specify the paths explicitly:</p> <p><code>git diff HEAD:full/path/to/foo full/path/to/bar</code></p> <p>Check out the <code>--find-renames</code> option in the <code>git-diff</code> <a href="https://www.kernel.org/pub/software/scm/git/docs/git-diff.html" rel="noreferrer">docs</a>.</p> <p>Credit: <a href="https://st...
119, 606
diff, git
<h1>git diff between two different files</h1> <p>In <code>HEAD</code> (the latest commit), I have a file named <code>foo</code>. In my current working tree, I renamed it to <code>bar</code>, and also edited it.</p> <p>I want to <code>git diff</code> between <code>foo</code> in <code>HEAD</code>, and <code>bar</code> in...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,781
git
# git diff between two different files In `HEAD` (the latest commit), I have a file named `foo`. In my current working tree, I renamed it to `bar`, and also edited it. I want to `git diff` between `foo` in `HEAD`, and `bar` in my current working tree.
Specify the paths explicitly: `git diff HEAD:full/path/to/foo full/path/to/bar` Check out the `--find-renames` option in the `git-diff` [docs](https://www.kernel.org/pub/software/scm/git/docs/git-diff.html). Credit: [twaggs](https://stackoverflow.com/questions/8131135/git-how-to-diff-two-different-files-in-different...
18939421
What should Xcode 6 gitignore file include?
226
2013-09-22 01:27:28
<p>What should the typical <code>.gitignore</code> include for Xcode 6?</p> <p>Also for information regarding the <code>xccheckout</code> introduced in Xcode 5 see <a href="https://stackoverflow.com/q/18340453/2158465">here</a></p>
75,320
2,158,465
2015-07-24 14:57:53
18,939,465
277
2013-09-22 01:40:04
981,049
2014-05-08 05:24:58
https://stackoverflow.com/q/18939421
https://stackoverflow.com/a/18939465
<p>1)</p> <p>The easiest answer is that mine looks like this:</p> <pre><code># Xcode .DS_Store build/ *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 *.xcworkspace !default.xcworkspace xcuserdata profile *.moved-aside DerivedData .idea/ # Pods - ...
<p>1)</p> <p>The easiest answer is that mine looks like this:</p> <pre><code># Xcode .DS_Store build/ *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 *.xcworkspace !default.xcworkspace xcuserdata profile *.moved-aside DerivedData .idea/ # Pods - ...
119, 154, 908, 58338
git, ios, iphone, xcode
<h1>What should Xcode 6 gitignore file include?</h1> <p>What should the typical <code>.gitignore</code> include for Xcode 6?</p> <p>Also for information regarding the <code>xccheckout</code> introduced in Xcode 5 see <a href="https://stackoverflow.com/q/18340453/2158465">here</a></p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,782
git
# What should Xcode 6 gitignore file include? What should the typical `.gitignore` include for Xcode 6? Also for information regarding the `xccheckout` introduced in Xcode 5 see [here](https://stackoverflow.com/q/18340453/2158465)
1) The easiest answer is that mine looks like this: ``` # Xcode .DS_Store build/ *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 *.xcworkspace !default.xcworkspace xcuserdata profile *.moved-aside DerivedData .idea/ # Pods - for those of you who ...
17096311
Why do I need to explicitly push a new branch?
208
2013-06-13 20:21:31
<p>I am new in <code>git</code> and I am practicing. I created a local branch but I saw that when I did <code>git push</code> my branch was not uploaded to the repository. I had to actually do: <code>git push -u origin --all</code>.<br> Why is this? Isn't a branch a new change to be pushed by default? Why do I need to ...
218,321
384,706
2022-07-12 11:31:14
17,096,880
277
2013-06-13 20:52:44
6,309
2022-07-12 11:31:14
https://stackoverflow.com/q/17096311
https://stackoverflow.com/a/17096880
<p>The actual reason is that, in a new repo (git init), there <strong>is no branch</strong> (no <code>master</code>, no branch at all, zero branches)</p> <p>So when you are pushing for the first time to an <em>empty</em> <a href="https://stackoverflow.com/a/2749166/6309">upstream repo</a> (generally a <a href="http://w...
<p>The actual reason is that, in a new repo (git init), there <strong>is no branch</strong> (no <code>master</code>, no branch at all, zero branches)</p> <p>So when you are pushing for the first time to an <em>empty</em> <a href="https://stackoverflow.com/a/2749166/6309">upstream repo</a> (generally a <a href="http://w...
119, 456
git, version-control
<h1>Why do I need to explicitly push a new branch?</h1> <p>I am new in <code>git</code> and I am practicing. I created a local branch but I saw that when I did <code>git push</code> my branch was not uploaded to the repository. I had to actually do: <code>git push -u origin --all</code>.<br> Why is this? Isn't a branch...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,783
git
# Why do I need to explicitly push a new branch? I am new in `git` and I am practicing. I created a local branch but I saw that when I did `git push` my branch was not uploaded to the repository. I had to actually do: `git push -u origin --all`. Why is this? Isn't a branch a new change to be pushed by default? Why d...
The actual reason is that, in a new repo (git init), there **is no branch** (no `master`, no branch at all, zero branches) So when you are pushing for the first time to an *empty* [upstream repo](https://stackoverflow.com/a/2749166/6309) (generally a [bare one](http://web.archive.org/web/20130820233326/http://gitolite...
11950037
View git history for folder
217
2012-08-14 10:07:58
<p>How can I view git log history for all files within a folder ?</p> <p>I have found several posts on how to show log for a specific file, but haven't found for a specific folder.</p>
129,259
923,004
2023-10-25 08:37:33
11,950,203
276
2012-08-14 10:18:38
112,968
2023-10-25 08:37:33
https://stackoverflow.com/q/11950037
https://stackoverflow.com/a/11950203
<p>You can use <code>foldername</code> or <code>'foldername/*'</code>.</p> <pre><code>git log -- path/to/folder git log -- 'path/to/folder/*' </code></pre> <p>History of renamed files will not be followed with this method.</p> <p>Please note that <code>--</code> is optional as well. From <a href="https://git-scm.com/do...
<p>You can use <code>foldername</code> or <code>'foldername/*'</code>.</p> <pre><code>git log -- path/to/folder git log -- 'path/to/folder/*' </code></pre> <p>History of renamed files will not be followed with this method.</p> <p>Please note that <code>--</code> is optional as well. From <a href="https://git-scm.com/do...
119
git
<h1>View git history for folder</h1> <p>How can I view git log history for all files within a folder ?</p> <p>I have found several posts on how to show log for a specific file, but haven't found for a specific folder.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,784
git
# View git history for folder How can I view git log history for all files within a folder ? I have found several posts on how to show log for a specific file, but haven't found for a specific folder.
You can use `foldername` or `'foldername/*'`. ``` git log -- path/to/folder git log -- 'path/to/folder/*' ``` History of renamed files will not be followed with this method. Please note that `--` is optional as well. From [`git help log`](https://git-scm.com/docs/git-log): ``` [--] <path>... Show only c...
12420924
Stash just a single file
591
2012-09-14 08:42:12
<p>I'd like to be able to stash just the changes from a single file:</p> <pre><code>git stash save -- just_my_file.txt </code></pre> <p>The above doesn't work though. Any alternatives?</p>
462,324
6,691
2023-12-06 18:26:55
12,425,360
275
2012-09-14 13:15:28
473,770
2022-03-07 04:56:03
https://stackoverflow.com/q/12420924
https://stackoverflow.com/a/12425360
<p>I think <code>stash -p</code> is probably the choice you want, but just in case you run into other even more tricky things in the future, remember that:</p> <p><code>Stash</code> is really just a very simple alternative to the only slightly more complex <code>branch</code> sets. Stash is very useful for moving thin...
<p>I think <code>stash -p</code> is probably the choice you want, but just in case you run into other even more tricky things in the future, remember that:</p> <p><code>Stash</code> is really just a very simple alternative to the only slightly more complex <code>branch</code> sets. Stash is very useful for moving thin...
119, 13091
git, git-stash
<h1>Stash just a single file</h1> <p>I'd like to be able to stash just the changes from a single file:</p> <pre><code>git stash save -- just_my_file.txt </code></pre> <p>The above doesn't work though. Any alternatives?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,786
git
# Stash just a single file I'd like to be able to stash just the changes from a single file: ``` git stash save -- just_my_file.txt ``` The above doesn't work though. Any alternatives?
I think `stash -p` is probably the choice you want, but just in case you run into other even more tricky things in the future, remember that: `Stash` is really just a very simple alternative to the only slightly more complex `branch` sets. Stash is very useful for moving things around quickly, but you can accomplish m...
3895453
How do I make a Git commit in the past?
489
2010-10-09 02:28:33
<p>I'm converting everything over to Git for my own personal use and I found some old versions of a file already in the repository. How do I commit it to the history in the correct order according the file's &quot;date modified&quot; so I have an accurate history of the file?</p> <p>I was told something like this woul...
303,983
227,259
2024-06-21 09:44:55
3,898,842
275
2010-10-10 03:03:08
193,688
2015-09-18 18:24:18
https://stackoverflow.com/q/3895453
https://stackoverflow.com/a/3898842
<p>The advice you were given is flawed. Unconditionally setting GIT_AUTHOR_DATE in an <code>--env-filter</code> would rewrite the date of every commit. Also, it would be unusual to use <em>git commit</em> inside <code>--index-filter</code>.</p> <p>You are dealing with multiple, independent problems here.</p> <h1>Spec...
<p>The advice you were given is flawed. Unconditionally setting GIT_AUTHOR_DATE in an <code>--env-filter</code> would rewrite the date of every commit. Also, it would be unusual to use <em>git commit</em> inside <code>--index-filter</code>.</p> <p>You are dealing with multiple, independent problems here.</p> <h1>Spec...
119, 456, 7330, 53850
git, git-commit, repository, version-control
<h1>How do I make a Git commit in the past?</h1> <p>I'm converting everything over to Git for my own personal use and I found some old versions of a file already in the repository. How do I commit it to the history in the correct order according the file's &quot;date modified&quot; so I have an accurate history of the...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,787
git
# How do I make a Git commit in the past? I'm converting everything over to Git for my own personal use and I found some old versions of a file already in the repository. How do I commit it to the history in the correct order according the file's "date modified" so I have an accurate history of the file? I was told s...
The advice you were given is flawed. Unconditionally setting GIT_AUTHOR_DATE in an `--env-filter` would rewrite the date of every commit. Also, it would be unusual to use *git commit* inside `--index-filter`. You are dealing with multiple, independent problems here. # Specifying Dates Other Than “now” Each commit ha...
1535524
Git submodule inside of a submodule (nested submodules)
181
2009-10-08 03:46:38
<p>Is it possible for a git submodule to be made of several other git submodules, and the super git repo to fetch the contents for each submodule?</p> <p>I have tried to do this using the obvious/naive approach of creating a git repo holding several submodules.</p> <p>Then adding this git repo to another git repo as ...
82,919
26,088
2017-08-30 15:11:45
6,562,038
275
2011-07-03 09:13:17
666,371
2011-07-03 09:53:32
https://stackoverflow.com/q/1535524
https://stackoverflow.com/a/6562038
<p>As mentioned in <a href="https://stackoverflow.com/questions/4251940/retrospectively-add-recursive-to-a-git-repo/4261001">Retrospectively add --recursive to a git repo</a></p> <pre><code>git submodule update --init --recursive </code></pre> <p>should work.</p>
<p>As mentioned in <a href="https://stackoverflow.com/questions/4251940/retrospectively-add-recursive-to-a-git-repo/4261001">Retrospectively add --recursive to a git repo</a></p> <pre><code>git submodule update --init --recursive </code></pre> <p>should work.</p>
119, 41612
git, git-submodules
<h1>Git submodule inside of a submodule (nested submodules)</h1> <p>Is it possible for a git submodule to be made of several other git submodules, and the super git repo to fetch the contents for each submodule?</p> <p>I have tried to do this using the obvious/naive approach of creating a git repo holding several subm...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,788
git
# Git submodule inside of a submodule (nested submodules) Is it possible for a git submodule to be made of several other git submodules, and the super git repo to fetch the contents for each submodule? I have tried to do this using the obvious/naive approach of creating a git repo holding several submodules. Then ad...
As mentioned in [Retrospectively add --recursive to a git repo](https://stackoverflow.com/questions/4251940/retrospectively-add-recursive-to-a-git-repo/4261001) ``` git submodule update --init --recursive ``` should work.
10906554
How do I revert my changes to a git submodule?
483
2012-06-05 23:52:44
<p>I have a git submodule (RestKit) which I have added to my repo.</p> <p>I accidentally changed some files in there and I'd like to go back to the source version. In order to do that, I tried to run </p> <pre><code>Mac:app-ios user$ git submodule update RestKit </code></pre> <p>But as you can see here, this did not...
421,133
1,098,873
2024-09-18 12:36:09
10,906,596
274
2012-06-05 23:57:20
68,230
2012-06-05 23:57:20
https://stackoverflow.com/q/10906554
https://stackoverflow.com/a/10906596
<p>Move into the submodule's directory, then do a <code>git reset --hard</code> to reset all modified files to their last committed state. Be aware that this will discard all non-committed changes.</p>
<p>Move into the submodule's directory, then do a <code>git reset --hard</code> to reset all modified files to their last committed state. Be aware that this will discard all non-committed changes.</p>
119, 41612
git, git-submodules
<h1>How do I revert my changes to a git submodule?</h1> <p>I have a git submodule (RestKit) which I have added to my repo.</p> <p>I accidentally changed some files in there and I'd like to go back to the source version. In order to do that, I tried to run </p> <pre><code>Mac:app-ios user$ git submodule update RestKit...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,789
git
# How do I revert my changes to a git submodule? I have a git submodule (RestKit) which I have added to my repo. I accidentally changed some files in there and I'd like to go back to the source version. In order to do that, I tried to run ``` Mac:app-ios user$ git submodule update RestKit ``` But as you can see her...
Move into the submodule's directory, then do a `git reset --hard` to reset all modified files to their last committed state. Be aware that this will discard all non-committed changes.
15479609
git commit --amend without asking for message
141
2013-03-18 14:44:29
<p>From time to time I find myself <em>commit-amending</em> using the same message.</p> <p>Typically, I do:</p> <ol> <li>Add my changes to staging area.</li> <li>Do <code>git commit --amend</code>.</li> <li>Wait for the text editor to open.</li> <li>Save and close it (without changing the message).</li> </ol> <p>The...
33,972
1,316,620
2015-02-20 18:42:15
15,479,726
274
2013-03-18 14:49:46
845,716
2013-03-18 14:49:46
https://stackoverflow.com/q/15479609
https://stackoverflow.com/a/15479726
<p>Try <code>git commit --amend --no-edit</code>.</p>
<p>Try <code>git commit --amend --no-edit</code>.</p>
119, 30968, 53850
git, git-amend, git-commit
<h1>git commit --amend without asking for message</h1> <p>From time to time I find myself <em>commit-amending</em> using the same message.</p> <p>Typically, I do:</p> <ol> <li>Add my changes to staging area.</li> <li>Do <code>git commit --amend</code>.</li> <li>Wait for the text editor to open.</li> <li>Save and clos...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,791
git
# git commit --amend without asking for message From time to time I find myself *commit-amending* using the same message. Typically, I do: 1. Add my changes to staging area. 2. Do `git commit --amend`. 3. Wait for the text editor to open. 4. Save and close it (without changing the message). There is anyway to tell ...
Try `git commit --amend --no-edit`.
12641469
List submodules in a Git repository
384
2012-09-28 13:58:38
<p>I have a Git repository that has several submodules in it. How do I list the names of all the submodules after <code>git submodule init</code> has been run?</p> <p>The <code>git submodule foreach</code> command could echo the names of the submodule, but that only works once they have been checked out which has not ...
439,547
1,082,851
2024-09-30 11:08:12
12,641,787
273
2012-09-28 14:16:46
20,261
2018-08-21 10:38:56
https://stackoverflow.com/q/12641469
https://stackoverflow.com/a/12641787
<p>You could use the same mechanism as <code>git submodule init</code> uses itself, namely, look at <code>.gitmodules</code>. This files enumerates each submodule path and the URL it refers to.</p> <p>For example, from root of repository, <code>cat .gitmodules</code> will print contents to the screen (assuming you hav...
<p>You could use the same mechanism as <code>git submodule init</code> uses itself, namely, look at <code>.gitmodules</code>. This files enumerates each submodule path and the URL it refers to.</p> <p>For example, from root of repository, <code>cat .gitmodules</code> will print contents to the screen (assuming you hav...
119, 41612
git, git-submodules
<h1>List submodules in a Git repository</h1> <p>I have a Git repository that has several submodules in it. How do I list the names of all the submodules after <code>git submodule init</code> has been run?</p> <p>The <code>git submodule foreach</code> command could echo the names of the submodule, but that only works o...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,792
git
# List submodules in a Git repository I have a Git repository that has several submodules in it. How do I list the names of all the submodules after `git submodule init` has been run? The `git submodule foreach` command could echo the names of the submodule, but that only works once they have been checked out which h...
You could use the same mechanism as `git submodule init` uses itself, namely, look at `.gitmodules`. This files enumerates each submodule path and the URL it refers to. For example, from root of repository, `cat .gitmodules` will print contents to the screen (assuming you have `cat`). Because .gitmodule files have th...
9512549
How to fast-forward a branch to head
328
2012-03-01 07:58:11
<p>I switched to <em>master</em> after developing on a branch for a long time. The log shows:</p> <blockquote> <p>Your branch is behind 'origin/master' by 167 commits, and can be fast-forwarded.</p> </blockquote> <p>I tried:</p> <pre><code>git checkout HEAD </code></pre> <p>It doesn't have any effect. This is because I...
423,771
721,441
2024-02-28 16:42:20
9,512,578
272
2012-03-01 08:00:39
893
2012-03-01 08:00:39
https://stackoverflow.com/q/9512549
https://stackoverflow.com/a/9512578
<p>Doing:</p> <pre><code>git checkout master git pull origin </code></pre> <p>will fetch and merge the <code>origin/master</code> branch (you may just say <code>git pull</code> as origin is the default).</p>
<p>Doing:</p> <pre><code>git checkout master git pull origin </code></pre> <p>will fetch and merge the <code>origin/master</code> branch (you may just say <code>git pull</code> as origin is the default).</p>
119
git
<h1>How to fast-forward a branch to head</h1> <p>I switched to <em>master</em> after developing on a branch for a long time. The log shows:</p> <blockquote> <p>Your branch is behind 'origin/master' by 167 commits, and can be fast-forwarded.</p> </blockquote> <p>I tried:</p> <pre><code>git checkout HEAD </code></pre> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,793
git
# How to fast-forward a branch to head I switched to *master* after developing on a branch for a long time. The log shows: > Your branch is behind 'origin/master' by 167 commits, and can be fast-forwarded. I tried: ``` git checkout HEAD ``` It doesn't have any effect. This is because I have checked out an intermed...
Doing: ``` git checkout master git pull origin ``` will fetch and merge the `origin/master` branch (you may just say `git pull` as origin is the default).
6468893
stash@{1} is ambiguous?
142
2011-06-24 14:02:44
<p>I'm trying to get info about my stash, but git is telling me that <code>stash@{0}</code> and <code>stash@{1}</code> are ambiguous. <code>git stash list</code> works fine, and <code>.git/logs/refs/stash</code> seems to have the appropriate content (not that I'm an expert on git internals).</p> <pre><code>% git stash...
29,463
310,159
2023-10-07 11:14:16
6,468,931
272
2011-06-24 14:06:13
201,725
2023-10-07 08:30:16
https://stackoverflow.com/q/6468893
https://stackoverflow.com/a/6468931
<p>Your shell is eating your curly brackets, so while you say <code>stash@{1}</code>, git sees <code>stash@1</code>, and that makes no sense to it. Quote the argument (use <code>git stash apply &quot;stash@{1}&quot;</code> or <code>git stash apply stash@&quot;{1}&quot;</code>; quoting either way will work) or reconfigu...
<p>Your shell is eating your curly brackets, so while you say <code>stash@{1}</code>, git sees <code>stash@1</code>, and that makes no sense to it. Quote the argument (use <code>git stash apply &quot;stash@{1}&quot;</code> or <code>git stash apply stash@&quot;{1}&quot;</code>; quoting either way will work) or reconfigu...
119
git
<h1>stash@{1} is ambiguous?</h1> <p>I'm trying to get info about my stash, but git is telling me that <code>stash@{0}</code> and <code>stash@{1}</code> are ambiguous. <code>git stash list</code> works fine, and <code>.git/logs/refs/stash</code> seems to have the appropriate content (not that I'm an expert on git intern...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,795
git
# stash@{1} is ambiguous? I'm trying to get info about my stash, but git is telling me that `stash@{0}` and `stash@{1}` are ambiguous. `git stash list` works fine, and `.git/logs/refs/stash` seems to have the appropriate content (not that I'm an expert on git internals). ``` % git stash list stash@{0}: On master: two...
Your shell is eating your curly brackets, so while you say `stash@{1}`, git sees `stash@1`, and that makes no sense to it. Quote the argument (use `git stash apply "stash@{1}"` or `git stash apply stash@"{1}"`; quoting either way will work) or reconfigure your shell to only expand curly brackets when there is a comma b...
20045946
Applying the changes from branch A to B, without merging or adding commits
161
2013-11-18 10:52:02
<p>My scenario is that I have one branch in which I've made big improvements to the build process (branch A) and in another I'm working on a unrelated feature (branch B). So now when I'm hacking away at branch B, I want to pull in the stuff I wrote in branch A because I want faster and easier builds. However, I don't w...
72,949
189,247
2026-01-05 18:48:16
41,772,786
271
2017-01-20 21:41:10
307,819
2026-01-05 18:48:16
https://stackoverflow.com/q/20045946
https://stackoverflow.com/a/41772786
<p>I just had to do something similar and was able to fix it by adding <code>--squash</code> to the merge command</p> <pre class="lang-bash prettyprint-override"><code>git merge --no-commit --squash branchA git reset HEAD # to unstage the changes </code></pre> <hr /> <p>Details:</p> <blockquote> <p><code>--no-commit</...
<p>I just had to do something similar and was able to fix it by adding <code>--squash</code> to the merge command</p> <pre class="lang-bash prettyprint-override"><code>git merge --no-commit --squash branchA git reset HEAD # to unstage the changes </code></pre> <hr /> <p>Details:</p> <blockquote> <p><code>--no-commit</...
119, 717, 1879
branch, git, merge
<h1>Applying the changes from branch A to B, without merging or adding commits</h1> <p>My scenario is that I have one branch in which I've made big improvements to the build process (branch A) and in another I'm working on a unrelated feature (branch B). So now when I'm hacking away at branch B, I want to pull in the s...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,797
git
# Applying the changes from branch A to B, without merging or adding commits My scenario is that I have one branch in which I've made big improvements to the build process (branch A) and in another I'm working on a unrelated feature (branch B). So now when I'm hacking away at branch B, I want to pull in the stuff I wr...
I just had to do something similar and was able to fix it by adding `--squash` to the merge command ``` git merge --no-commit --squash branchA git reset HEAD # to unstage the changes ``` --- Details: > `--no-commit`: Perform the merge and **stop just before creating a merge commit**, to give the user a chance to in...
653454
How do you make Git ignore files without using .gitignore?
262
2009-03-17 09:00:13
<p>Due to external weird constraints I cannot modify the <code>.gitignore</code> of my repository. Is there a way to ignore files and directories other than modifying a <code>.gitignore</code>? Even if it is a global solution like a global configuration that will be applied to all my repositories.</p>
111,883
6,068
2024-05-09 10:09:51
653,495
269
2009-03-17 09:21:06
6,309
2016-02-26 11:34:34
https://stackoverflow.com/q/653454
https://stackoverflow.com/a/653495
<p>Do not forget, according to <a href="http://git-scm.com/docs/gitignore" rel="noreferrer">gitignore</a>, that there is an order of precedence in the different "ignore pattern sources" that Git consider:</p> <ul> <li>Patterns read from the command line for those commands that support them.</li> <li>Patterns read from...
<p>Do not forget, according to <a href="http://git-scm.com/docs/gitignore" rel="noreferrer">gitignore</a>, that there is an order of precedence in the different "ignore pattern sources" that Git consider:</p> <ul> <li>Patterns read from the command line for those commands that support them.</li> <li>Patterns read from...
119, 456
git, version-control
<h1>How do you make Git ignore files without using .gitignore?</h1> <p>Due to external weird constraints I cannot modify the <code>.gitignore</code> of my repository. Is there a way to ignore files and directories other than modifying a <code>.gitignore</code>? Even if it is a global solution like a global configuratio...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,798
git
# How do you make Git ignore files without using .gitignore? Due to external weird constraints I cannot modify the `.gitignore` of my repository. Is there a way to ignore files and directories other than modifying a `.gitignore`? Even if it is a global solution like a global configuration that will be applied to all m...
Do not forget, according to [gitignore](http://git-scm.com/docs/gitignore), that there is an order of precedence in the different "ignore pattern sources" that Git consider: - Patterns read from the command line for those commands that support them. - Patterns read from a .gitignore file in the same directory as the p...
31769820
Differences between git submodule and subtree
443
2015-08-02 08:05:45
<p>What are the conceptual differences between using git submodule and subtree?</p> <p>What are the typical scenarios for each?</p>
158,325
25,645
2024-02-27 06:30:00
31,770,147
268
2015-08-02 08:49:17
6,309
2021-07-12 17:10:18
https://stackoverflow.com/q/31769820
https://stackoverflow.com/a/31770147
<ul> <li><strong>submodule</strong> is a better fit for <a href="https://stackoverflow.com/a/933735/6309">component-based development</a>, where your main project depends on a fixed version of another component (repo).<br /> You keep only references in your parent repo (<strong><a href="https://stackoverflow.com/a/1658...
<ul> <li><strong>submodule</strong> is a better fit for <a href="https://stackoverflow.com/a/933735/6309">component-based development</a>, where your main project depends on a fixed version of another component (repo).<br /> You keep only references in your parent repo (<strong><a href="https://stackoverflow.com/a/1658...
119, 41612, 68200
git, git-submodules, git-subtree
<h1>Differences between git submodule and subtree</h1> <p>What are the conceptual differences between using git submodule and subtree?</p> <p>What are the typical scenarios for each?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,802
git
# Differences between git submodule and subtree What are the conceptual differences between using git submodule and subtree? What are the typical scenarios for each?
- **submodule** is a better fit for [component-based development](https://stackoverflow.com/a/933735/6309), where your main project depends on a fixed version of another component (repo). You keep only references in your parent repo (**[gitlinks](https://stackoverflow.com/a/16581096/6309)**, [special entries in the...
715321
Git status - is there a way to show changes only in a specific directory?
191
2009-04-03 19:24:25
<p>I would like to see a list of files modified since the last commit, as <code>git status</code> shows, but I care only about files located in a single directory. Is there a way to do this? I tried <code>git status &lt;directory&gt;</code>, but it seems this does something completely different (lists all changed files...
140,762
78,255
2026-01-06 16:53:30
13,881,723
268
2012-12-14 15:36:22
539,681
2016-03-02 08:01:39
https://stackoverflow.com/q/715321
https://stackoverflow.com/a/13881723
<p>From within the directory:</p> <pre><code>git status . </code></pre> <hr> <p>You can use any path really, use this syntax:</p> <pre><code>git status &lt;directoryPath&gt; </code></pre> <p>For instance for directory with path "my/cool/path/here"</p> <pre><code>git status my/cool/path/here </code></pre>
<p>From within the directory:</p> <pre><code>git status . </code></pre> <hr> <p>You can use any path really, use this syntax:</p> <pre><code>git status &lt;directoryPath&gt; </code></pre> <p>For instance for directory with path "my/cool/path/here"</p> <pre><code>git status my/cool/path/here </code></pre>
119, 218, 6951
directory, git, status
<h1>Git status - is there a way to show changes only in a specific directory?</h1> <p>I would like to see a list of files modified since the last commit, as <code>git status</code> shows, but I care only about files located in a single directory. Is there a way to do this? I tried <code>git status &lt;directory&gt;</co...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,803
git
# Git status - is there a way to show changes only in a specific directory? I would like to see a list of files modified since the last commit, as `git status` shows, but I care only about files located in a single directory. Is there a way to do this? I tried `git status <directory>`, but it seems this does something...
From within the directory: ``` git status . ``` --- You can use any path really, use this syntax: ``` git status <directoryPath> ``` For instance for directory with path "my/cool/path/here" ``` git status my/cool/path/here ```
39963695
How to remove git hooks
166
2016-10-10 17:30:50
<p>I had set up a git hook in pre-commit file to run <code>git pull</code> before any commit. Now I have deleted that file and restarted my computer multiple times, but that hook is still running before my commits. </p> <p>How can I remove or disable that completely?</p>
175,249
6,006,686
2024-04-24 10:00:59
40,148,602
268
2016-10-20 07:55:58
6,006,686
2022-04-13 11:02:05
https://stackoverflow.com/q/39963695
https://stackoverflow.com/a/40148602
<p>I figured out what was causing that:<br /> I had created my <code>pre-commit</code> hook in git core directory, but the git had created a pre-commit hook in project's <code>.git/hooks/</code> directory. I just removed it.</p> <p>It means running the command that @romin21 mentioned inside project's root directory:</p...
<p>I figured out what was causing that:<br /> I had created my <code>pre-commit</code> hook in git core directory, but the git had created a pre-commit hook in project's <code>.git/hooks/</code> directory. I just removed it.</p> <p>It means running the command that @romin21 mentioned inside project's root directory:</p...
119, 43087
git, githooks
<h1>How to remove git hooks</h1> <p>I had set up a git hook in pre-commit file to run <code>git pull</code> before any commit. Now I have deleted that file and restarted my computer multiple times, but that hook is still running before my commits. </p> <p>How can I remove or disable that completely?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,804
git
# How to remove git hooks I had set up a git hook in pre-commit file to run `git pull` before any commit. Now I have deleted that file and restarted my computer multiple times, but that hook is still running before my commits. How can I remove or disable that completely?
I figured out what was causing that: I had created my `pre-commit` hook in git core directory, but the git had created a pre-commit hook in project's `.git/hooks/` directory. I just removed it. It means running the command that @romin21 mentioned inside project's root directory: ``` rm -rf .git/hooks ```
8123674
How to git commit nothing without an error?
161
2011-11-14 15:13:49
<p>I'm trying to write a script that does a <code>git commit</code>; however, if there is nothing to commit, git exits with a status of <code>1</code>. The deploy script takes that as unsuccessful, and quits. How can I allow empty-commit failures to be ignored so that the script can continue, but still catch errors cau...
62,464
418,413
2023-11-04 15:45:16
8,123,841
268
2011-11-14 15:27:20
5,422
2022-12-21 13:08:03
https://stackoverflow.com/q/8123674
https://stackoverflow.com/a/8123841
<p>Catch this condition beforehand by checking the exit code of <code>git diff-index</code>?</p> <p>For example (in shell):</p> <pre><code>git add -A git diff-index --quiet HEAD || git commit -m 'bla' </code></pre> <p><em>EDIT: Fixed <code>git diff</code> command according to Holger's comment.</em></p>
<p>Catch this condition beforehand by checking the exit code of <code>git diff-index</code>?</p> <p>For example (in shell):</p> <pre><code>git add -A git diff-index --quiet HEAD || git commit -m 'bla' </code></pre> <p><em>EDIT: Fixed <code>git diff</code> command according to Holger's comment.</em></p>
119
git
<h1>How to git commit nothing without an error?</h1> <p>I'm trying to write a script that does a <code>git commit</code>; however, if there is nothing to commit, git exits with a status of <code>1</code>. The deploy script takes that as unsuccessful, and quits. How can I allow empty-commit failures to be ignored so tha...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,805
git
# How to git commit nothing without an error? I'm trying to write a script that does a `git commit`; however, if there is nothing to commit, git exits with a status of `1`. The deploy script takes that as unsuccessful, and quits. How can I allow empty-commit failures to be ignored so that the script can continue, but ...
Catch this condition beforehand by checking the exit code of `git diff-index`? For example (in shell): ``` git add -A git diff-index --quiet HEAD || git commit -m 'bla' ``` *EDIT: Fixed `git diff` command according to Holger's comment.*
29007821
git checkout all the files
181
2015-03-12 10:54:10
<p><strong>How can I get rid of all the changes in all the files of my repository?</strong></p> <p>Say I am in a branch and I did some changes. <code>git status</code> returns a set of files in the "Changes not staged for commit" and I notice I would like to get rid of all of these changes in all the files. How can I ...
256,988
1,983,854
2021-07-27 06:16:26
29,007,884
267
2015-03-12 10:56:52
216,074
2015-03-12 10:56:52
https://stackoverflow.com/q/29007821
https://stackoverflow.com/a/29007884
<p>If you are at the root of your working directory, you can do <code>git checkout -- .</code> to check-out all files in the current HEAD and replace your local files.</p> <p>You can also do <code>git reset --hard</code> to reset your working directory and replace all changes (including the index).</p>
<p>If you are at the root of your working directory, you can do <code>git checkout -- .</code> to check-out all files in the current HEAD and replace your local files.</p> <p>You can also do <code>git reset --hard</code> to reset your working directory and replace all changes (including the index).</p>
119, 37230
git, git-checkout
<h1>git checkout all the files</h1> <p><strong>How can I get rid of all the changes in all the files of my repository?</strong></p> <p>Say I am in a branch and I did some changes. <code>git status</code> returns a set of files in the "Changes not staged for commit" and I notice I would like to get rid of all of these ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,806
git
# git checkout all the files **How can I get rid of all the changes in all the files of my repository?** Say I am in a branch and I did some changes. `git status` returns a set of files in the "Changes not staged for commit" and I notice I would like to get rid of all of these changes in all the files. How can I do t...
If you are at the root of your working directory, you can do `git checkout -- .` to check-out all files in the current HEAD and replace your local files. You can also do `git reset --hard` to reset your working directory and replace all changes (including the index).
18063521
Git stash twice
168
2013-08-05 16:54:40
<p>I had to quickly switch git branches, so I ran <code>git stash</code>, but I had to run it again because one of my files needed editing.</p> <p>So I've run <code>git stash</code> twice, and I'm ready to go back to editing my files. I ran <code>git stash apply</code> but I'm not convinced that all of the files I had...
94,251
227,863
2023-06-20 08:33:43
18,063,664
267
2013-08-05 17:03:39
218,196
2013-08-05 17:03:39
https://stackoverflow.com/q/18063521
https://stackoverflow.com/a/18063664
<p>You can get a list of all stashes with</p> <pre><code>git stash list </code></pre> <p>which will show you something like</p> <pre><code>stash@{0}: WIP on dev: 1f6f8bb Commit message A stash@{1}: WIP on master: 50cf63b Commit message B </code></pre> <p>If you made two stashes, then just call <code>git stash pop</...
<p>You can get a list of all stashes with</p> <pre><code>git stash list </code></pre> <p>which will show you something like</p> <pre><code>stash@{0}: WIP on dev: 1f6f8bb Commit message A stash@{1}: WIP on master: 50cf63b Commit message B </code></pre> <p>If you made two stashes, then just call <code>git stash pop</...
119, 13091
git, git-stash
<h1>Git stash twice</h1> <p>I had to quickly switch git branches, so I ran <code>git stash</code>, but I had to run it again because one of my files needed editing.</p> <p>So I've run <code>git stash</code> twice, and I'm ready to go back to editing my files. I ran <code>git stash apply</code> but I'm not convinced th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,808
git
# Git stash twice I had to quickly switch git branches, so I ran `git stash`, but I had to run it again because one of my files needed editing. So I've run `git stash` twice, and I'm ready to go back to editing my files. I ran `git stash apply` but I'm not convinced that all of the files I had stashed were unstashed....
You can get a list of all stashes with ``` git stash list ``` which will show you something like ``` stash@{0}: WIP on dev: 1f6f8bb Commit message A stash@{1}: WIP on master: 50cf63b Commit message B ``` If you made two stashes, then just call `git stash pop` twice. As opposed to `git stash apply`, `pop` applies an...
10516201
Updating and committing only a file's permissions using git version control
305
2012-05-09 12:34:03
<p>Just turned an <code>some.sh</code> file into an executable (<code>chmod 755 ...</code>), the permissions were updated but not the content. Is there a way to <em>commit</em> the file into git, so that the executable bit will be restored/set on <em>clone</em> / <em>checkout</em> / <em>pull</em> ?</p> <p><strong>Upda...
322,957
366,472
2023-12-14 09:15:46
10,516,406
266
2012-05-09 12:45:31
773,999
2019-06-12 21:07:59
https://stackoverflow.com/q/10516201
https://stackoverflow.com/a/10516406
<p>By default, git will update execute file permissions if you change them. It will not change or track any other permissions.</p> <p>If you don't see any changes when modifying execute permission, you probably have a configuration in git which ignore file mode.</p> <p>Look into your project, in the <code>.git</code>...
<p>By default, git will update execute file permissions if you change them. It will not change or track any other permissions.</p> <p>If you don't see any changes when modifying execute permission, you probably have a configuration in git which ignore file mode.</p> <p>Look into your project, in the <code>.git</code>...
119
git
<h1>Updating and committing only a file's permissions using git version control</h1> <p>Just turned an <code>some.sh</code> file into an executable (<code>chmod 755 ...</code>), the permissions were updated but not the content. Is there a way to <em>commit</em> the file into git, so that the executable bit will be rest...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,809
git
# Updating and committing only a file's permissions using git version control Just turned an `some.sh` file into an executable (`chmod 755 ...`), the permissions were updated but not the content. Is there a way to *commit* the file into git, so that the executable bit will be restored/set on *clone* / *checkout* / *pu...
By default, git will update execute file permissions if you change them. It will not change or track any other permissions. If you don't see any changes when modifying execute permission, you probably have a configuration in git which ignore file mode. Look into your project, in the `.git` folder for the `config` fil...
8839958
How does origin/HEAD get set?
227
2012-01-12 18:03:15
<p>I have a branch set up to track a ref in origin. <code>git checkout &lt;branchname&gt;</code> switches to that branch, and a <code>git status</code> will show me how far ahead or behind my branch is from origin, but I'm surprised that <code>origin/HEAD</code> still points at <code>origin/master</code>, and not <cod...
303,864
37,838
2024-12-24 17:09:02
8,841,024
266
2012-01-12 19:22:52
119,963
2014-08-22 15:37:32
https://stackoverflow.com/q/8839958
https://stackoverflow.com/a/8841024
<p>Note first that your question shows a bit of misunderstanding. <strong>origin/HEAD represents the default branch on the remote</strong>, i.e. the HEAD that's in that remote repository you're calling origin. When you switch branches in your repo, you're not affecting that. The same is true for remote branches; you mi...
<p>Note first that your question shows a bit of misunderstanding. <strong>origin/HEAD represents the default branch on the remote</strong>, i.e. the HEAD that's in that remote repository you're calling origin. When you switch branches in your repo, you're not affecting that. The same is true for remote branches; you mi...
119
git
<h1>How does origin/HEAD get set?</h1> <p>I have a branch set up to track a ref in origin. <code>git checkout &lt;branchname&gt;</code> switches to that branch, and a <code>git status</code> will show me how far ahead or behind my branch is from origin, but I'm surprised that <code>origin/HEAD</code> still points at <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,812
git
# How does origin/HEAD get set? I have a branch set up to track a ref in origin. `git checkout <branchname>` switches to that branch, and a `git status` will show me how far ahead or behind my branch is from origin, but I'm surprised that `origin/HEAD` still points at `origin/master`, and not `origin/<branchname>` So...
Note first that your question shows a bit of misunderstanding. **origin/HEAD represents the default branch on the remote**, i.e. the HEAD that's in that remote repository you're calling origin. When you switch branches in your repo, you're not affecting that. The same is true for remote branches; you might have `master...
4991594
Revert a range of commits in git
218
2011-02-14 11:25:16
<p>How can I revert a range of commits in git? From looking at the <a href="http://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html" rel="noreferrer">gitrevisions</a> documentation, I cannot see how to specify the range I need. For example:</p> <pre><code>A -&gt; B -&gt; C -&gt; D -&gt; E -&gt; HEAD </code><...
112,695
12,149
2023-07-17 23:57:16
4,992,711
266
2011-02-14 13:31:09
6,309
2018-01-16 08:41:27
https://stackoverflow.com/q/4991594
https://stackoverflow.com/a/4992711
<p>What version of Git are you using?</p> <p>Reverting multiple commits in only supported in Git1.7.2+: see "<a href="https://stackoverflow.com/questions/4716051/rollback-to-an-old-commit-using-revert-multiple-times">Rollback to an old commit using revert multiple times.</a>" for more details.<br> The current <a href=...
<p>What version of Git are you using?</p> <p>Reverting multiple commits in only supported in Git1.7.2+: see "<a href="https://stackoverflow.com/questions/4716051/rollback-to-an-old-commit-using-revert-multiple-times">Rollback to an old commit using revert multiple times.</a>" for more details.<br> The current <a href=...
119, 8125, 12309
git, range, revert
<h1>Revert a range of commits in git</h1> <p>How can I revert a range of commits in git? From looking at the <a href="http://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html" rel="noreferrer">gitrevisions</a> documentation, I cannot see how to specify the range I need. For example:</p> <pre><code>A -&gt; B -...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,813
git
# Revert a range of commits in git How can I revert a range of commits in git? From looking at the [gitrevisions](http://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html) documentation, I cannot see how to specify the range I need. For example: ``` A -> B -> C -> D -> E -> HEAD ``` I want to do the equival...
What version of Git are you using? Reverting multiple commits in only supported in Git1.7.2+: see "[Rollback to an old commit using revert multiple times.](https://stackoverflow.com/questions/4716051/rollback-to-an-old-commit-using-revert-multiple-times)" for more details. The current [`git revert` man page](http://...
7556155
Git: Set up a fetch-only remote?
190
2011-09-26 13:53:38
<p>When I run <code>git remote -v</code> in one of my Git repositories that has a remote(s) configured, I see that each remote has both fetch and push specs:</p> <pre><code>$ git remote -v &lt;remote-name&gt; ssh://host/path/to/repo (fetch) &lt;remote-name&gt; ssh://host/path/to/repo (push) </code></pre> <p>For remot...
48,056
263,607
2019-10-30 13:00:13
7,556,269
266
2011-09-26 14:02:14
133,732
2015-04-22 20:31:40
https://stackoverflow.com/q/7556155
https://stackoverflow.com/a/7556269
<p>I don't think you can <em>remove</em> the push URL, you can only <em>override</em> it to be something other than the pull URL. So I think the closest you'll get is something like this:</p> <pre><code>$ git remote set-url --push origin no-pushing $ git push fatal: 'no-pushing' does not appear to be a git repository ...
<p>I don't think you can <em>remove</em> the push URL, you can only <em>override</em> it to be something other than the pull URL. So I think the closest you'll get is something like this:</p> <pre><code>$ git remote set-url --push origin no-pushing $ git push fatal: 'no-pushing' does not appear to be a git repository ...
119, 758
git, workflow
<h1>Git: Set up a fetch-only remote?</h1> <p>When I run <code>git remote -v</code> in one of my Git repositories that has a remote(s) configured, I see that each remote has both fetch and push specs:</p> <pre><code>$ git remote -v &lt;remote-name&gt; ssh://host/path/to/repo (fetch) &lt;remote-name&gt; ssh://host/path/...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,814
git
# Git: Set up a fetch-only remote? When I run `git remote -v` in one of my Git repositories that has a remote(s) configured, I see that each remote has both fetch and push specs: ``` $ git remote -v <remote-name> ssh://host/path/to/repo (fetch) <remote-name> ssh://host/path/to/repo (push) ``` For remotes that point ...
I don't think you can *remove* the push URL, you can only *override* it to be something other than the pull URL. So I think the closest you'll get is something like this: ``` $ git remote set-url --push origin no-pushing $ git push fatal: 'no-pushing' does not appear to be a git repository fatal: The remote end hung u...
21573405
How to prepare a Unity project for git (step-by-step)?
189
2014-02-05 09:36:16
<p>What are the detailed steps necessary to prepare a Unity project for committing to a git repository eg. github? I don't want to store unnecessary files (specially temp files and avoid binary formats as much as possible) and I would appreciate a walk-through.</p>
141,877
267,265
2022-09-16 13:40:43
21,573,406
266
2014-02-05 09:36:16
267,265
2016-07-22 13:43:39
https://stackoverflow.com/q/21573405
https://stackoverflow.com/a/21573406
<p>On the Unity Editor open your project and:</p> <ol> <li>Enable <strong>External option</strong> in <strong>Unity</strong> → <strong>Preferences</strong> → <strong>Packages</strong> → <strong>Repository</strong> (only if Unity ver &lt; 4.5)</li> <li>Switch to <strong>Visible Meta Files</strong> in <strong>Edit</stro...
<p>On the Unity Editor open your project and:</p> <ol> <li>Enable <strong>External option</strong> in <strong>Unity</strong> → <strong>Preferences</strong> → <strong>Packages</strong> → <strong>Repository</strong> (only if Unity ver &lt; 4.5)</li> <li>Switch to <strong>Visible Meta Files</strong> in <strong>Edit</stro...
119, 28511
git, unity-game-engine
<h1>How to prepare a Unity project for git (step-by-step)?</h1> <p>What are the detailed steps necessary to prepare a Unity project for committing to a git repository eg. github? I don't want to store unnecessary files (specially temp files and avoid binary formats as much as possible) and I would appreciate a walk-thr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,815
git
# How to prepare a Unity project for git (step-by-step)? What are the detailed steps necessary to prepare a Unity project for committing to a git repository eg. github? I don't want to store unnecessary files (specially temp files and avoid binary formats as much as possible) and I would appreciate a walk-through.
On the Unity Editor open your project and: 1. Enable **External option** in **Unity** → **Preferences** → **Packages** → **Repository** (only if Unity ver < 4.5) 2. Switch to **Visible Meta Files** in **Edit** → **Project Settings** → **Editor** → **Version Control Mode** 3. Switch to **Force Text** in **Edit** → **Pr...
552659
How to assign a Git SHA1's to a file without Git?
146
2009-02-16 08:53:23
<p>As I understand it when Git assigns a SHA1 hash to a file this SHA1 is unique to the file based on its contents. </p> <p>As a result if a file moves from one repository to another the SHA1 for the file remains the same as its contents have not changed. </p> <p>How does Git calculate the SHA1 digest? Does it do it ...
25,070
52,416
2026-01-06 09:43:32
552,725
266
2009-02-16 09:25:54
34,855
2014-06-27 19:57:03
https://stackoverflow.com/q/552659
https://stackoverflow.com/a/552725
<p>This is how Git calculates the SHA1 for a file (or, in Git terms, a "blob"):</p> <pre class="lang-sh prettyprint-override"><code>sha1("blob " + filesize + "\0" + data) </code></pre> <p>So you can easily compute it yourself without having Git installed. Note that "\0" is the NULL-byte, not a two-character string.</...
<p>This is how Git calculates the SHA1 for a file (or, in Git terms, a "blob"):</p> <pre class="lang-sh prettyprint-override"><code>sha1("blob " + filesize + "\0" + data) </code></pre> <p>So you can easily compute it yourself without having Git installed. Note that "\0" is the NULL-byte, not a two-character string.</...
119, 3190
git, sha1
<h1>How to assign a Git SHA1's to a file without Git?</h1> <p>As I understand it when Git assigns a SHA1 hash to a file this SHA1 is unique to the file based on its contents. </p> <p>As a result if a file moves from one repository to another the SHA1 for the file remains the same as its contents have not changed. </p>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,816
git
# How to assign a Git SHA1's to a file without Git? As I understand it when Git assigns a SHA1 hash to a file this SHA1 is unique to the file based on its contents. As a result if a file moves from one repository to another the SHA1 for the file remains the same as its contents have not changed. How does Git calcula...
This is how Git calculates the SHA1 for a file (or, in Git terms, a "blob"): ``` sha1("blob " + filesize + "\0" + data) ``` So you can easily compute it yourself without having Git installed. Note that "\0" is the NULL-byte, not a two-character string. For example, the hash of an empty file: ``` sha1("blob 0\0") = ...
5613345
How to shrink the .git folder
317
2011-04-10 17:05:50
<p>My current base has a total size of approx. 200MB.</p> <p>But my .git folder has an amazing size of 5GB (!). Since I push my work to an external server, i don't need any big local history...</p> <p>How can I shrink the .git folder to free up some space on my notebook? Can I delete all changes that are older, than 30...
212,876
553,820
2023-12-15 00:19:45
5,613,380
265
2011-04-10 17:09:54
112,968
2023-08-25 03:17:57
https://stackoverflow.com/q/5613345
https://stackoverflow.com/a/5613380
<p>Linus Torvalds <a href="http://gcc.gnu.org/ml/gcc/2007-12/msg00165.html" rel="noreferrer">recommends</a>:</p> <pre><code>git repack -a -d -f --depth=250 --window=250 </code></pre> <p>This could take a long time for old repos. Consider letting it run overnight.</p> <p>Note: Do you have a lot of binary files (archives...
<p>Linus Torvalds <a href="http://gcc.gnu.org/ml/gcc/2007-12/msg00165.html" rel="noreferrer">recommends</a>:</p> <pre><code>git repack -a -d -f --depth=250 --window=250 </code></pre> <p>This could take a long time for old repos. Consider letting it run overnight.</p> <p>Note: Do you have a lot of binary files (archives...
119
git
<h1>How to shrink the .git folder</h1> <p>My current base has a total size of approx. 200MB.</p> <p>But my .git folder has an amazing size of 5GB (!). Since I push my work to an external server, i don't need any big local history...</p> <p>How can I shrink the .git folder to free up some space on my notebook? Can I del...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,817
git
# How to shrink the .git folder My current base has a total size of approx. 200MB. But my .git folder has an amazing size of 5GB (!). Since I push my work to an external server, i don't need any big local history... How can I shrink the .git folder to free up some space on my notebook? Can I delete all changes that ...
Linus Torvalds [recommends](http://gcc.gnu.org/ml/gcc/2007-12/msg00165.html): ``` git repack -a -d -f --depth=250 --window=250 ``` This could take a long time for old repos. Consider letting it run overnight. Note: Do you have a lot of binary files (archives, images, executables) which change often? Those usually le...
7566416
How to see which commits in one branch aren't in the other?
226
2011-09-27 08:49:02
<p>I have two branches <code>devel</code> and <code>next</code>. In devel I have a more or less huge amount of commits. Some of the commits are cherry picked in <code>next</code>. Also I added some commits to next which are merged to <code>devel</code>.</p> <p>Now I would like to see what is missing in <code>next</cod...
104,026
966,599
2025-03-22 08:43:03
7,566,523
265
2011-09-27 08:58:03
223,092
2025-03-22 08:43:03
https://stackoverflow.com/q/7566416
https://stackoverflow.com/a/7566523
<p>The little-used command <code>git cherry</code> (<a href="https://git-scm.com/docs/git-cherry" rel="noreferrer">docs</a>) shows you the commits which haven't yet been cherry-picked.</p> <p>In short:</p> <pre class="lang-bash prettyprint-override"><code>git cherry &lt;feature-branch&gt; [base-branch] </code></pre> <p...
<p>The little-used command <code>git cherry</code> (<a href="https://git-scm.com/docs/git-cherry" rel="noreferrer">docs</a>) shows you the commits which haven't yet been cherry-picked.</p> <p>In short:</p> <pre class="lang-bash prettyprint-override"><code>git cherry &lt;feature-branch&gt; [base-branch] </code></pre> <p...
119
git
<h1>How to see which commits in one branch aren't in the other?</h1> <p>I have two branches <code>devel</code> and <code>next</code>. In devel I have a more or less huge amount of commits. Some of the commits are cherry picked in <code>next</code>. Also I added some commits to next which are merged to <code>devel</code...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,818
git
# How to see which commits in one branch aren't in the other? I have two branches `devel` and `next`. In devel I have a more or less huge amount of commits. Some of the commits are cherry picked in `next`. Also I added some commits to next which are merged to `devel`. Now I would like to see what is missing in `next`...
The little-used command `git cherry` ([docs](https://git-scm.com/docs/git-cherry)) shows you the commits which haven't yet been cherry-picked. In short: ``` git cherry <feature-branch> [base-branch] ``` ``` # Checkout the base branch git checkout main # Diff against the target branch git cherry -v next ``` Example...
16758131
What's the difference between "squash" and "fixup" in Git/Git Extension?
222
2013-05-26 10:01:00
<p>I've been using <strong>Git Extensions</strong> for a while now (it's awesome!) but I haven't found a simple answer to the following:</p> <p>Sometimes, when typing a commit message, a make a typo. My friend showed me how to fix it the following way (in Git Extentions):</p> <blockquote> <p>Right-Click on the comm...
118,807
904,554
2023-09-02 06:33:50
16,758,662
265
2013-05-26 11:11:07
719,279
2018-05-02 05:51:50
https://stackoverflow.com/q/16758131
https://stackoverflow.com/a/16758662
<p>I do not know what Git Extensions does with it specifically, but <code>git rebase</code> has an option to automatically squash or fixup commits with squash! or fixup! prefixes, respectively:</p> <pre><code> --autosquash, --no-autosquash When the commit log message begins with "squash! ..." (or "fixup! ...
<p>I do not know what Git Extensions does with it specifically, but <code>git rebase</code> has an option to automatically squash or fixup commits with squash! or fixup! prefixes, respectively:</p> <pre><code> --autosquash, --no-autosquash When the commit log message begins with "squash! ..." (or "fixup! ...
119, 34019, 39597, 42532, 91850
difference, fixup, git, git-extensions, squash
<h1>What's the difference between "squash" and "fixup" in Git/Git Extension?</h1> <p>I've been using <strong>Git Extensions</strong> for a while now (it's awesome!) but I haven't found a simple answer to the following:</p> <p>Sometimes, when typing a commit message, a make a typo. My friend showed me how to fix it the...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,819
git
# What's the difference between "squash" and "fixup" in Git/Git Extension? I've been using **Git Extensions** for a while now (it's awesome!) but I haven't found a simple answer to the following: Sometimes, when typing a commit message, a make a typo. My friend showed me how to fix it the following way (in Git Extent...
I do not know what Git Extensions does with it specifically, but `git rebase` has an option to automatically squash or fixup commits with squash! or fixup! prefixes, respectively: ``` --autosquash, --no-autosquash When the commit log message begins with "squash! ..." (or "fixup! ..."), and there is a ...
1692892
warning: refname 'HEAD' is ambiguous
173
2009-11-07 12:32:54
<p>I am new to Git and I seem to have one branch too many if I execute the following command:</p> <pre><code>warning: refname 'HEAD' is ambiguous. </code></pre> <p>I get the following output:</p> <pre><code>warning: refname 'HEAD' is ambiguous. From github.com:dagda1/hornget * branch master -&gt; FET...
93,775
11,755
2017-12-14 10:30:24
1,692,926
265
2009-11-07 12:46:20
137,317
2009-11-07 12:46:20
https://stackoverflow.com/q/1692892
https://stackoverflow.com/a/1692926
<p>The problem is that you have a branch called <code>HEAD</code> which is absolutely dangerous, since that's the symbolic name for whatever branch is the <em>current</em> branch.</p> <p>Rename it:</p> <pre><code>git branch -m HEAD newbranch </code></pre> <p>then you can examine it and decide what to do (delete it, ...
<p>The problem is that you have a branch called <code>HEAD</code> which is absolutely dangerous, since that's the symbolic name for whatever branch is the <em>current</em> branch.</p> <p>Rename it:</p> <pre><code>git branch -m HEAD newbranch </code></pre> <p>then you can examine it and decide what to do (delete it, ...
119
git
<h1>warning: refname 'HEAD' is ambiguous</h1> <p>I am new to Git and I seem to have one branch too many if I execute the following command:</p> <pre><code>warning: refname 'HEAD' is ambiguous. </code></pre> <p>I get the following output:</p> <pre><code>warning: refname 'HEAD' is ambiguous. From github.com:dagda1/hor...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,821
git
# warning: refname 'HEAD' is ambiguous I am new to Git and I seem to have one branch too many if I execute the following command: ``` warning: refname 'HEAD' is ambiguous. ``` I get the following output: ``` warning: refname 'HEAD' is ambiguous. From github.com:dagda1/hornget * branch master -> FETC...
The problem is that you have a branch called `HEAD` which is absolutely dangerous, since that's the symbolic name for whatever branch is the *current* branch. Rename it: ``` git branch -m HEAD newbranch ``` then you can examine it and decide what to do (delete it, or save under a descriptive branch name) (The `orig...
13154562
Have I lost my changes after rebasing?
115
2012-10-31 09:14:49
<p>I recently rebased a branch that I was working on. The history of the tree looked something like this:</p> <pre><code>1 = 2 = 3 = 4 \ 5 = 6 = 7 \ 8 </code></pre> <p>I wanted to rebase my changes (number 8 in the diagram) to be on the master branch (up to commit 4 on the diagram no...
103,389
450,609
2023-02-07 21:35:59
13,155,341
265
2012-10-31 09:58:50
683,080
2012-10-31 09:58:50
https://stackoverflow.com/q/13154562
https://stackoverflow.com/a/13155341
<p>If you're not seeing any difference, I suspect you lost your changes. You can likely use <a href="http://git-scm.com/docs/git-reflog" rel="noreferrer"><code>git reflog</code></a> to identify the branch that existed before the rebase, and use <code>git reset --hard &lt;my-branch-tip-before-rebase&gt;</code> to get b...
<p>If you're not seeing any difference, I suspect you lost your changes. You can likely use <a href="http://git-scm.com/docs/git-reflog" rel="noreferrer"><code>git reflog</code></a> to identify the branch that existed before the rebase, and use <code>git reset --hard &lt;my-branch-tip-before-rebase&gt;</code> to get b...
119, 456
git, version-control
<h1>Have I lost my changes after rebasing?</h1> <p>I recently rebased a branch that I was working on. The history of the tree looked something like this:</p> <pre><code>1 = 2 = 3 = 4 \ 5 = 6 = 7 \ 8 </code></pre> <p>I wanted to rebase my changes (number 8 in the diagram) to be on the...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,822
git
# Have I lost my changes after rebasing? I recently rebased a branch that I was working on. The history of the tree looked something like this: ``` 1 = 2 = 3 = 4 \ 5 = 6 = 7 \ 8 ``` I wanted to rebase my changes (number 8 in the diagram) to be on the master branch (up to commit 4 on...
If you're not seeing any difference, I suspect you lost your changes. You can likely use [`git reflog`](http://git-scm.com/docs/git-reflog) to identify the branch that existed before the rebase, and use `git reset --hard <my-branch-tip-before-rebase>` to get back the original branch. And yes, you'll have to run through...
5257553
Coloring white space in git-diff's output
229
2011-03-10 09:15:19
<p>Regarding code formatting I'm kind of purist :). I very often remove unnecessary white spaces (lines with only ws, ws at the end of lines etc). I even have set vim to show that kind of lines colored to red.</p> <p>My problem is that using git-diff I often see something like this:</p> <pre><code>- else{ + ...
84,290
66,553
2023-02-02 01:11:40
5,259,137
264
2011-03-10 11:38:12
223,092
2022-02-21 04:40:12
https://stackoverflow.com/q/5257553
https://stackoverflow.com/a/5259137
<p>With <a href="https://stackoverflow.com/a/30803980/6309">with Git 2.11 (Q4 2016)</a> and after, you can do:</p> <pre><code>git config diff.wsErrorHighlight all </code></pre> <p>See <a href="https://github.com/git/git/blob/e5272d304af3528163cd5faa822f88086448ae57/Documentation/diff-config.txt#L197-L201" rel="noreferr...
<p>With <a href="https://stackoverflow.com/a/30803980/6309">with Git 2.11 (Q4 2016)</a> and after, you can do:</p> <pre><code>git config diff.wsErrorHighlight all </code></pre> <p>See <a href="https://github.com/git/git/blob/e5272d304af3528163cd5faa822f88086448ae57/Documentation/diff-config.txt#L197-L201" rel="noreferr...
119, 606, 1084, 6439
colors, diff, git, whitespace
<h1>Coloring white space in git-diff's output</h1> <p>Regarding code formatting I'm kind of purist :). I very often remove unnecessary white spaces (lines with only ws, ws at the end of lines etc). I even have set vim to show that kind of lines colored to red.</p> <p>My problem is that using git-diff I often see somet...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,823
git
# Coloring white space in git-diff's output Regarding code formatting I'm kind of purist :). I very often remove unnecessary white spaces (lines with only ws, ws at the end of lines etc). I even have set vim to show that kind of lines colored to red. My problem is that using git-diff I often see something like this: ...
With [with Git 2.11 (Q4 2016)](https://stackoverflow.com/a/30803980/6309) and after, you can do: ``` git config diff.wsErrorHighlight all ``` See [doc on `git diff`](https://github.com/git/git/blob/e5272d304af3528163cd5faa822f88086448ae57/Documentation/diff-config.txt#L197-L201) and [on `git config`](https://github.c...
11856983
Why is git AuthorDate different from CommitDate?
185
2012-08-08 02:50:43
<p>I looked in my git logs and found that the AuthorDate and CommitDate is slightly different for some of my commits. From the <code>git log --pretty=fuller</code> output:</p> <pre><code>commit 3a5912f90dc5227f308e99f95152fbee2301c59a Author: &lt;hidden&gt; AuthorDate: Fri Jun 15 10:57:22 2012 +0800 Commit: &lt...
69,484
547,578
2025-02-07 07:25:55
11,857,467
264
2012-08-08 03:55:22
520,162
2025-02-07 07:25:55
https://stackoverflow.com/q/11856983
https://stackoverflow.com/a/11857467
<p>The <strong>author date</strong> notes when this commit was originally made (i.e. when you finished the <code>git commit</code>). According to the docs of <a href="http://www.kernel.org/pub/software/scm/git/docs/git-commit.html" rel="noreferrer"><code>git commit</code></a>, the author date could be overridden using ...
<p>The <strong>author date</strong> notes when this commit was originally made (i.e. when you finished the <code>git commit</code>). According to the docs of <a href="http://www.kernel.org/pub/software/scm/git/docs/git-commit.html" rel="noreferrer"><code>git commit</code></a>, the author date could be overridden using ...
119
git
<h1>Why is git AuthorDate different from CommitDate?</h1> <p>I looked in my git logs and found that the AuthorDate and CommitDate is slightly different for some of my commits. From the <code>git log --pretty=fuller</code> output:</p> <pre><code>commit 3a5912f90dc5227f308e99f95152fbee2301c59a Author: &lt;hidden&gt; ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,824
git
# Why is git AuthorDate different from CommitDate? I looked in my git logs and found that the AuthorDate and CommitDate is slightly different for some of my commits. From the `git log --pretty=fuller` output: ``` commit 3a5912f90dc5227f308e99f95152fbee2301c59a Author: <hidden> AuthorDate: Fri Jun 15 10:57:22 2012...
The **author date** notes when this commit was originally made (i.e. when you finished the `git commit`). According to the docs of [`git commit`](http://www.kernel.org/pub/software/scm/git/docs/git-commit.html), the author date could be overridden using the `--date` switch. The **commit date** gets changed every time ...
26174757
Git: Needed a single revision error
138
2014-10-03 07:16:59
<p>I initialized a new git in my project and I have only two commits so far. My log is like below</p> <pre><code>git log commit e515e5b8dcbd8f1ea4a7a7d4a1efb82a1a0aee7a Author: Olkun Mustafa &lt;olkun.mustafa@gmail.com&gt; Date: Fri Oct 3 10:04:20 2014 +0300 Temp commit commit 71781bf0a7807351a56d5155dac94169e...
74,524
2,834,196
2021-01-08 18:05:11
26,174,905
264
2014-10-03 07:28:56
6,309
2021-01-08 18:05:11
https://stackoverflow.com/q/26174757
https://stackoverflow.com/a/26174905
<p>In your case, there is no <code>HEAD~2</code>, since you only have 2 commits, hence the &quot;<code>Needed a single revision</code>&quot; error message.<br /> Try:</p> <pre><code> git rebase -i --root </code></pre> <p>see more about <code>--root</code> at &quot;<a href="https://stackoverflow.com/a/2309391/6309">Chan...
<p>In your case, there is no <code>HEAD~2</code>, since you only have 2 commits, hence the &quot;<code>Needed a single revision</code>&quot; error message.<br /> Try:</p> <pre><code> git rebase -i --root </code></pre> <p>see more about <code>--root</code> at &quot;<a href="https://stackoverflow.com/a/2309391/6309">Chan...
119
git
<h1>Git: Needed a single revision error</h1> <p>I initialized a new git in my project and I have only two commits so far. My log is like below</p> <pre><code>git log commit e515e5b8dcbd8f1ea4a7a7d4a1efb82a1a0aee7a Author: Olkun Mustafa &lt;olkun.mustafa@gmail.com&gt; Date: Fri Oct 3 10:04:20 2014 +0300 Temp com...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,825
git
# Git: Needed a single revision error I initialized a new git in my project and I have only two commits so far. My log is like below ``` git log commit e515e5b8dcbd8f1ea4a7a7d4a1efb82a1a0aee7a Author: Olkun Mustafa <olkun.mustafa@gmail.com> Date: Fri Oct 3 10:04:20 2014 +0300 Temp commit commit 71781bf0a78073...
In your case, there is no `HEAD~2`, since you only have 2 commits, hence the "`Needed a single revision`" error message. Try: ``` git rebase -i --root ``` see more about `--root` at "[Change first commit of project with Git?](https://stackoverflow.com/a/2309391/6309)"
3694380
Calculating distance between two points, using latitude longitude?
116
2010-09-12 09:47:19
<p>Here's my try, it's just a snippet of my code:</p> <pre><code>final double RADIUS = 6371.01; double temp = Math.cos(Math.toRadians(latA)) * Math.cos(Math.toRadians(latB)) * Math.cos(Math.toRadians((latB) - (latA))) + Math.sin(Math.toRadians(latA)) * Math.sin(Math.toRa...
222,197
323,926
2024-09-03 04:31:03
16,794,680
264
2013-05-28 14:30:21
502,162
2024-03-06 16:14:24
https://stackoverflow.com/q/3694380
https://stackoverflow.com/a/16794680
<p>The <a href="https://stackoverflow.com/a/3694410/238704">Java code given by Dommer</a> gives slightly incorrect results but the small errors add up if you are processing say a GPS track. Here is an implementation of the Haversine method in Java which also takes into account height differences between two points.</p>...
<p>The <a href="https://stackoverflow.com/a/3694410/238704">Java code given by Dommer</a> gives slightly incorrect results but the small errors add up if you are processing say a GPS track. Here is an implementation of the Haversine method in Java which also takes into account height differences between two points.</p>...
17, 259, 20301
java, latitude-longitude, math
<h1>Calculating distance between two points, using latitude longitude?</h1> <p>Here's my try, it's just a snippet of my code:</p> <pre><code>final double RADIUS = 6371.01; double temp = Math.cos(Math.toRadians(latA)) * Math.cos(Math.toRadians(latB)) * Math.cos(Math.toRadians((latB) - (latA))) ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,826
git
# Calculating distance between two points, using latitude longitude? Here's my try, it's just a snippet of my code: ``` final double RADIUS = 6371.01; double temp = Math.cos(Math.toRadians(latA)) * Math.cos(Math.toRadians(latB)) * Math.cos(Math.toRadians((latB) - (latA))) + Math.si...
The [Java code given by Dommer](https://stackoverflow.com/a/3694410/238704) gives slightly incorrect results but the small errors add up if you are processing say a GPS track. Here is an implementation of the Haversine method in Java which also takes into account height differences between two points. ``` /** * Calcu...
2553786
How do I alias commands in git?
866
2010-03-31 14:31:20
<p>I saw a screencast where someone had gotten </p> <pre><code>git st git ci </code></pre> <p>to work. When I do it I get an error asking me if I meant something else.<br> Being a git newb, I need to know what you have to do to get this done?</p>
435,313
1,220
2024-10-31 02:02:08
2,554,167
263
2010-03-31 15:19:44
95,592
2023-06-19 22:12:05
https://stackoverflow.com/q/2553786
https://stackoverflow.com/a/2554167
<p>As others have said the appropriate way to add git aliases is in your global <code>.gitconfig</code> file either by editing <code>~/.gitconfig</code> or by using the <code>git config --global alias.&lt;alias&gt; &lt;git-command&gt;</code> command</p> <p>Below is a copy of the alias section of my <code>~/.gitconfig</...
<p>As others have said the appropriate way to add git aliases is in your global <code>.gitconfig</code> file either by editing <code>~/.gitconfig</code> or by using the <code>git config --global alias.&lt;alias&gt; &lt;git-command&gt;</code> command</p> <p>Below is a copy of the alias section of my <code>~/.gitconfig</...
119, 79211
git, git-alias
<h1>How do I alias commands in git?</h1> <p>I saw a screencast where someone had gotten </p> <pre><code>git st git ci </code></pre> <p>to work. When I do it I get an error asking me if I meant something else.<br> Being a git newb, I need to know what you have to do to get this done?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,827
git
# How do I alias commands in git? I saw a screencast where someone had gotten ``` git st git ci ``` to work. When I do it I get an error asking me if I meant something else. Being a git newb, I need to know what you have to do to get this done?
As others have said the appropriate way to add git aliases is in your global `.gitconfig` file either by editing `~/.gitconfig` or by using the `git config --global alias.<alias> <git-command>` command Below is a copy of the alias section of my `~/.gitconfig` file: ``` [alias] st = status ci = commit co =...
1484648
How to migrate GIT repository from one server to a new one
324
2009-09-27 22:26:26
<p>I have a server that I'm taking down. The only thing I have left to migrate is my repository. This server is listed as the origin (master) for one of my projects. What is the proper way to move the repository to keep the history.</p>
263,264
64,728
2024-07-26 16:38:45
1,484,666
263
2009-09-27 22:37:29
165,017
2009-09-27 22:37:29
https://stackoverflow.com/q/1484648
https://stackoverflow.com/a/1484666
<p>To add the new repo location, </p> <pre><code>git remote add new_repo_name new_repo_url </code></pre> <p>Then push the content to the new location</p> <pre><code>git push new_repo_name master </code></pre> <p>Finally remove the old one</p> <pre><code>git remote rm origin </code></pre> <p>After that you can do ...
<p>To add the new repo location, </p> <pre><code>git remote add new_repo_name new_repo_url </code></pre> <p>Then push the content to the new location</p> <pre><code>git push new_repo_name master </code></pre> <p>Finally remove the old one</p> <pre><code>git remote rm origin </code></pre> <p>After that you can do ...
119
git
<h1>How to migrate GIT repository from one server to a new one</h1> <p>I have a server that I'm taking down. The only thing I have left to migrate is my repository. This server is listed as the origin (master) for one of my projects. What is the proper way to move the repository to keep the history.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,828
git
# How to migrate GIT repository from one server to a new one I have a server that I'm taking down. The only thing I have left to migrate is my repository. This server is listed as the origin (master) for one of my projects. What is the proper way to move the repository to keep the history.
To add the new repo location, ``` git remote add new_repo_name new_repo_url ``` Then push the content to the new location ``` git push new_repo_name master ``` Finally remove the old one ``` git remote rm origin ``` After that you can do what bdonlan said and edit the.git/config file to change the new_repo_name t...
747075
How to git-svn clone the last n revisions from a Subversion repository?
332
2009-04-14 10:58:07
<p><strong>Problem</strong></p> <p>How do you create a shallow copy with git-svn from a Subversion repository, e.g. how do you pull only the last three revisions?</p> <p>The <code>git clone</code> command can get the last n revisions from a Git repository if you use the option <code>--depth</code>, i.e. you get a sha...
156,404
33,311
2025-11-11 19:18:18
749,054
262
2009-04-14 19:39:03
23,356
2025-11-11 19:18:18
https://stackoverflow.com/q/747075
https://stackoverflow.com/a/749054
<p>You've already discovered the simplest way to specify a shallow clone in Git-SVN, by specifying the SVN revision number that you want to start your clone at (<code>-r$REV:HEAD</code>).</p> <p>For example: <code>git svn clone -s -r1450:HEAD some/svn/repo</code></p> <p>Git's data structure is based on pointers in a d...
<p>You've already discovered the simplest way to specify a shallow clone in Git-SVN, by specifying the SVN revision number that you want to start your clone at (<code>-r$REV:HEAD</code>).</p> <p>For example: <code>git svn clone -s -r1450:HEAD some/svn/repo</code></p> <p>Git's data structure is based on pointers in a d...
63, 119, 6452, 34099, 65722
git, git-clone, git-svn, svn, svn-checkout
<h1>How to git-svn clone the last n revisions from a Subversion repository?</h1> <p><strong>Problem</strong></p> <p>How do you create a shallow copy with git-svn from a Subversion repository, e.g. how do you pull only the last three revisions?</p> <p>The <code>git clone</code> command can get the last n revisions fro...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,829
git
# How to git-svn clone the last n revisions from a Subversion repository? **Problem** How do you create a shallow copy with git-svn from a Subversion repository, e.g. how do you pull only the last three revisions? The `git clone` command can get the last n revisions from a Git repository if you use the option `--dep...
You've already discovered the simplest way to specify a shallow clone in Git-SVN, by specifying the SVN revision number that you want to start your clone at (`-r$REV:HEAD`). For example: `git svn clone -s -r1450:HEAD some/svn/repo` Git's data structure is based on pointers in a directed acyclic graph (DAG), which mak...
2160638
How can I format patch with what I stash away
198
2010-01-29 08:07:21
<p>In git, I stash away my changes. Is it possible that I can create a patch with what I stash away? And then apply that patch in some other repository (my co-worker's)?</p> <p>I know <code>git format-patch -1</code>, but I think that it's for what I have committed. But I am looking for the same thing for changes that...
84,679
114,970
2022-02-24 14:28:02
2,160,650
262
2010-01-29 08:09:17
893
2020-07-01 12:02:12
https://stackoverflow.com/q/2160638
https://stackoverflow.com/a/2160650
<p>Sure, <a href="http://git-scm.com/docs/git-stash.html" rel="noreferrer"><code>git stash show</code></a> supports this:</p> <pre class="lang-sh prettyprint-override"><code>git stash show -p </code></pre> <hr /> <p>So, use</p> <pre class="lang-sh prettyprint-override"><code>git stash list </code></pre> <p>to find out ...
<p>Sure, <a href="http://git-scm.com/docs/git-stash.html" rel="noreferrer"><code>git stash show</code></a> supports this:</p> <pre class="lang-sh prettyprint-override"><code>git stash show -p </code></pre> <hr /> <p>So, use</p> <pre class="lang-sh prettyprint-override"><code>git stash list </code></pre> <p>to find out ...
119, 13091, 62078
git, git-patch, git-stash
<h1>How can I format patch with what I stash away</h1> <p>In git, I stash away my changes. Is it possible that I can create a patch with what I stash away? And then apply that patch in some other repository (my co-worker's)?</p> <p>I know <code>git format-patch -1</code>, but I think that it's for what I have committe...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,831
git
# How can I format patch with what I stash away In git, I stash away my changes. Is it possible that I can create a patch with what I stash away? And then apply that patch in some other repository (my co-worker's)? I know `git format-patch -1`, but I think that it's for what I have committed. But I am looking for the...
Sure, [`git stash show`](http://git-scm.com/docs/git-stash.html) supports this: ``` git stash show -p ``` --- So, use ``` git stash list ``` to find out the number of the stash that you want to export as a patch, then ``` git stash show -p stash@{<number>} > <name>.patch ``` to export it. For example: ``` git ...
46645843
Where to store my Git personal access token?
441
2017-10-09 11:54:32
<p>Is it necessary to store the personal access token somewhere locally on the machine after generating it in GitHub? </p> <p>If yes, is there any preferred way where it could be stored?</p>
586,234
2,569,042
2025-07-14 08:03:21
51,505,417
261
2018-07-24 18:33:38
6,309
2023-02-03 20:05:11
https://stackoverflow.com/q/46645843
https://stackoverflow.com/a/51505417
<blockquote> <p>Half the point of passwords is that (ideally) you memorize them and the system hashes them, so therefore they're never stored anywhere in plain text.<br /> Yet GitHub's personal access token system seems to basically force you to store the token in plain text?</p> </blockquote> <p>First, a <a href="http...
<blockquote> <p>Half the point of passwords is that (ideally) you memorize them and the system hashes them, so therefore they're never stored anywhere in plain text.<br /> Yet GitHub's personal access token system seems to basically force you to store the token in plain text?</p> </blockquote> <p>First, a <a href="http...
119, 58149
access-token, git
<h1>Where to store my Git personal access token?</h1> <p>Is it necessary to store the personal access token somewhere locally on the machine after generating it in GitHub? </p> <p>If yes, is there any preferred way where it could be stored?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,832
git
# Where to store my Git personal access token? Is it necessary to store the personal access token somewhere locally on the machine after generating it in GitHub? If yes, is there any preferred way where it could be stored?
> Half the point of passwords is that (ideally) you memorize them and the system hashes them, so therefore they're never stored anywhere in plain text. > Yet GitHub's personal access token system seems to basically force you to store the token in plain text? First, a [PAT (Personal Access Token)](https://help.github...
12762922
Git: Cannot see new remote branch
212
2012-10-06 19:06:02
<p>A colleague pushed a new remote branch to origin/dev/homepage and I cannot see it when I run:</p> <pre><code>$ git branch -r </code></pre> <p>I still see preexisting remote branches. </p> <p>I assume this is because my local remote refs are not up-to-date hence when I ran a git pull nothing happened since git pul...
345,713
852,366
2024-02-22 07:37:50
12,762,937
261
2012-10-06 19:08:01
1,451,820
2012-10-06 20:57:29
https://stackoverflow.com/q/12762922
https://stackoverflow.com/a/12762937
<p>First, double check that the branch has been actually pushed remotely, by using the command <code>git ls-remote origin</code>. If the new branch appears in the output, try and give the command <code>git fetch</code>: it should download the branch references from the remote repository.</p> <p>If your remote branch s...
<p>First, double check that the branch has been actually pushed remotely, by using the command <code>git ls-remote origin</code>. If the new branch appears in the output, try and give the command <code>git fetch</code>: it should download the branch references from the remote repository.</p> <p>If your remote branch s...
119, 31678
git, remote-branch
<h1>Git: Cannot see new remote branch</h1> <p>A colleague pushed a new remote branch to origin/dev/homepage and I cannot see it when I run:</p> <pre><code>$ git branch -r </code></pre> <p>I still see preexisting remote branches. </p> <p>I assume this is because my local remote refs are not up-to-date hence when I ra...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,833
git
# Git: Cannot see new remote branch A colleague pushed a new remote branch to origin/dev/homepage and I cannot see it when I run: ``` $ git branch -r ``` I still see preexisting remote branches. I assume this is because my local remote refs are not up-to-date hence when I ran a git pull nothing happened since git p...
First, double check that the branch has been actually pushed remotely, by using the command `git ls-remote origin`. If the new branch appears in the output, try and give the command `git fetch`: it should download the branch references from the remote repository. If your remote branch still does not appear, double che...
6150188
How to update a git clone --mirror?
176
2011-05-27 09:16:42
<p>I have created a git repository to mirror a live site (which is a non-bare git repository):</p> <pre><code>git clone --mirror ssh://user@example.com/path/to/repo </code></pre> <p>Now, to keep this mirror clone updated with all changes from its remote origin, which command or commands I must use?</p> <p>I'd like t...
179,929
370,290
2018-12-07 10:01:38
6,151,419
261
2011-05-27 11:12:19
106,205
2011-05-27 11:12:19
https://stackoverflow.com/q/6150188
https://stackoverflow.com/a/6151419
<p>This is the command that you need to execute on the mirror:</p> <pre><code>git remote update </code></pre>
<p>This is the command that you need to execute on the mirror:</p> <pre><code>git remote update </code></pre>
119, 7620, 33720, 34099, 41346
git, git-clone, git-fetch, git-remote, mirror
<h1>How to update a git clone --mirror?</h1> <p>I have created a git repository to mirror a live site (which is a non-bare git repository):</p> <pre><code>git clone --mirror ssh://user@example.com/path/to/repo </code></pre> <p>Now, to keep this mirror clone updated with all changes from its remote origin, which comma...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,835
git
# How to update a git clone --mirror? I have created a git repository to mirror a live site (which is a non-bare git repository): ``` git clone --mirror ssh://user@example.com/path/to/repo ``` Now, to keep this mirror clone updated with all changes from its remote origin, which command or commands I must use? I'd l...
This is the command that you need to execute on the mirror: ``` git remote update ```
30227858
.gitignore exclude specific file
164
2015-05-14 01:31:05
<p>I am trying to use <code>.gitignore</code> file to exclude <code>templates.js</code> located in <code>public/app/</code> folder. My <code>.gitignore</code> file looks like this:</p> <pre><code>/vendor /node_modules composer.phar composer.lock .DS_Store templates.js </code></pre> <p>But when I check in the Git Gui,...
159,250
1,995,781
2015-05-14 03:16:49
30,227,922
261
2015-05-14 01:39:30
67,579
2015-05-14 02:11:27
https://stackoverflow.com/q/30227858
https://stackoverflow.com/a/30227922
<p>In contrast to what the name "ignore" might suggest. <code>.gitignore</code> is only consulted when you <code>git add</code> files: in other words a file already added to the (index of the) repository will not be excluded based on the <code>.gitignore</code>.</p> <p>First you better modify the <code>.gitignore</cod...
<p>In contrast to what the name "ignore" might suggest. <code>.gitignore</code> is only consulted when you <code>git add</code> files: in other words a file already added to the (index of the) repository will not be excluded based on the <code>.gitignore</code>.</p> <p>First you better modify the <code>.gitignore</cod...
119, 25056
git, gitignore
<h1>.gitignore exclude specific file</h1> <p>I am trying to use <code>.gitignore</code> file to exclude <code>templates.js</code> located in <code>public/app/</code> folder. My <code>.gitignore</code> file looks like this:</p> <pre><code>/vendor /node_modules composer.phar composer.lock .DS_Store templates.js </code><...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,836
git
# .gitignore exclude specific file I am trying to use `.gitignore` file to exclude `templates.js` located in `public/app/` folder. My `.gitignore` file looks like this: ``` /vendor /node_modules composer.phar composer.lock .DS_Store templates.js ``` But when I check in the Git Gui, the `templates.js` file is still s...
In contrast to what the name "ignore" might suggest. `.gitignore` is only consulted when you `git add` files: in other words a file already added to the (index of the) repository will not be excluded based on the `.gitignore`. First you better modify the `.gitignore` such that the file is no longer added. Add the foll...
16434267
How to stash changes in current folder?
137
2013-05-08 06:41:14
<p>I would like to stash only the changes in the current folder and its subfolders.</p> <p>How can I achieve that?</p> <p>I have tried the obvious approach - <code>git stash .</code> but it doesn't seem to work.</p> <p>I know I can create temporary commits and delete them afterward, but I want to know if <code>git stas...
94,748
877,235
2021-08-15 11:14:31
51,758,558
261
2018-08-09 03:52:10
1,618,119
2018-08-09 03:52:10
https://stackoverflow.com/q/16434267
https://stackoverflow.com/a/51758558
<pre><code>git stash push -- path/to/folder </code></pre> <p>Does the trick for me.</p>
<pre><code>git stash push -- path/to/folder </code></pre> <p>Does the trick for me.</p>
119, 13091
git, git-stash
<h1>How to stash changes in current folder?</h1> <p>I would like to stash only the changes in the current folder and its subfolders.</p> <p>How can I achieve that?</p> <p>I have tried the obvious approach - <code>git stash .</code> but it doesn't seem to work.</p> <p>I know I can create temporary commits and delete the...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,837
git
# How to stash changes in current folder? I would like to stash only the changes in the current folder and its subfolders. How can I achieve that? I have tried the obvious approach - `git stash .` but it doesn't seem to work. I know I can create temporary commits and delete them afterward, but I want to know if `gi...
``` git stash push -- path/to/folder ``` Does the trick for me.
16951207
git commit error: pathspec 'commit' did not match any file(s) known to git
122
2013-06-05 22:55:18
<p>I am trying to upload a Ruby app to Heroku. I start with <code>git init</code> and then I type <code>git add .</code> and then I use <code>git commit -m initial commit</code>. </p> <p>Whenever I use <code>git commit -m</code>, I receive an error message saying:</p> <blockquote> <p>git commit error:pathspect 'com...
208,185
2,457,644
2023-01-31 13:11:44
16,951,241
260
2013-06-05 22:58:00
438,742
2013-06-05 22:58:00
https://stackoverflow.com/q/16951207
https://stackoverflow.com/a/16951241
<p>The command line arguments are separated by space. If you want provide an argument with a space in it, you should quote it. So use <code>git commit -m "initial commit"</code>.</p>
<p>The command line arguments are separated by space. If you want provide an argument with a space in it, you should quote it. So use <code>git commit -m "initial commit"</code>.</p>
119, 1231
command-line, git
<h1>git commit error: pathspec 'commit' did not match any file(s) known to git</h1> <p>I am trying to upload a Ruby app to Heroku. I start with <code>git init</code> and then I type <code>git add .</code> and then I use <code>git commit -m initial commit</code>. </p> <p>Whenever I use <code>git commit -m</code>, I rec...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,838
git
# git commit error: pathspec 'commit' did not match any file(s) known to git I am trying to upload a Ruby app to Heroku. I start with `git init` and then I type `git add .` and then I use `git commit -m initial commit`. Whenever I use `git commit -m`, I receive an error message saying: > git commit error:pathspect '...
The command line arguments are separated by space. If you want provide an argument with a space in it, you should quote it. So use `git commit -m "initial commit"`.
3601911
How do I undo a checkout in git?
192
2010-08-30 15:39:51
<p>I just checked out an earlier commit from my local git repo. I haven't made any changes to it, I was just looking at it. Now I want to go back to my latest commit - how do I do that?</p> <p>The exact command I used to check it out:</p> <pre><code>git checkout e5dff6b3c5d704f9b598de46551355d18235ac08 </code></pre> ...
377,908
118,175
2025-03-28 12:29:20
3,601,927
259
2010-08-30 15:41:38
148,870
2022-03-10 23:46:36
https://stackoverflow.com/q/3601911
https://stackoverflow.com/a/3601927
<p>Try this first:</p> <pre><code>git checkout master </code></pre> <p>(If you're on a different branch than <code>master</code> (or <code>main</code>), use the branch name there instead.)</p> <p>If that doesn't work, try...</p> <p>For a single file:</p> <pre><code>git checkout HEAD /path/to/file </code></pre> <p>For t...
<p>Try this first:</p> <pre><code>git checkout master </code></pre> <p>(If you're on a different branch than <code>master</code> (or <code>main</code>), use the branch name there instead.)</p> <p>If that doesn't work, try...</p> <p>For a single file:</p> <pre><code>git checkout HEAD /path/to/file </code></pre> <p>For t...
119
git
<h1>How do I undo a checkout in git?</h1> <p>I just checked out an earlier commit from my local git repo. I haven't made any changes to it, I was just looking at it. Now I want to go back to my latest commit - how do I do that?</p> <p>The exact command I used to check it out:</p> <pre><code>git checkout e5dff6b3c5d70...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,839
git
# How do I undo a checkout in git? I just checked out an earlier commit from my local git repo. I haven't made any changes to it, I was just looking at it. Now I want to go back to my latest commit - how do I do that? The exact command I used to check it out: ``` git checkout e5dff6b3c5d704f9b598de46551355d18235ac08...
Try this first: ``` git checkout master ``` (If you're on a different branch than `master` (or `main`), use the branch name there instead.) If that doesn't work, try... For a single file: ``` git checkout HEAD /path/to/file ``` For the entire repository working copy: ``` git reset --hard HEAD ``` And if that do...
6655052
Is there a way to rollback my last push to Git?
171
2011-07-11 18:42:54
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="https://stackoverflow.com/questions/1270514/undoing-a-git-push">Undoing a 'git push'</a> </p> </blockquote> <p>I have pushed some bad code, and I am the only user of the repository. How can I rollback my last commit?</p>
315,367
808,729
2015-04-24 18:21:55
6,655,126
259
2011-07-11 19:06:07
526,535
2011-07-11 22:41:08
https://stackoverflow.com/q/6655052
https://stackoverflow.com/a/6655126
<p>Since you are the only user:</p> <pre><code>git reset --hard HEAD@{1} git push -f git reset --hard HEAD@{1} </code></pre> <p>( basically, go back one commit, force push to the repo, then go back again - remove the last step if you don't care about the commit )</p> <p>Without doing any changes to your local repo, ...
<p>Since you are the only user:</p> <pre><code>git reset --hard HEAD@{1} git push -f git reset --hard HEAD@{1} </code></pre> <p>( basically, go back one commit, force push to the repo, then go back again - remove the last step if you don't care about the commit )</p> <p>Without doing any changes to your local repo, ...
119
git
<h1>Is there a way to rollback my last push to Git?</h1> <blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="https://stackoverflow.com/questions/1270514/undoing-a-git-push">Undoing a 'git push'</a> </p> </blockquote> <p>I have pushed some bad code, and I am the only user of the repository. How ca...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,840
git
# Is there a way to rollback my last push to Git? > **Possible Duplicates:** > [Undoing a 'git push'](https://stackoverflow.com/questions/1270514/undoing-a-git-push) I have pushed some bad code, and I am the only user of the repository. How can I rollback my last commit?
Since you are the only user: ``` git reset --hard HEAD@{1} git push -f git reset --hard HEAD@{1} ``` ( basically, go back one commit, force push to the repo, then go back again - remove the last step if you don't care about the commit ) Without doing any changes to your local repo, you can also do something like: `...
21307793
Set git config values for all child folders
168
2014-01-23 12:11:54
<p>I know that it's possible to set per-repo configs which override the user-level config (i.e. <code>/path/to/my/repo/.gitconfig</code> overrides <code>~/.gitconfig</code>). Is it possible to set git configs which override the user-level settings for all child folders of a given folder? I.e., I have</p> <pre><code>|-...
33,822
1,040,915
2024-06-27 08:07:11
48,088,291
259
2018-01-04 03:33:07
1,091,015
2023-08-11 03:28:22
https://stackoverflow.com/q/21307793
https://stackoverflow.com/a/48088291
<p>As mentioned by <a href="https://stackoverflow.com/a/24463387/1091015">NateEag's edit</a>, git's <a href="https://git-scm.com/docs/git-config#_conditional_includes" rel="noreferrer">Conditional Includes</a> are perfect for this. Since that answer's the one for people on git &lt; 2.13, here's one for those who have n...
<p>As mentioned by <a href="https://stackoverflow.com/a/24463387/1091015">NateEag's edit</a>, git's <a href="https://git-scm.com/docs/git-config#_conditional_includes" rel="noreferrer">Conditional Includes</a> are perfect for this. Since that answer's the one for people on git &lt; 2.13, here's one for those who have n...
119
git
<h1>Set git config values for all child folders</h1> <p>I know that it's possible to set per-repo configs which override the user-level config (i.e. <code>/path/to/my/repo/.gitconfig</code> overrides <code>~/.gitconfig</code>). Is it possible to set git configs which override the user-level settings for all child folde...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,841
git
# Set git config values for all child folders I know that it's possible to set per-repo configs which override the user-level config (i.e. `/path/to/my/repo/.gitconfig` overrides `~/.gitconfig`). Is it possible to set git configs which override the user-level settings for all child folders of a given folder? I.e., I h...
As mentioned by [NateEag's edit](https://stackoverflow.com/a/24463387/1091015), git's [Conditional Includes](https://git-scm.com/docs/git-config#_conditional_includes) are perfect for this. Since that answer's the one for people on git < 2.13, here's one for those who have newer versions. First, create a new config fi...