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
3469741
Remove file from the repository but keep it locally
485
2010-08-12 16:15:34
<p>I have a folder which I'd like to remove in my remote repository. I'd like to delete it, but keep the folder in my computer</p>
132,150
336,945
2018-07-01 03:03:40
3,469,805
845
2010-08-12 16:21:31
198,244
2018-07-01 03:03:40
https://stackoverflow.com/q/3469741
https://stackoverflow.com/a/3469805
<pre><code>git rm --cached -r somedir </code></pre> <p>Will stage the deletion of the directory, but doesn't touch anything on disk. This works also for a file, like: </p> <pre><code>git rm --cached somefile.ext </code></pre> <p>Afterwards you may want to add <code>somedir/</code> or <code>somefile.ext</code> to you...
<pre><code>git rm --cached -r somedir </code></pre> <p>Will stage the deletion of the directory, but doesn't touch anything on disk. This works also for a file, like: </p> <pre><code>git rm --cached somefile.ext </code></pre> <p>Afterwards you may want to add <code>somedir/</code> or <code>somefile.ext</code> to you...
119, 25056, 112901
git, gitignore, git-rm
<h1>Remove file from the repository but keep it locally</h1> <p>I have a folder which I'd like to remove in my remote repository. I'd like to delete it, but keep the folder in my computer</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,098
git
# Remove file from the repository but keep it locally I have a folder which I'd like to remove in my remote repository. I'd like to delete it, but keep the folder in my computer
``` git rm --cached -r somedir ``` Will stage the deletion of the directory, but doesn't touch anything on disk. This works also for a file, like: ``` git rm --cached somefile.ext ``` Afterwards you may want to add `somedir/` or `somefile.ext` to your `.gitignore` file so that git doesn't try to add it back.
8435343
Retrieve the commit log for a specific line in a file?
695
2011-12-08 17:51:47
<p>Is there any way to get git to give you a commit log for just commits that touched a particular <em>line</em> in a file?</p> <p>Like <code>git blame</code>, but <code>git blame</code> will show you the LAST commit that touched a particular line. </p> <p>I'd really like to get a similar log of, not the list of comm...
319,050
307,106
2025-03-31 17:22:36
19,757,493
843
2013-11-03 20:08:22
168,740
2018-01-05 10:36:54
https://stackoverflow.com/q/8435343
https://stackoverflow.com/a/19757493
<p>See also <a href="https://stackoverflow.com/questions/14142609/git-discover-which-commits-ever-touched-a-range-of-lines">Git: discover which commits ever touched a range of lines</a>.</p> <hr> <p><a href="https://github.com/git/git/blob/v1.8.4/Documentation/RelNotes/1.8.4.txt#L210" rel="noreferrer">Since Git 1.8.4...
<p>See also <a href="https://stackoverflow.com/questions/14142609/git-discover-which-commits-ever-touched-a-range-of-lines">Git: discover which commits ever touched a range of lines</a>.</p> <hr> <p><a href="https://github.com/git/git/blob/v1.8.4/Documentation/RelNotes/1.8.4.txt#L210" rel="noreferrer">Since Git 1.8.4...
119
git
<h1>Retrieve the commit log for a specific line in a file?</h1> <p>Is there any way to get git to give you a commit log for just commits that touched a particular <em>line</em> in a file?</p> <p>Like <code>git blame</code>, but <code>git blame</code> will show you the LAST commit that touched a particular line. </p> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,099
git
# Retrieve the commit log for a specific line in a file? Is there any way to get git to give you a commit log for just commits that touched a particular *line* in a file? Like `git blame`, but `git blame` will show you the LAST commit that touched a particular line. I'd really like to get a similar log of, not the l...
See also [Git: discover which commits ever touched a range of lines](https://stackoverflow.com/questions/14142609/git-discover-which-commits-ever-touched-a-range-of-lines). --- [Since Git 1.8.4](https://github.com/git/git/blob/v1.8.4/Documentation/RelNotes/1.8.4.txt#L210), `git log` has [`-L`](https://github.com/git/...
9224754
How to remove origin from git repository
475
2012-02-10 08:21:51
<p>Basic question: How do I disassociate a git repo from the origin from which it was cloned?</p> <p><code>git branch -a</code> shows:</p> <pre><code>* master remotes/origin/HEAD -&gt; origin/master </code></pre> <p>and I want to remove all knowledge of origin, and the associated revisions.</p> <p>Longer question...
630,395
313,842
2023-02-27 22:30:52
9,224,789
835
2012-02-10 08:25:06
148,870
2012-02-10 08:25:06
https://stackoverflow.com/q/9224754
https://stackoverflow.com/a/9224789
<p>Fairly straightforward: </p> <pre><code>git remote rm origin </code></pre> <hr> <p>As for the <code>filter-branch</code> question - just add <code>--prune-empty</code> to your filter branch command and it'll remove any revision that doesn't actually contain any changes in your resulting repo:</p> <pre><code>git ...
<p>Fairly straightforward: </p> <pre><code>git remote rm origin </code></pre> <hr> <p>As for the <code>filter-branch</code> question - just add <code>--prune-empty</code> to your filter branch command and it'll remove any revision that doesn't actually contain any changes in your resulting repo:</p> <pre><code>git ...
119, 6452
git, git-svn
<h1>How to remove origin from git repository</h1> <p>Basic question: How do I disassociate a git repo from the origin from which it was cloned?</p> <p><code>git branch -a</code> shows:</p> <pre><code>* master remotes/origin/HEAD -&gt; origin/master </code></pre> <p>and I want to remove all knowledge of origin, and...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,100
git
# How to remove origin from git repository Basic question: How do I disassociate a git repo from the origin from which it was cloned? `git branch -a` shows: ``` * master remotes/origin/HEAD -> origin/master ``` and I want to remove all knowledge of origin, and the associated revisions. Longer question: I want to...
Fairly straightforward: ``` git remote rm origin ``` --- As for the `filter-branch` question - just add `--prune-empty` to your filter branch command and it'll remove any revision that doesn't actually contain any changes in your resulting repo: ``` git filter-branch --prune-empty --subdirectory-filter path/to/subt...
9392365
How would Git handle a SHA-1 collision on a blob?
610
2012-02-22 09:42:05
<p>This probably never happened in the real-world yet, and may never happen, but let's consider this: say you have a git repository, make a commit, and get very very unlucky: one of the blobs ends up having the same SHA-1 as another that is already in your repository. Question is, how would Git handle this? Simply fail...
89,352
251,248
2021-10-21 06:28:22
34,599,081
834
2016-01-04 20:15:12
5,744,809
2017-06-25 07:41:14
https://stackoverflow.com/q/9392365
https://stackoverflow.com/a/34599081
<p>I did an experiment to find out exactly how Git would behave in this case. This is with version 2.7.9~rc0+next.20151210 (Debian version). I basically just reduced the hash size from 160-bit to 4-bit by applying the following diff and rebuilding git:</p> <pre><code>--- git-2.7.0~rc0+next.20151210.orig/block-sha1/sha...
<p>I did an experiment to find out exactly how Git would behave in this case. This is with version 2.7.9~rc0+next.20151210 (Debian version). I basically just reduced the hash size from 160-bit to 4-bit by applying the following diff and rebuilding git:</p> <pre><code>--- git-2.7.0~rc0+next.20151210.orig/block-sha1/sha...
119, 25940
git, hash-collision
<h1>How would Git handle a SHA-1 collision on a blob?</h1> <p>This probably never happened in the real-world yet, and may never happen, but let's consider this: say you have a git repository, make a commit, and get very very unlucky: one of the blobs ends up having the same SHA-1 as another that is already in your repo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,101
git
# How would Git handle a SHA-1 collision on a blob? This probably never happened in the real-world yet, and may never happen, but let's consider this: say you have a git repository, make a commit, and get very very unlucky: one of the blobs ends up having the same SHA-1 as another that is already in your repository. Q...
I did an experiment to find out exactly how Git would behave in this case. This is with version 2.7.9~rc0+next.20151210 (Debian version). I basically just reduced the hash size from 160-bit to 4-bit by applying the following diff and rebuilding git: ``` --- git-2.7.0~rc0+next.20151210.orig/block-sha1/sha1.c +++ git-2....
1800783
How to compare a local Git branch with its remote branch
1,522
2009-11-25 23:58:17
<p>How can I see the <code>diff</code> between a local branch and a remote branch?</p>
1,445,012
68,183
2025-12-30 22:46:13
1,800,787
832
2009-11-25 23:59:18
145,190
2021-06-13 11:21:43
https://stackoverflow.com/q/1800783
https://stackoverflow.com/a/1800787
<p>To update remote-tracking branches, you need to type <code>git fetch</code> first and then:</p> <pre><code>git diff &lt;mainbranch_path&gt; &lt;remotebranch_path&gt; </code></pre> <p>You can <code>git branch -a</code> to list all branches (local and remote) and then choose the branch name from the list (just remove ...
<p>To update remote-tracking branches, you need to type <code>git fetch</code> first and then:</p> <pre><code>git diff &lt;mainbranch_path&gt; &lt;remotebranch_path&gt; </code></pre> <p>You can <code>git branch -a</code> to list all branches (local and remote) and then choose the branch name from the list (just remove ...
119, 606
diff, git
<h1>How to compare a local Git branch with its remote branch</h1> <p>How can I see the <code>diff</code> between a local branch and a remote branch?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,102
git
# How to compare a local Git branch with its remote branch How can I see the `diff` between a local branch and a remote branch?
To update remote-tracking branches, you need to type `git fetch` first and then: ``` git diff <mainbranch_path> <remotebranch_path> ``` You can `git branch -a` to list all branches (local and remote) and then choose the branch name from the list (just remove `remotes/` from the remote branch name. Example: `git diff...
3745135
Push git commits & tags simultaneously
613
2010-09-19 09:21:47
<p><code>git push --tags</code> is a separate operation to <code>git push</code> since pushing tags should be a conscious choice to avoid accidentally pushing the wrong one. That's fine. But how do I push them both simultaneously / atomically? (<code>git push &amp;&amp; git push --tags</code> is not perfectly atomic.)<...
265,881
4,161
2023-03-07 05:05:32
3,745,250
832
2010-09-19 10:00:59
6,309
2021-03-04 08:13:50
https://stackoverflow.com/q/3745135
https://stackoverflow.com/a/3745250
<h1>Update August 2020</h1> <p>As mentioned originally in <a href="https://stackoverflow.com/a/57842917/6309">this</a> answer by <a href="https://stackoverflow.com/users/8305572/soberich">SoBeRich</a>, and in my <a href="https://stackoverflow.com/a/28523050/6309">own answer</a>, as of <a href="https://github.com/git/gi...
<h1>Update August 2020</h1> <p>As mentioned originally in <a href="https://stackoverflow.com/a/57842917/6309">this</a> answer by <a href="https://stackoverflow.com/users/8305572/soberich">SoBeRich</a>, and in my <a href="https://stackoverflow.com/a/28523050/6309">own answer</a>, as of <a href="https://github.com/git/gi...
119
git
<h1>Push git commits & tags simultaneously</h1> <p><code>git push --tags</code> is a separate operation to <code>git push</code> since pushing tags should be a conscious choice to avoid accidentally pushing the wrong one. That's fine. But how do I push them both simultaneously / atomically? (<code>git push &amp;&amp; g...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,103
git
# Push git commits & tags simultaneously `git push --tags` is a separate operation to `git push` since pushing tags should be a conscious choice to avoid accidentally pushing the wrong one. That's fine. But how do I push them both simultaneously / atomically? (`git push && git push --tags` is not perfectly atomic.)
# Update August 2020 As mentioned originally in [this](https://stackoverflow.com/a/57842917/6309) answer by [SoBeRich](https://stackoverflow.com/users/8305572/soberich), and in my [own answer](https://stackoverflow.com/a/28523050/6309), as of [git 2.4.x](https://github.com/git/git/commit/d0e8e09cd8828b278a56d4ebfc52d6...
13969050
Creating a new empty branch for a new project
439
2012-12-20 09:34:44
<p>We are using a git repository to store our project. We have our branches departing from the original branch. But now we want to create a small new project to track some documentation. For that we would want to create a new empty branch to start storing our files, and I would want other users of the network to clone ...
310,397
1,213,528
2024-01-04 21:52:11
13,969,482
830
2012-12-20 09:57:46
260,885
2014-04-30 23:44:34
https://stackoverflow.com/q/13969050
https://stackoverflow.com/a/13969482
<p>You can create a branch as an orphan:</p> <pre><code>git checkout --orphan &lt;branchname&gt; </code></pre> <p>This will create a new branch with no parents. Then, you can clear the working directory with: </p> <pre><code>git rm --cached -r . </code></pre> <p>and add the documentation files, commit them and push...
<p>You can create a branch as an orphan:</p> <pre><code>git checkout --orphan &lt;branchname&gt; </code></pre> <p>This will create a new branch with no parents. Then, you can clear the working directory with: </p> <pre><code>git rm --cached -r . </code></pre> <p>and add the documentation files, commit them and push...
119, 1879, 76220
branch, git, git-branch
<h1>Creating a new empty branch for a new project</h1> <p>We are using a git repository to store our project. We have our branches departing from the original branch. But now we want to create a small new project to track some documentation. For that we would want to create a new empty branch to start storing our files...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,104
git
# Creating a new empty branch for a new project We are using a git repository to store our project. We have our branches departing from the original branch. But now we want to create a small new project to track some documentation. For that we would want to create a new empty branch to start storing our files, and I w...
You can create a branch as an orphan: ``` git checkout --orphan <branchname> ``` This will create a new branch with no parents. Then, you can clear the working directory with: ``` git rm --cached -r . ``` and add the documentation files, commit them and push them up to github. A pull or fetch will always update th...
9794931
Keep file in a Git repo, but don't track changes
495
2012-03-20 21:04:45
<p>I need to include some files in my GitHub repo, but not track changes on them. How can I accomplish this? An example use case is for a file that includes sensitive user information, such as login credentials.</p> <p>For example, I deploy a new installation of this framework to a new client, I want the following file...
163,197
703,146
2022-08-14 20:10:48
17,410,119
828
2013-07-01 17:20:44
1,277,065
2016-10-12 14:35:55
https://stackoverflow.com/q/9794931
https://stackoverflow.com/a/17410119
<p>git has a different solution to do this. First change the file you do not want to be tracked and use the following command: </p> <pre><code>git update-index --assume-unchanged FILE_NAME </code></pre> <p>and if you want to track the changes again use this command: </p> <pre><code>git update-index --no-assume-uncha...
<p>git has a different solution to do this. First change the file you do not want to be tracked and use the following command: </p> <pre><code>git update-index --assume-unchanged FILE_NAME </code></pre> <p>and if you want to track the changes again use this command: </p> <pre><code>git update-index --no-assume-uncha...
119
git
<h1>Keep file in a Git repo, but don't track changes</h1> <p>I need to include some files in my GitHub repo, but not track changes on them. How can I accomplish this? An example use case is for a file that includes sensitive user information, such as login credentials.</p> <p>For example, I deploy a new installation of...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,105
git
# Keep file in a Git repo, but don't track changes I need to include some files in my GitHub repo, but not track changes on them. How can I accomplish this? An example use case is for a file that includes sensitive user information, such as login credentials. For example, I deploy a new installation of this framework...
git has a different solution to do this. First change the file you do not want to be tracked and use the following command: ``` git update-index --assume-unchanged FILE_NAME ``` and if you want to track the changes again use this command: ``` git update-index --no-assume-unchanged FILE_NAME ``` [git-update-index do...
22289345
Completely cancel a rebase
519
2014-03-09 22:55:32
<p>I performed a rebase like this: </p> <pre><code>git rebase --onto master new_background_processing export_background_processing </code></pre> <p>That didn't do what I wanted it to, so I performed a reset: </p> <pre><code>git reset --hard HEAD@{1} </code></pre> <p>I got my branch back to the state it was, but I r...
582,998
2,757,483
2021-11-18 10:33:00
22,289,400
826
2014-03-09 23:01:03
null
2021-11-18 10:33:00
https://stackoverflow.com/q/22289345
https://stackoverflow.com/a/22289400
<p>Use <code>git rebase --abort</code>. From the <a href="https://www.kernel.org/pub/software/scm/git/docs/git-rebase.html" rel="noreferrer">official Linux kernel documentation for <code>git rebase</code></a>:</p> <pre><code>git rebase --continue | --skip | --abort | --edit-todo | --quit </code></pre>
<p>Use <code>git rebase --abort</code>. From the <a href="https://www.kernel.org/pub/software/scm/git/docs/git-rebase.html" rel="noreferrer">official Linux kernel documentation for <code>git rebase</code></a>:</p> <pre><code>git rebase --continue | --skip | --abort | --edit-todo | --quit </code></pre>
119
git
<h1>Completely cancel a rebase</h1> <p>I performed a rebase like this: </p> <pre><code>git rebase --onto master new_background_processing export_background_processing </code></pre> <p>That didn't do what I wanted it to, so I performed a reset: </p> <pre><code>git reset --hard HEAD@{1} </code></pre> <p>I got my bran...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,106
git
# Completely cancel a rebase I performed a rebase like this: ``` git rebase --onto master new_background_processing export_background_processing ``` That didn't do what I wanted it to, so I performed a reset: ``` git reset --hard HEAD@{1} ``` I got my branch back to the state it was, but I received this message wh...
Use `git rebase --abort`. From the [official Linux kernel documentation for `git rebase`](https://www.kernel.org/pub/software/scm/git/docs/git-rebase.html): ``` git rebase --continue | --skip | --abort | --edit-todo | --quit ```
3697178
Merge (with squash) all changes from another branch as a single commit
673
2010-09-12 23:52:40
<p>In Git, is there a way to merge all changes from one branch into another, but squash to a single commit at the same time? </p> <p>I often work on a new feature in a separate branch and will regularly commit/push - mainly for backup or to transfer what I'm working on to another machine. Mostly those commits say "F...
332,728
77,002
2024-05-15 22:57:14
3,697,263
823
2010-09-13 00:28:33
399,938
2017-12-31 02:48:26
https://stackoverflow.com/q/3697178
https://stackoverflow.com/a/3697263
<p>Another option is <code>git merge --squash &lt;feature branch&gt;</code> then finally do a <code>git commit</code>.</p> <p>From <a href="http://www.kernel.org/pub/software/scm/git/docs/git-merge.html" rel="noreferrer">Git merge</a></p> <blockquote> <p><code>--squash</code></p> <p><code>--no-squash</code> </...
<p>Another option is <code>git merge --squash &lt;feature branch&gt;</code> then finally do a <code>git commit</code>.</p> <p>From <a href="http://www.kernel.org/pub/software/scm/git/docs/git-merge.html" rel="noreferrer">Git merge</a></p> <blockquote> <p><code>--squash</code></p> <p><code>--no-squash</code> </...
119
git
<h1>Merge (with squash) all changes from another branch as a single commit</h1> <p>In Git, is there a way to merge all changes from one branch into another, but squash to a single commit at the same time? </p> <p>I often work on a new feature in a separate branch and will regularly commit/push - mainly for backup or ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,107
git
# Merge (with squash) all changes from another branch as a single commit In Git, is there a way to merge all changes from one branch into another, but squash to a single commit at the same time? I often work on a new feature in a separate branch and will regularly commit/push - mainly for backup or to transfer what I...
Another option is `git merge --squash <feature branch>` then finally do a `git commit`. From [Git merge](http://www.kernel.org/pub/software/scm/git/docs/git-merge.html) > `--squash` > > `--no-squash` > > Produce the working tree and index state as if a real merge > happened (except for the merge > information), but d...
10418975
How to change line-ending settings
951
2012-05-02 17:45:07
<p>Is there a file or menu that will let me change the settings on how to deal with line endings?</p> <p>I read there are 3 options:</p> <ol> <li><p><strong>Checkout Windows-style, commit Unix-style</strong></p> <p>Git will convert LF to CRLF when checking out text files. When committing text files, CRLF will be con...
889,844
465,546
2025-09-09 19:42:48
10,419,350
820
2012-05-02 18:12:26
28,278
2023-06-10 14:45:39
https://stackoverflow.com/q/10418975
https://stackoverflow.com/a/10419350
<p>The normal way to control this is with <code>git config</code></p> <p>For example</p> <pre class="lang-sh prettyprint-override"><code>git config --global core.autocrlf true </code></pre> <p>For details, scroll down in <a href="https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_formatting_and_whit...
<p>The normal way to control this is with <code>git config</code></p> <p>For example</p> <pre class="lang-sh prettyprint-override"><code>git config --global core.autocrlf true </code></pre> <p>For details, scroll down in <a href="https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_formatting_and_whit...
119, 21628
git, msysgit
<h1>How to change line-ending settings</h1> <p>Is there a file or menu that will let me change the settings on how to deal with line endings?</p> <p>I read there are 3 options:</p> <ol> <li><p><strong>Checkout Windows-style, commit Unix-style</strong></p> <p>Git will convert LF to CRLF when checking out text files. ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,108
git
# How to change line-ending settings Is there a file or menu that will let me change the settings on how to deal with line endings? I read there are 3 options: 1. **Checkout Windows-style, commit Unix-style** Git will convert LF to CRLF when checking out text files. When committing text files, CRLF will be co...
The normal way to control this is with `git config` For example ``` git config --global core.autocrlf true ``` For details, scroll down in [this link to Pro Git](https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_formatting_and_whitespace) to the section named "core.autocrlf" --- If you want to ...
11124053
Accidentally committed .idea directory files into git
392
2012-06-20 16:33:01
<p>I have accidentally committed the <code>.idea/</code> directory into git. This is causing conflicts everywhere else I need to checkout my repo. I was wondering how do I remove these files from the remote?</p> <p>I still need these files locally since the Intellij IDE needs them. I just don't want them in the remote...
236,164
836,487
2025-02-05 07:47:42
11,124,105
820
2012-06-20 16:36:01
548,696
2013-09-29 02:29:34
https://stackoverflow.com/q/11124053
https://stackoverflow.com/a/11124105
<h2>Add .idea directory to the list of ignored files</h2> <p>First, add it to <code>.gitignore</code>, so it is not accidentally committed by you (or someone else) again:</p> <pre><code>.idea </code></pre> <h2>Remove it from repository</h2> <p>Second, remove the directory only from the repository, but do not delete...
<h2>Add .idea directory to the list of ignored files</h2> <p>First, add it to <code>.gitignore</code>, so it is not accidentally committed by you (or someone else) again:</p> <pre><code>.idea </code></pre> <h2>Remove it from repository</h2> <p>Second, remove the directory only from the repository, but do not delete...
119, 25056
git, gitignore
<h1>Accidentally committed .idea directory files into git</h1> <p>I have accidentally committed the <code>.idea/</code> directory into git. This is causing conflicts everywhere else I need to checkout my repo. I was wondering how do I remove these files from the remote?</p> <p>I still need these files locally since th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,109
git
# Accidentally committed .idea directory files into git I have accidentally committed the `.idea/` directory into git. This is causing conflicts everywhere else I need to checkout my repo. I was wondering how do I remove these files from the remote? I still need these files locally since the Intellij IDE needs them. ...
## Add .idea directory to the list of ignored files First, add it to `.gitignore`, so it is not accidentally committed by you (or someone else) again: ``` .idea ``` ## Remove it from repository Second, remove the directory only from the repository, but do not delete it locally. To achieve that, do what is listed he...
11623862
fetch in git doesn't get all branches
429
2012-07-24 03:48:32
<p>I have cloned a repository, after which somebody else has created a new branch, which I'd like to start working on. I read the manual, and it seems dead straight easy. Strangely it's not working, and all the posts I've found suggest I'm doing the right thing. So I'll subject myself to the lambasting, because ther...
327,621
1,467,306
2025-04-11 08:15:19
25,941,875
818
2014-09-19 20:25:07
2,250,183
2024-12-18 12:43:53
https://stackoverflow.com/q/11623862
https://stackoverflow.com/a/25941875
<p>The problem can be seen when checking the <code>remote.origin.fetch</code> setting<br /> (The lines starting with <code>$</code> are bash prompts with the commands I typed. The other lines are the resulting output)</p> <pre><code>$ git config --get remote.origin.fetch +refs/heads/master:refs/remotes/origin/master </...
<p>The problem can be seen when checking the <code>remote.origin.fetch</code> setting<br /> (The lines starting with <code>$</code> are bash prompts with the commands I typed. The other lines are the resulting output)</p> <pre><code>$ git config --get remote.origin.fetch +refs/heads/master:refs/remotes/origin/master </...
119, 33720, 76220
git, git-branch, git-fetch
<h1>fetch in git doesn't get all branches</h1> <p>I have cloned a repository, after which somebody else has created a new branch, which I'd like to start working on. I read the manual, and it seems dead straight easy. Strangely it's not working, and all the posts I've found suggest I'm doing the right thing. So I'll...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,110
git
# fetch in git doesn't get all branches I have cloned a repository, after which somebody else has created a new branch, which I'd like to start working on. I read the manual, and it seems dead straight easy. Strangely it's not working, and all the posts I've found suggest I'm doing the right thing. So I'll subject mys...
The problem can be seen when checking the `remote.origin.fetch` setting (The lines starting with `$` are bash prompts with the commands I typed. The other lines are the resulting output) ``` $ git config --get remote.origin.fetch +refs/heads/master:refs/remotes/origin/master ``` As you can see, in my case, the remo...
14759748
How to stash only staged changes in Git?
857
2013-02-07 19:50:04
<p>Is there a way I can stash just my staged changes? The scenario I'm having issues with is when I've worked on several bugs at a given time, and have several unstaged changes. I'd like to be able to stage these files individually, create my .patch files, and stash them away until the code is approved. This way, when ...
354,481
1,143,724
2024-06-25 19:31:31
32,951,373
817
2015-10-05 14:42:18
2,725,435
2023-03-01 07:10:57
https://stackoverflow.com/q/14759748
https://stackoverflow.com/a/32951373
<p>Yes, It's possible with <strong>DOUBLE STASH</strong></p> <ol> <li>Stage all your files that you need to stash.</li> <li>Run <code>git stash --keep-index</code>. This command will create a stash with <strong>ALL</strong> of your changes (<em>staged and unstaged</em>), but will leave the staged changes in your workin...
<p>Yes, It's possible with <strong>DOUBLE STASH</strong></p> <ol> <li>Stage all your files that you need to stash.</li> <li>Run <code>git stash --keep-index</code>. This command will create a stash with <strong>ALL</strong> of your changes (<em>staged and unstaged</em>), but will leave the staged changes in your workin...
119, 13091
git, git-stash
<h1>How to stash only staged changes in Git?</h1> <p>Is there a way I can stash just my staged changes? The scenario I'm having issues with is when I've worked on several bugs at a given time, and have several unstaged changes. I'd like to be able to stage these files individually, create my .patch files, and stash the...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,111
git
# How to stash only staged changes in Git? Is there a way I can stash just my staged changes? The scenario I'm having issues with is when I've worked on several bugs at a given time, and have several unstaged changes. I'd like to be able to stage these files individually, create my .patch files, and stash them away un...
Yes, It's possible with **DOUBLE STASH** 1. Stage all your files that you need to stash. 2. Run `git stash --keep-index`. This command will create a stash with **ALL** of your changes (*staged and unstaged*), but will leave the staged changes in your working directory (still in state staged). 3. Run `git stash push -m...
6564257
Can't ignore UserInterfaceState.xcuserstate
385
2011-07-03 17:05:31
<p>I'm using Git for Xcode 4 project version control. I've explicitly added <code>ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate</code> to <code>.gitignore</code>, but Git it won't ignore it. Any ideas why this is so?</p>
152,797
389,569
2025-03-19 08:13:27
6,565,909
816
2011-07-03 22:25:51
214,790
2017-04-30 18:11:35
https://stackoverflow.com/q/6564257
https://stackoverflow.com/a/6565909
<p>Git is probably already tracking the file.</p> <p>From the <a href="http://git-scm.com/docs/gitignore" rel="noreferrer">gitignore docs</a>:</p> <blockquote> <p>To stop tracking a file that is currently tracked, use <em>git rm --cached</em>.</p> </blockquote> <p>Use this, replacing <code>[project]</code> and <co...
<p>Git is probably already tracking the file.</p> <p>From the <a href="http://git-scm.com/docs/gitignore" rel="noreferrer">gitignore docs</a>:</p> <blockquote> <p>To stop tracking a file that is currently tracked, use <em>git rm --cached</em>.</p> </blockquote> <p>Use this, replacing <code>[project]</code> and <co...
119, 908, 25056, 59704
git, gitignore, xcode, xcode4
<h1>Can't ignore UserInterfaceState.xcuserstate</h1> <p>I'm using Git for Xcode 4 project version control. I've explicitly added <code>ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate</code> to <code>.gitignore</code>, but Git it won't ignore it. Any ideas w...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,112
git
# Can't ignore UserInterfaceState.xcuserstate I'm using Git for Xcode 4 project version control. I've explicitly added `ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate` to `.gitignore`, but Git it won't ignore it. Any ideas why this is so?
Git is probably already tracking the file. From the [gitignore docs](http://git-scm.com/docs/gitignore): > To stop tracking a file that is currently tracked, use *git rm --cached*. Use this, replacing `[project]` and `[username]` with your info: ``` git rm --cached [project].xcodeproj/project.xcworkspace/xcuserdata...
17454235
How to Git stash pop specific stash in 1.8.3?
611
2013-07-03 17:12:17
<p>I just upgraded Git. I'm on Git version 1.8.3.</p> <p>This morning I tried to unstash a change 1 deep in the stack.</p> <p>I ran <code>git stash pop stash@{1}</code> and got this error.</p> <blockquote> <p>fatal: ambiguous argument 'stash@1': unknown revision or path not in the working tree. Use '--' to...
573,629
762,889
2024-10-15 22:54:34
17,454,945
813
2013-07-03 17:51:35
887,124
2020-04-01 20:53:56
https://stackoverflow.com/q/17454235
https://stackoverflow.com/a/17454945
<pre><code>git stash apply n </code></pre> <p>works as of git version 2.11</p> <p>Original answer, possibly helping to debug issues with the older syntax involving shell escapes:</p> <p>As pointed out previously, the curly braces may require escaping or quoting depending on your OS, shell, etc.</p> <p>See "<a href=...
<pre><code>git stash apply n </code></pre> <p>works as of git version 2.11</p> <p>Original answer, possibly helping to debug issues with the older syntax involving shell escapes:</p> <p>As pointed out previously, the curly braces may require escaping or quoting depending on your OS, shell, etc.</p> <p>See "<a href=...
119, 4804, 13091
escaping, git, git-stash
<h1>How to Git stash pop specific stash in 1.8.3?</h1> <p>I just upgraded Git. I'm on Git version 1.8.3.</p> <p>This morning I tried to unstash a change 1 deep in the stack.</p> <p>I ran <code>git stash pop stash@{1}</code> and got this error.</p> <blockquote> <p>fatal: ambiguous argument 'stash@1': unknown revisi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,113
git
# How to Git stash pop specific stash in 1.8.3? I just upgraded Git. I'm on Git version 1.8.3. This morning I tried to unstash a change 1 deep in the stack. I ran `git stash pop stash@{1}` and got this error. > fatal: ambiguous argument 'stash@1': unknown revision or path not in > the working tree. > Use '--' to se...
``` git stash apply n ``` works as of git version 2.11 Original answer, possibly helping to debug issues with the older syntax involving shell escapes: As pointed out previously, the curly braces may require escaping or quoting depending on your OS, shell, etc. See "[stash@{1} is ambiguous?](https://stackoverflow.c...
3636914
How can I see what I am about to push with git?
728
2010-09-03 14:51:54
<p>Is there a way to see what would be pushed if I did a <code>git push</code> command?</p> <p>What I'm picturing is something like the "Files Changed" tab of Github's "pull request" feature. When I issue a pull request, I can look and see what will be pulled in if they accept my pull request: <img src="https://i.ssta...
673,332
58
2020-10-13 12:01:12
3,637,039
811
2010-09-03 15:06:24
58,808
2015-03-18 09:10:46
https://stackoverflow.com/q/3636914
https://stackoverflow.com/a/3637039
<p><strong>For a list of files to be pushed, run:</strong></p> <pre><code>git diff --stat --cached [remote/branch] </code></pre> <p><em>example:</em> </p> <pre><code>git diff --stat --cached origin/master </code></pre> <p><strong>For the code diff of the files to be pushed, run:</strong></p> <pre><code>git diff [r...
<p><strong>For a list of files to be pushed, run:</strong></p> <pre><code>git diff --stat --cached [remote/branch] </code></pre> <p><em>example:</em> </p> <pre><code>git diff --stat --cached origin/master </code></pre> <p><strong>For the code diff of the files to be pushed, run:</strong></p> <pre><code>git diff [r...
119
git
<h1>How can I see what I am about to push with git?</h1> <p>Is there a way to see what would be pushed if I did a <code>git push</code> command?</p> <p>What I'm picturing is something like the "Files Changed" tab of Github's "pull request" feature. When I issue a pull request, I can look and see what will be pulled in...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,114
git
# How can I see what I am about to push with git? Is there a way to see what would be pushed if I did a `git push` command? What I'm picturing is something like the "Files Changed" tab of Github's "pull request" feature. When I issue a pull request, I can look and see what will be pulled in if they accept my pull req...
**For a list of files to be pushed, run:** ``` git diff --stat --cached [remote/branch] ``` *example:* ``` git diff --stat --cached origin/master ``` **For the code diff of the files to be pushed, run:** ``` git diff [remote repo/branch] ``` **To see full file paths of the files that will change, run:** ``` git ...
4404444
How do I "git blame" a deleted line?
644
2010-12-10 00:05:20
<p><code>git blame</code> is great for modified and added lines, but how can I find when a line that existed in a specific previous commit was eventually deleted. I'm thinking <code>bisect</code>, but I was hoping for something handier.</p> <p>(Before you ask: in this case, I just did a <code>git log -p</code> and se...
118,613
238,884
2023-04-13 08:44:28
4,404,551
810
2010-12-10 00:26:08
119,963
2015-03-29 23:41:14
https://stackoverflow.com/q/4404444
https://stackoverflow.com/a/4404551
<p>If you know the contents of the line, this is an ideal use case for:</p> <pre><code>git log -S &lt;string&gt; path/to/file </code></pre> <p>which shows you commits which introduce or remove an instance of that string. There's also the <code>-G&lt;regex&gt;</code> which does the same thing with regular expressions!...
<p>If you know the contents of the line, this is an ideal use case for:</p> <pre><code>git log -S &lt;string&gt; path/to/file </code></pre> <p>which shows you commits which introduce or remove an instance of that string. There's also the <code>-G&lt;regex&gt;</code> which does the same thing with regular expressions!...
119
git
<h1>How do I "git blame" a deleted line?</h1> <p><code>git blame</code> is great for modified and added lines, but how can I find when a line that existed in a specific previous commit was eventually deleted. I'm thinking <code>bisect</code>, but I was hoping for something handier.</p> <p>(Before you ask: in this cas...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,116
git
# How do I "git blame" a deleted line? `git blame` is great for modified and added lines, but how can I find when a line that existed in a specific previous commit was eventually deleted. I'm thinking `bisect`, but I was hoping for something handier. (Before you ask: in this case, I just did a `git log -p` and search...
If you know the contents of the line, this is an ideal use case for: ``` git log -S <string> path/to/file ``` which shows you commits which introduce or remove an instance of that string. There's also the `-G<regex>` which does the same thing with regular expressions! See `man git-log` and search for the `-G` and `-S...
37805621
Change email address in Git
481
2016-06-14 07:29:41
<p>I have a project hosted in Git stash (now rebranded as <a href="https://confluence.atlassian.com/bitbucketserver/bitbucket-rebrand-faq-779298912.html" rel="noreferrer">Bitbucket Server</a>). It is built using Jenkins. Now I made a typo while installing my Git locally. Like <code>@ab.example</code> instead of <code>@...
661,246
1,095,863
2025-03-12 12:01:19
37,805,844
807
2016-06-14 07:39:48
3,280,271
2023-05-17 10:05:53
https://stackoverflow.com/q/37805621
https://stackoverflow.com/a/37805844
<h3>Locally set email-address (separately for each repository)</h3> <ol> <li><p>Open Git Bash.</p> </li> <li><p>Change the current working directory to the local repository in which you want to set your Git config email.</p> </li> <li><p>Set your email address with the following command:</p> </li> </ol> <pre class="lan...
<h3>Locally set email-address (separately for each repository)</h3> <ol> <li><p>Open Git Bash.</p> </li> <li><p>Change the current working directory to the local repository in which you want to set your Git config email.</p> </li> <li><p>Set your email address with the following command:</p> </li> </ol> <pre class="lan...
119, 146, 64999
email, git, jenkins
<h1>Change email address in Git</h1> <p>I have a project hosted in Git stash (now rebranded as <a href="https://confluence.atlassian.com/bitbucketserver/bitbucket-rebrand-faq-779298912.html" rel="noreferrer">Bitbucket Server</a>). It is built using Jenkins. Now I made a typo while installing my Git locally. Like <code>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,117
git
# Change email address in Git I have a project hosted in Git stash (now rebranded as [Bitbucket Server](https://confluence.atlassian.com/bitbucketserver/bitbucket-rebrand-faq-779298912.html)). It is built using Jenkins. Now I made a typo while installing my Git locally. Like `@ab.example` instead of `@abc.example` Af...
### Locally set email-address (separately for each repository) 1. Open Git Bash. 2. Change the current working directory to the local repository in which you want to set your Git config email. 3. Set your email address with the following command: ``` git config user.email "your_email@abc.example" ``` 4. Confirm that...
6934752
Combining multiple commits before pushing in Git
523
2011-08-04 00:04:00
<p>I have a bunch of commits on my local repository which are thematically similar. I'd like to combine them into a single commit before pushing up to a remote. How do I do it? I think <code>rebase</code> does this, but I can't make sense of the docs.</p>
432,993
288,843
2022-05-21 03:34:51
6,934,882
804
2011-08-04 00:27:40
303,056
2017-08-25 21:28:50
https://stackoverflow.com/q/6934752
https://stackoverflow.com/a/6934882
<p>What you want to do is referred to as "squashing" in git. There are lots of options when you're doing this (too many?) but if you just want to merge all of your unpushed commits into a single commit, do this:</p> <pre><code>git rebase -i origin/master </code></pre> <p>This will bring up your text editor (<code>-i...
<p>What you want to do is referred to as "squashing" in git. There are lots of options when you're doing this (too many?) but if you just want to merge all of your unpushed commits into a single commit, do this:</p> <pre><code>git rebase -i origin/master </code></pre> <p>This will bring up your text editor (<code>-i...
119, 98455
git, git-squash
<h1>Combining multiple commits before pushing in Git</h1> <p>I have a bunch of commits on my local repository which are thematically similar. I'd like to combine them into a single commit before pushing up to a remote. How do I do it? I think <code>rebase</code> does this, but I can't make sense of the docs.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,118
git
# Combining multiple commits before pushing in Git I have a bunch of commits on my local repository which are thematically similar. I'd like to combine them into a single commit before pushing up to a remote. How do I do it? I think `rebase` does this, but I can't make sense of the docs.
What you want to do is referred to as "squashing" in git. There are lots of options when you're doing this (too many?) but if you just want to merge all of your unpushed commits into a single commit, do this: ``` git rebase -i origin/master ``` This will bring up your text editor (`-i` is for "interactive") with a fi...
2928584
How to grep (search through) committed code in the Git history
1,995
2010-05-28 11:36:06
<p>I have deleted a file or some code in a file sometime in the past. Can I search through the content (not just the commit messages)?</p> <p>A very poor solution is to grep the log:</p> <pre class="lang-none prettyprint-override"><code>git log -p | grep &lt;pattern&gt; </code></pre> <p>However, this doesn't return the...
699,047
235,297
2025-12-12 17:05:26
2,928,721
797
2010-05-28 11:57:01
6,309
2024-01-29 16:17:12
https://stackoverflow.com/q/2928584
https://stackoverflow.com/a/2928721
<p>You should use the <a href="https://git-scm.com/docs/git-log#Documentation/git-log.txt--Sltstringgt" rel="noreferrer">pickaxe (<code>-S</code>)</a> option of <a href="http://git-scm.com/docs/git-log" rel="noreferrer"><code>git log</code></a>.</p> <p>To search for <code>Foo</code>:</p> <pre class="lang-none prettypri...
<p>You should use the <a href="https://git-scm.com/docs/git-log#Documentation/git-log.txt--Sltstringgt" rel="noreferrer">pickaxe (<code>-S</code>)</a> option of <a href="http://git-scm.com/docs/git-log" rel="noreferrer"><code>git log</code></a>.</p> <p>To search for <code>Foo</code>:</p> <pre class="lang-none prettypri...
119, 606, 1271
diff, git, grep
<h1>How to grep (search through) committed code in the Git history</h1> <p>I have deleted a file or some code in a file sometime in the past. Can I search through the content (not just the commit messages)?</p> <p>A very poor solution is to grep the log:</p> <pre class="lang-none prettyprint-override"><code>git log -p ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,121
git
# How to grep (search through) committed code in the Git history I have deleted a file or some code in a file sometime in the past. Can I search through the content (not just the commit messages)? A very poor solution is to grep the log: ``` git log -p | grep <pattern> ``` However, this doesn't return the commit ha...
You should use the [pickaxe (`-S`)](https://git-scm.com/docs/git-log#Documentation/git-log.txt--Sltstringgt) option of [`git log`](http://git-scm.com/docs/git-log). To search for `Foo`: ``` git log -SFoo -- path_containing_change git log -SFoo --since=2009.1.1 --until=2010.1.1 -- path_containing_change ``` See [Git ...
4649356
How do I run git log to see changes only for a specific branch?
616
2011-01-10 17:04:40
<p>I have a local branch tracking the remote/master branch. After running <code>git-pull</code> and <code>git-log</code>, the log will show all commits in the remote tracking branch as well as the current branch. However, because there were so many changes made to the remote branch, I need to see just the commits made ...
556,749
463,038
2024-09-26 05:41:16
4,649,377
795
2011-01-10 17:07:39
238,886
2023-07-19 15:48:50
https://stackoverflow.com/q/4649356
https://stackoverflow.com/a/4649377
<h1>Using <code>git log</code></h1> <p>Assuming that your branch was created off of <code>master</code>, then <em>while in the branch</em> (that is, you have the branch checked out):</p> <pre><code>git log master.. </code></pre> <p>If you are not in the branch, then you can add the branch name to the &quot;git log&quot...
<h1>Using <code>git log</code></h1> <p>Assuming that your branch was created off of <code>master</code>, then <em>while in the branch</em> (that is, you have the branch checked out):</p> <pre><code>git log master.. </code></pre> <p>If you are not in the branch, then you can add the branch name to the &quot;git log&quot...
119, 1879, 47913, 76220
branch, git, git-branch, git-log
<h1>How do I run git log to see changes only for a specific branch?</h1> <p>I have a local branch tracking the remote/master branch. After running <code>git-pull</code> and <code>git-log</code>, the log will show all commits in the remote tracking branch as well as the current branch. However, because there were so man...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,122
git
# How do I run git log to see changes only for a specific branch? I have a local branch tracking the remote/master branch. After running `git-pull` and `git-log`, the log will show all commits in the remote tracking branch as well as the current branch. However, because there were so many changes made to the remote br...
# Using `git log` Assuming that your branch was created off of `master`, then *while in the branch* (that is, you have the branch checked out): ``` git log master.. ``` If you are not in the branch, then you can add the branch name to the "git log" command, like this: ``` git log master..branchname ``` If your bra...
3689838
Git: Difference between HEAD, working tree and index?
684
2010-09-11 04:53:04
<p>Can someone tell me the difference between HEAD, working tree and index, in Git?</p> <p>From what I understand, they are all names for different branches. Is my assumption correct?</p> <p>I found this:</p> <blockquote> <p>A single git repository can track an arbitrary number of branches, but your working tree is ass...
231,564
465,590
2025-07-21 14:45:34
3,690,796
793
2010-09-11 11:26:05
6,309
2025-07-21 14:45:34
https://stackoverflow.com/q/3689838
https://stackoverflow.com/a/3690796
<p>A few other good references on those topics:</p> <ul> <li><p><a href="http://blog.osteele.com/2008/05/my-git-workflow/" rel="noreferrer">My Git Workflow</a></p> <p><a href="https://i.sstatic.net/cZkcV.jpg" rel="noreferrer"><img src="https://i.sstatic.net/cZkcV.jpg" alt="workflow" /></a></p> <blockquote> <p>I use the...
<p>A few other good references on those topics:</p> <ul> <li><p><a href="http://blog.osteele.com/2008/05/my-git-workflow/" rel="noreferrer">My Git Workflow</a></p> <p><a href="https://i.sstatic.net/cZkcV.jpg" rel="noreferrer"><img src="https://i.sstatic.net/cZkcV.jpg" alt="workflow" /></a></p> <blockquote> <p>I use the...
119
git
<h1>Git: Difference between HEAD, working tree and index?</h1> <p>Can someone tell me the difference between HEAD, working tree and index, in Git?</p> <p>From what I understand, they are all names for different branches. Is my assumption correct?</p> <p>I found this:</p> <blockquote> <p>A single git repository can trac...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,123
git
# Git: Difference between HEAD, working tree and index? Can someone tell me the difference between HEAD, working tree and index, in Git? From what I understand, they are all names for different branches. Is my assumption correct? I found this: > A single git repository can track an arbitrary number of branches, but...
A few other good references on those topics: - [My Git Workflow](http://blog.osteele.com/2008/05/my-git-workflow/) [![workflow](https://i.sstatic.net/cZkcV.jpg)](https://i.sstatic.net/cZkcV.jpg) > I use the index as a *checkpoint*. > > When I'm about to make a change that might go awry — when I want to explo...
9813816
Git pull after forced update
548
2012-03-21 22:30:45
<p>I just squashed some commits with <code>git rebase</code> and did a <code>git push --force</code> (which is evil, I know).</p> <p>Now the other software engineers have a different history and when they do a <code>git pull</code>, Git will merge. Is there a way to fix this, except doing a <code>rm my-repo; git clone...
235,745
773,690
2023-05-15 08:37:48
9,813,888
793
2012-03-21 22:36:54
761,202
2021-09-09 09:49:16
https://stackoverflow.com/q/9813816
https://stackoverflow.com/a/9813888
<p>To receive the new commits</p> <pre><code>git fetch </code></pre> <p><strong>Reset</strong></p> <p>You can reset the commit for a local branch using <code>git reset</code>.</p> <p>To change the commit of a local branch:</p> <pre><code>git reset origin/main --hard </code></pre> <p>Be careful though, as the documentat...
<p>To receive the new commits</p> <pre><code>git fetch </code></pre> <p><strong>Reset</strong></p> <p>You can reset the commit for a local branch using <code>git reset</code>.</p> <p>To change the commit of a local branch:</p> <pre><code>git reset origin/main --hard </code></pre> <p>Be careful though, as the documentat...
119, 28896
git, git-pull
<h1>Git pull after forced update</h1> <p>I just squashed some commits with <code>git rebase</code> and did a <code>git push --force</code> (which is evil, I know).</p> <p>Now the other software engineers have a different history and when they do a <code>git pull</code>, Git will merge. Is there a way to fix this, exce...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,124
git
# Git pull after forced update I just squashed some commits with `git rebase` and did a `git push --force` (which is evil, I know). Now the other software engineers have a different history and when they do a `git pull`, Git will merge. Is there a way to fix this, except doing a `rm my-repo; git clone git@example.org...
To receive the new commits ``` git fetch ``` **Reset** You can reset the commit for a local branch using `git reset`. To change the commit of a local branch: ``` git reset origin/main --hard ``` Be careful though, as the documentation puts it: > Resets the index and working tree. Any changes to tracked files in ...
15432052
What is the meaning of git reset --hard origin/master?
408
2013-03-15 12:06:57
<p>I did a <code>git pull</code> and got an error: </p> <blockquote> <p>The following working tree files would be overwritten by merge... Please move or remove them before you can merge.</p> </blockquote> <p>To resolve this I did the following:</p> <pre><code>git fetch git reset --hard origin/master </code></pre...
738,534
1,154,018
2025-06-19 19:44:02
15,432,250
785
2013-03-15 12:17:04
19,563
2013-03-15 12:17:04
https://stackoverflow.com/q/15432052
https://stackoverflow.com/a/15432250
<pre><code>git reset --hard origin/master </code></pre> <p>says: throw away all my staged and unstaged changes, forget everything on my current local branch and make it exactly the same as <code>origin/master</code>.</p> <p>You probably wanted to ask this before you ran the command. The destructive nature is hinted a...
<pre><code>git reset --hard origin/master </code></pre> <p>says: throw away all my staged and unstaged changes, forget everything on my current local branch and make it exactly the same as <code>origin/master</code>.</p> <p>You probably wanted to ask this before you ran the command. The destructive nature is hinted a...
119, 456, 51381
git, git-reset, version-control
<h1>What is the meaning of git reset --hard origin/master?</h1> <p>I did a <code>git pull</code> and got an error: </p> <blockquote> <p>The following working tree files would be overwritten by merge... Please move or remove them before you can merge.</p> </blockquote> <p>To resolve this I did the following:</p> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,125
git
# What is the meaning of git reset --hard origin/master? I did a `git pull` and got an error: > The following working tree files would be overwritten by merge... > Please move or remove them before you can merge. To resolve this I did the following: ``` git fetch git reset --hard origin/master ``` Now when I do `g...
``` git reset --hard origin/master ``` says: throw away all my staged and unstaged changes, forget everything on my current local branch and make it exactly the same as `origin/master`. You probably wanted to ask this before you ran the command. The destructive nature is hinted at by using the same words as in "hard ...
4630312
Reset all changes after last commit in git
454
2011-01-07 21:09:19
<p>How can I undo <em>every</em> change made to my directory after the last commit, including deleting added files, resetting modified files, and adding back deleted files?</p>
304,466
320,615
2020-09-19 10:23:04
4,630,316
783
2011-01-07 21:10:29
176,922
2020-07-16 19:08:13
https://stackoverflow.com/q/4630312
https://stackoverflow.com/a/4630316
<p><strong>First, reset any changes</strong></p> <p>This will undo any changes you've made to tracked files and restore deleted files:</p> <pre><code>git reset HEAD --hard </code></pre> <p><strong>Second, remove new files</strong></p> <p>This will delete any new files that were added since the last commit:</p> <pre><co...
<p><strong>First, reset any changes</strong></p> <p>This will undo any changes you've made to tracked files and restore deleted files:</p> <pre><code>git reset HEAD --hard </code></pre> <p><strong>Second, remove new files</strong></p> <p>This will delete any new files that were added since the last commit:</p> <pre><co...
119, 34403, 51381, 53850
git, git-commit, git-reset, git-revert
<h1>Reset all changes after last commit in git</h1> <p>How can I undo <em>every</em> change made to my directory after the last commit, including deleting added files, resetting modified files, and adding back deleted files?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,126
git
# Reset all changes after last commit in git How can I undo *every* change made to my directory after the last commit, including deleting added files, resetting modified files, and adding back deleted files?
**First, reset any changes** This will undo any changes you've made to tracked files and restore deleted files: ``` git reset HEAD --hard ``` **Second, remove new files** This will delete any new files that were added since the last commit: ``` git clean -fd ``` Files that are not tracked due to `.gitignore` are ...
2314652
Is it possible to move/rename files in Git and maintain their history?
866
2010-02-22 22:11:07
<p>I would like to rename/move a project subtree in Git moving it from</p> <pre><code>/project/xyz </code></pre> <p>to </p> <pre><code>/components/xyz </code></pre> <p>If I use a plain <code>git mv project components</code>, then all the commit history for the <code>xyz project</code> gets lost. Is there a way to m...
518,283
106,801
2023-12-20 07:09:34
2,314,757
782
2010-02-22 22:26:14
20,138
2023-06-07 16:36:41
https://stackoverflow.com/q/2314652
https://stackoverflow.com/a/2314757
<p>Git detects renames rather than persisting the operation with the commit, so whether you use <code>git mv</code> or <code>mv</code> doesn't matter, as long as the move operation is committed separately from any changes to the file.</p> <p>The <code>log</code> command takes a <a href="http://git-scm.com/docs/git-log#...
<p>Git detects renames rather than persisting the operation with the commit, so whether you use <code>git mv</code> or <code>mv</code> doesn't matter, as long as the move operation is committed separately from any changes to the file.</p> <p>The <code>log</code> command takes a <a href="http://git-scm.com/docs/git-log#...
119, 4510, 12668
git, mv, rename
<h1>Is it possible to move/rename files in Git and maintain their history?</h1> <p>I would like to rename/move a project subtree in Git moving it from</p> <pre><code>/project/xyz </code></pre> <p>to </p> <pre><code>/components/xyz </code></pre> <p>If I use a plain <code>git mv project components</code>, then all th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,127
git
# Is it possible to move/rename files in Git and maintain their history? I would like to rename/move a project subtree in Git moving it from ``` /project/xyz ``` to ``` /components/xyz ``` If I use a plain `git mv project components`, then all the commit history for the `xyz project` gets lost. Is there a way to m...
Git detects renames rather than persisting the operation with the commit, so whether you use `git mv` or `mv` doesn't matter, as long as the move operation is committed separately from any changes to the file. The `log` command takes a [`--follow`](http://git-scm.com/docs/git-log#Documentation/git-log.txt---follow) ar...
31281679
How to undo local changes to a specific file
441
2015-07-08 00:37:11
<p>I'm trying to undo local changes to a specific file. Nothing has been committed.</p> <p>When I want to revert all changes, I can perform <code>git revert --reset HEAD</code>. However, in this case, I don't want to revert all changes to all files.</p> <p>Its not clear or obvious to me how to revert just a file, eve...
440,049
608,639
2020-05-24 03:05:11
31,281,748
781
2015-07-08 00:44:11
1,263,211
2020-05-24 03:05:11
https://stackoverflow.com/q/31281679
https://stackoverflow.com/a/31281748
<p>You don't want <code>git revert</code>. That undoes a previous commit. You want <code>git checkout</code> to get git's version of the file from master.</p> <p><code>git checkout -- filename.txt</code></p> <p>In general, when you want to perform a git operation on a single file, use <code>-- filename</code>.</p> <...
<p>You don't want <code>git revert</code>. That undoes a previous commit. You want <code>git checkout</code> to get git's version of the file from master.</p> <p><code>git checkout -- filename.txt</code></p> <p>In general, when you want to perform a git operation on a single file, use <code>-- filename</code>.</p> <...
119, 34403
git, git-revert
<h1>How to undo local changes to a specific file</h1> <p>I'm trying to undo local changes to a specific file. Nothing has been committed.</p> <p>When I want to revert all changes, I can perform <code>git revert --reset HEAD</code>. However, in this case, I don't want to revert all changes to all files.</p> <p>Its not...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,128
git
# How to undo local changes to a specific file I'm trying to undo local changes to a specific file. Nothing has been committed. When I want to revert all changes, I can perform `git revert --reset HEAD`. However, in this case, I don't want to revert all changes to all files. Its not clear or obvious to me how to rev...
You don't want `git revert`. That undoes a previous commit. You want `git checkout` to get git's version of the file from master. `git checkout -- filename.txt` In general, when you want to perform a git operation on a single file, use `-- filename`. --- - [git-checkout Documentation](https://git-scm.com/docs/git-c...
6925099
git stash changes apply to new branch?
501
2011-08-03 10:32:53
<p>I was working on master branch, made some changes and then stashed them. Now, my master is at HEAD.</p> <p>But now, I want to retrieve these changes but to a new branch which branches from the HEAD version of the master branch. </p> <p>How do i do this ?</p>
404,918
278,851
2023-12-12 12:51:24
6,925,136
779
2011-08-03 10:36:23
147,407
2023-12-12 12:51:24
https://stackoverflow.com/q/6925099
https://stackoverflow.com/a/6925136
<p>The usual, standard procedure is:</p> <ul> <li>make changes</li> <li><code>git stash save</code></li> <li><code>git branch xxx HEAD</code></li> <li><code>git checkout xxx</code></li> <li><code>git stash pop</code></li> </ul> <p>Shorter:</p> <ul> <li>make changes</li> <li><code>git stash</code></li> <li><code>git che...
<p>The usual, standard procedure is:</p> <ul> <li>make changes</li> <li><code>git stash save</code></li> <li><code>git branch xxx HEAD</code></li> <li><code>git checkout xxx</code></li> <li><code>git stash pop</code></li> </ul> <p>Shorter:</p> <ul> <li>make changes</li> <li><code>git stash</code></li> <li><code>git che...
119
git
<h1>git stash changes apply to new branch?</h1> <p>I was working on master branch, made some changes and then stashed them. Now, my master is at HEAD.</p> <p>But now, I want to retrieve these changes but to a new branch which branches from the HEAD version of the master branch. </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,129
git
# git stash changes apply to new branch? I was working on master branch, made some changes and then stashed them. Now, my master is at HEAD. But now, I want to retrieve these changes but to a new branch which branches from the HEAD version of the master branch. How do i do this ?
The usual, standard procedure is: - make changes - `git stash save` - `git branch xxx HEAD` - `git checkout xxx` - `git stash pop` Shorter: - make changes - `git stash` - `git checkout -b xxx` - `git stash pop`
2517339
How can I restore the permissions of files and directories within Git if they have been modified?
394
2010-03-25 16:26:32
<p>I have a Git checkout. All the file permissions are different than what Git thinks they should be therefore they all show up as modified.</p> <p>Without touching the content of the files (just want to modify the permissions), how do I set all the files permissions to what Git thinks they should be?</p>
166,552
285,546
2025-06-03 15:12:49
4,408,378
778
2010-12-10 11:31:53
450,383
2025-03-30 19:47:03
https://stackoverflow.com/q/2517339
https://stackoverflow.com/a/4408378
<p>Git keeps track of file permissions and exposes permission changes when creating patches using <code>git diff -p</code>. So all we need is:</p> <ol> <li>create a reverse patch</li> <li>include only the permission changes</li> <li>apply the patch to our working copy</li> </ol> <p>As a one-liner (run from the reposito...
<p>Git keeps track of file permissions and exposes permission changes when creating patches using <code>git diff -p</code>. So all we need is:</p> <ol> <li>create a reverse patch</li> <li>include only the permission changes</li> <li>apply the patch to our working copy</li> </ol> <p>As a one-liner (run from the reposito...
119, 2120, 5310
file, file-permissions, git
<h1>How can I restore the permissions of files and directories within Git if they have been modified?</h1> <p>I have a Git checkout. All the file permissions are different than what Git thinks they should be therefore they all show up as modified.</p> <p>Without touching the content of the files (just want to modify th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,130
git
# How can I restore the permissions of files and directories within Git if they have been modified? I have a Git checkout. All the file permissions are different than what Git thinks they should be therefore they all show up as modified. Without touching the content of the files (just want to modify the permissions),...
Git keeps track of file permissions and exposes permission changes when creating patches using `git diff -p`. So all we need is: 1. create a reverse patch 2. include only the permission changes 3. apply the patch to our working copy As a one-liner (run from the repository's root directory): ``` git diff -p -R --no-e...
914939
Simple tool to 'accept theirs' or 'accept mine' on a whole file using git
550
2009-05-27 10:06:52
<p>I don't want a visual merge tool, and I also don't want to have to vi the conflicted file and manually choose the between HEAD (mine) and the imported change (theirs). Most of the time I either want all of their changes or all of mine. Commonly this is because my change made it upsteam and is coming back to me thr...
396,925
110,296
2022-06-10 13:02:15
917,623
774
2009-05-27 19:40:14
46,058
2021-01-10 19:30:12
https://stackoverflow.com/q/914939
https://stackoverflow.com/a/917623
<p>The solution is very simple. <code>git checkout &lt;filename&gt;</code> tries to check out file from <strong>the index</strong>, and therefore fails on merge.</p> <p>What you need to do is (i.e. checkout a <strong>commit</strong>):</p> <p><strong>To checkout your own version</strong> you can use <em>one</em> of:</p>...
<p>The solution is very simple. <code>git checkout &lt;filename&gt;</code> tries to check out file from <strong>the index</strong>, and therefore fails on merge.</p> <p>What you need to do is (i.e. checkout a <strong>commit</strong>):</p> <p><strong>To checkout your own version</strong> you can use <em>one</em> of:</p>...
119, 717
git, merge
<h1>Simple tool to 'accept theirs' or 'accept mine' on a whole file using git</h1> <p>I don't want a visual merge tool, and I also don't want to have to vi the conflicted file and manually choose the between HEAD (mine) and the imported change (theirs). Most of the time I either want all of their changes or all of min...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,131
git
# Simple tool to 'accept theirs' or 'accept mine' on a whole file using git I don't want a visual merge tool, and I also don't want to have to vi the conflicted file and manually choose the between HEAD (mine) and the imported change (theirs). Most of the time I either want all of their changes or all of mine. Commonl...
The solution is very simple. `git checkout <filename>` tries to check out file from **the index**, and therefore fails on merge. What you need to do is (i.e. checkout a **commit**): **To checkout your own version** you can use *one* of: ``` git checkout HEAD -- <filename> ``` or ``` git checkout --ours -- <filenam...
3021161
Git: can't undo local changes (error: path ... is unmerged)
479
2010-06-11 08:04:45
<p>I have following working tree state</p> <pre><code>$ git status foo/bar.txt # On branch master # Unmerged paths: # (use "git reset HEAD &lt;file&gt;..." to unstage) # (use "git add/rm &lt;file&gt;..." as appropriate to mark resolution) # # deleted by us: foo/bar.txt # no changes added to commit (use ...
313,868
342,896
2023-07-20 01:48:01
3,021,184
774
2010-06-11 08:09:30
129,404
2023-05-09 20:23:42
https://stackoverflow.com/q/3021161
https://stackoverflow.com/a/3021184
<p>You did it the wrong way around. You are meant to reset first to unstage the file, then checkout to revert local changes.</p> <p>Try this:</p> <pre><code>$ git reset foo/bar.txt $ git checkout foo/bar.txt </code></pre>
<p>You did it the wrong way around. You are meant to reset first to unstage the file, then checkout to revert local changes.</p> <p>Try this:</p> <pre><code>$ git reset foo/bar.txt $ git checkout foo/bar.txt </code></pre>
119, 37230, 51381
git, git-checkout, git-reset
<h1>Git: can't undo local changes (error: path ... is unmerged)</h1> <p>I have following working tree state</p> <pre><code>$ git status foo/bar.txt # On branch master # Unmerged paths: # (use "git reset HEAD &lt;file&gt;..." to unstage) # (use "git add/rm &lt;file&gt;..." as appropriate to mark resolution) # # ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,132
git
# Git: can't undo local changes (error: path ... is unmerged) I have following working tree state ``` $ git status foo/bar.txt # On branch master # Unmerged paths: # (use "git reset HEAD <file>..." to unstage) # (use "git add/rm <file>..." as appropriate to mark resolution) # # deleted by us: foo/bar.t...
You did it the wrong way around. You are meant to reset first to unstage the file, then checkout to revert local changes. Try this: ``` $ git reset foo/bar.txt $ git checkout foo/bar.txt ```
9529497
What is "origin" in Git?
788
2012-03-02 07:23:16
<p>When I run:</p> <pre><code>git push origin branchname </code></pre> <p>What exactly is <code>origin</code> and why do I have to type it before the branch name?</p>
383,068
693,642
2023-03-08 20:57:05
9,529,518
770
2012-03-02 07:25:44
487,033
2017-11-25 13:59:04
https://stackoverflow.com/q/9529497
https://stackoverflow.com/a/9529518
<p><code>origin</code> is an <strong>alias</strong> <em>on your system</em> for a particular remote repository. It's not actually a property of that repository.</p> <p>By doing</p> <pre><code>git push origin branchname </code></pre> <p>you're saying to push to the <code>origin</code> repository. There's no requireme...
<p><code>origin</code> is an <strong>alias</strong> <em>on your system</em> for a particular remote repository. It's not actually a property of that repository.</p> <p>By doing</p> <pre><code>git push origin branchname </code></pre> <p>you're saying to push to the <code>origin</code> repository. There's no requireme...
119
git
<h1>What is "origin" in Git?</h1> <p>When I run:</p> <pre><code>git push origin branchname </code></pre> <p>What exactly is <code>origin</code> and why do I have to type it before the branch name?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,133
git
# What is "origin" in Git? When I run: ``` git push origin branchname ``` What exactly is `origin` and why do I have to type it before the branch name?
`origin` is an **alias** *on your system* for a particular remote repository. It's not actually a property of that repository. By doing ``` git push origin branchname ``` you're saying to push to the `origin` repository. There's no requirement to name the remote repository `origin`: in fact the same repository could...
5964118
Git - working on wrong branch - how to copy changes to existing topic branch
457
2011-05-11 12:21:15
<p>I've been working on a project, but unfortunately, I <em>forgot</em> to switch to my branch, and as such have been working on master</p> <p>How can I copy the work (3 files) I've done here from master, to my branch (called, for example <em>branch123</em>) without comitting to master?</p>
162,231
131,809
2022-08-04 19:01:05
5,964,168
767
2011-05-11 12:24:39
409,623
2011-05-11 12:24:39
https://stackoverflow.com/q/5964118
https://stackoverflow.com/a/5964168
<p>Sounds like all you need is the following:</p> <pre><code>git stash git checkout branch123 git stash apply </code></pre> <p>Then you should be back on your own branch without touching the master branch.</p>
<p>Sounds like all you need is the following:</p> <pre><code>git stash git checkout branch123 git stash apply </code></pre> <p>Then you should be back on your own branch without touching the master branch.</p>
119
git
<h1>Git - working on wrong branch - how to copy changes to existing topic branch</h1> <p>I've been working on a project, but unfortunately, I <em>forgot</em> to switch to my branch, and as such have been working on master</p> <p>How can I copy the work (3 files) I've done here from master, to my branch (called, for ex...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,135
git
# Git - working on wrong branch - how to copy changes to existing topic branch I've been working on a project, but unfortunately, I *forgot* to switch to my branch, and as such have been working on master How can I copy the work (3 files) I've done here from master, to my branch (called, for example *branch123*) with...
Sounds like all you need is the following: ``` git stash git checkout branch123 git stash apply ``` Then you should be back on your own branch without touching the master branch.
2472254
When should I use git pull --rebase?
1,236
2010-03-18 18:04:26
<p>I know of some people who use <code>git pull --rebase</code> by default and others who insist never to use it. I believe I understand the difference between merging and rebasing, but I'm trying to put this in the context of <code>git pull</code>. Is it just about not wanting to see lots of merge commit messages, o...
1,194,542
2,147
2025-05-20 21:30:19
2,472,606
756
2010-03-18 19:01:45
158,676
2011-02-02 22:50:50
https://stackoverflow.com/q/2472254
https://stackoverflow.com/a/2472606
<p>You should use <code>git pull --rebase</code> when</p> <ul> <li>your changes do not deserve a separate branch</li> </ul> <p>Indeed -- why not then? It's more clear, and doesn't impose a <em>logical grouping</em> on your commits.</p> <hr> <p>Ok, I suppose it needs some clarification. In Git, as you probably kno...
<p>You should use <code>git pull --rebase</code> when</p> <ul> <li>your changes do not deserve a separate branch</li> </ul> <p>Indeed -- why not then? It's more clear, and doesn't impose a <em>logical grouping</em> on your commits.</p> <hr> <p>Ok, I suppose it needs some clarification. In Git, as you probably kno...
119
git
<h1>When should I use git pull --rebase?</h1> <p>I know of some people who use <code>git pull --rebase</code> by default and others who insist never to use it. I believe I understand the difference between merging and rebasing, but I'm trying to put this in the context of <code>git pull</code>. Is it just about not w...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,137
git
# When should I use git pull --rebase? I know of some people who use `git pull --rebase` by default and others who insist never to use it. I believe I understand the difference between merging and rebasing, but I'm trying to put this in the context of `git pull`. Is it just about not wanting to see lots of merge commi...
You should use `git pull --rebase` when - your changes do not deserve a separate branch Indeed -- why not then? It's more clear, and doesn't impose a *logical grouping* on your commits. --- Ok, I suppose it needs some clarification. In Git, as you probably know, you're encouraged to branch and merge. Your local bra...
658885
How do you get git to always pull from a specific branch?
503
2009-03-18 15:53:59
<p>I'm not a git master, but I have been working with it for some time now, with several different projects. In each project, I always <code>git clone [repository]</code> and from that point, can always <code>git pull</code>, so long as I don't have outstanding changes, of course.</p> <p>Recently, I had to revert to ...
265,946
78,642
2019-10-08 03:50:33
659,804
755
2009-03-18 19:40:26
28,804
2016-09-19 06:39:21
https://stackoverflow.com/q/658885
https://stackoverflow.com/a/659804
<p>Under <code>[branch "master"]</code>, try adding the following to the repo's Git config file (<code>.git/config</code>):</p> <pre><code>[branch "master"] remote = origin merge = refs/heads/master </code></pre> <p>This tells Git 2 things:</p> <ol> <li>When you're on the master branch, the default remote is...
<p>Under <code>[branch "master"]</code>, try adding the following to the repo's Git config file (<code>.git/config</code>):</p> <pre><code>[branch "master"] remote = origin merge = refs/heads/master </code></pre> <p>This tells Git 2 things:</p> <ol> <li>When you're on the master branch, the default remote is...
119, 456
git, version-control
<h1>How do you get git to always pull from a specific branch?</h1> <p>I'm not a git master, but I have been working with it for some time now, with several different projects. In each project, I always <code>git clone [repository]</code> and from that point, can always <code>git pull</code>, so long as I don't have ou...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,138
git
# How do you get git to always pull from a specific branch? I'm not a git master, but I have been working with it for some time now, with several different projects. In each project, I always `git clone [repository]` and from that point, can always `git pull`, so long as I don't have outstanding changes, of course. R...
Under `[branch "master"]`, try adding the following to the repo's Git config file (`.git/config`): ``` [branch "master"] remote = origin merge = refs/heads/master ``` This tells Git 2 things: 1. When you're on the master branch, the default remote is origin. 2. When using `git pull` on the master branch, wit...
10998792
How to color the Git console?
423
2012-06-12 14:30:00
<p>I recently saw that the <code>git</code> console in Windows is colored, e.g. Green for additions, red for deletions, etc. How do I color my <code>git</code> console like that?</p> <p>To install it, I used the command: <code>$ sudo apt-get install git-core</code></p>
235,805
320,791
2023-09-29 19:20:15
13,075,208
755
2012-10-25 18:47:49
907,779
2019-04-01 08:06:04
https://stackoverflow.com/q/10998792
https://stackoverflow.com/a/13075208
<p>As <a href="https://stackoverflow.com/a/17278947/6309">noted</a> by <a href="https://stackoverflow.com/users/6309/vonc">@VonC</a>, <code>color.ui</code> defaults to <code>auto</code> since Git 1.8.4</p> <hr> <p>From the Unix &amp; Linux Stackexchange question <a href="https://unix.stackexchange.com/questions/44266...
<p>As <a href="https://stackoverflow.com/a/17278947/6309">noted</a> by <a href="https://stackoverflow.com/users/6309/vonc">@VonC</a>, <code>color.ui</code> defaults to <code>auto</code> since Git 1.8.4</p> <hr> <p>From the Unix &amp; Linux Stackexchange question <a href="https://unix.stackexchange.com/questions/44266...
119, 488, 6439
colors, console, git
<h1>How to color the Git console?</h1> <p>I recently saw that the <code>git</code> console in Windows is colored, e.g. Green for additions, red for deletions, etc. How do I color my <code>git</code> console like that?</p> <p>To install it, I used the command: <code>$ sudo apt-get install git-core</code></p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,139
git
# How to color the Git console? I recently saw that the `git` console in Windows is colored, e.g. Green for additions, red for deletions, etc. How do I color my `git` console like that? To install it, I used the command: `$ sudo apt-get install git-core`
As [noted](https://stackoverflow.com/a/17278947/6309) by [@VonC](https://stackoverflow.com/users/6309/vonc), `color.ui` defaults to `auto` since Git 1.8.4 --- From the Unix & Linux Stackexchange question [How to colorize output of git?](https://unix.stackexchange.com/questions/44266/how-to-colorize-output-of-git) and...
3293531
How to permanently remove few commits from remote branch
1,160
2010-07-20 19:19:59
<p>I know that's rewriting of history which is bad yada yada.</p> <p>But how to permanently remove few commits from remote branch?</p>
1,088,727
82,062
2024-03-12 21:47:01
3,293,592
754
2010-07-20 19:26:36
6,309
2022-06-01 18:37:56
https://stackoverflow.com/q/3293531
https://stackoverflow.com/a/3293592
<p>You <code>git reset --hard</code> your local branch to remove changes from working tree and index, and you <code>git push --force</code> (or <a href="https://stackoverflow.com/a/52937476/6309"><code>git push --force-with-lease</code></a>) your revised local branch to the remote.<br /> (<a href="https://stackoverflow...
<p>You <code>git reset --hard</code> your local branch to remove changes from working tree and index, and you <code>git push --force</code> (or <a href="https://stackoverflow.com/a/52937476/6309"><code>git push --force-with-lease</code></a>) your revised local branch to the remote.<br /> (<a href="https://stackoverflow...
119
git
<h1>How to permanently remove few commits from remote branch</h1> <p>I know that's rewriting of history which is bad yada yada.</p> <p>But how to permanently remove few commits from remote branch?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,141
git
# How to permanently remove few commits from remote branch I know that's rewriting of history which is bad yada yada. But how to permanently remove few commits from remote branch?
You `git reset --hard` your local branch to remove changes from working tree and index, and you `git push --force` (or [`git push --force-with-lease`](https://stackoverflow.com/a/52937476/6309)) your revised local branch to the remote. ([other solution here](https://stackoverflow.com/questions/1475665/why-git-push-he...
17667023
Git, How to reset origin/master to a commit?
346
2013-07-16 02:26:10
<p>I reset my local master to a commit by this command:</p> <pre><code>git reset --hard e3f1e37 </code></pre> <p>when I enter <code>$ git status</code> command, terminal says:</p> <pre><code># On branch master # Your branch is behind 'origin/master' by 7 commits, and can be fast-forwarded. # (use "git pull" to up...
402,339
513,413
2022-12-01 07:19:01
17,667,057
753
2013-07-16 02:30:37
1,024,223
2013-07-16 02:30:37
https://stackoverflow.com/q/17667023
https://stackoverflow.com/a/17667057
<p><code>origin/xxx</code> branches are always pointer to a remote. You cannot check them out as they're not pointer to your local repository (you only checkout the commit. That's why you won't see the name written in the command line interface branch marker, only the commit hash).</p> <p>What you need to do to update...
<p><code>origin/xxx</code> branches are always pointer to a remote. You cannot check them out as they're not pointer to your local repository (you only checkout the commit. That's why you won't see the name written in the command line interface branch marker, only the commit hash).</p> <p>What you need to do to update...
119, 37230, 51381
git, git-checkout, git-reset
<h1>Git, How to reset origin/master to a commit?</h1> <p>I reset my local master to a commit by this command:</p> <pre><code>git reset --hard e3f1e37 </code></pre> <p>when I enter <code>$ git status</code> command, terminal says:</p> <pre><code># On branch master # Your branch is behind 'origin/master' by 7 commits,...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,142
git
# Git, How to reset origin/master to a commit? I reset my local master to a commit by this command: ``` git reset --hard e3f1e37 ``` when I enter `$ git status` command, terminal says: ``` # On branch master # Your branch is behind 'origin/master' by 7 commits, and can be fast-forwarded. # (use "git pull" to upd...
`origin/xxx` branches are always pointer to a remote. You cannot check them out as they're not pointer to your local repository (you only checkout the commit. That's why you won't see the name written in the command line interface branch marker, only the commit hash). What you need to do to update the remote is to for...
6006737
Git merge errors
367
2011-05-15 05:47:36
<p>I have a git branch called <code>9-sign-in-out</code> with perfectly working code, and I want to turn it into the master. I'm currently on the master branch.</p> <pre><code>$ git branch 9-sign-in-out * master </code></pre> <p>I'm trying to switch to <code>9-sign-in-out</code> branch, but it doesn't allow me to:</p...
576,029
496,797
2025-08-24 14:34:41
6,007,083
749
2011-05-15 07:23:19
223,092
2012-04-17 17:46:04
https://stackoverflow.com/q/6006737
https://stackoverflow.com/a/6007083
<p>It's worth understanding what those error messages mean - <code>needs merge</code> and <code>error: you need to resolve your current index first</code> indicate that a merge failed, and that there are conflicts in those files. If you've decided that whatever merge you were trying to do was a bad idea after all, you...
<p>It's worth understanding what those error messages mean - <code>needs merge</code> and <code>error: you need to resolve your current index first</code> indicate that a merge failed, and that there are conflicts in those files. If you've decided that whatever merge you were trying to do was a bad idea after all, you...
119, 1879, 28897, 76220
branch, git, git-branch, git-merge
<h1>Git merge errors</h1> <p>I have a git branch called <code>9-sign-in-out</code> with perfectly working code, and I want to turn it into the master. I'm currently on the master branch.</p> <pre><code>$ git branch 9-sign-in-out * master </code></pre> <p>I'm trying to switch to <code>9-sign-in-out</code> branch, but ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,143
git
# Git merge errors I have a git branch called `9-sign-in-out` with perfectly working code, and I want to turn it into the master. I'm currently on the master branch. ``` $ git branch 9-sign-in-out * master ``` I'm trying to switch to `9-sign-in-out` branch, but it doesn't allow me to: ``` $ git checkout 9-sign-in-o...
It's worth understanding what those error messages mean - `needs merge` and `error: you need to resolve your current index first` indicate that a merge failed, and that there are conflicts in those files. If you've decided that whatever merge you were trying to do was a bad idea after all, you can put things back to no...
3801321
Git: list only "untracked" files (also, custom commands)
489
2010-09-27 05:30:20
<p>Is there a way to use a command like <code>git ls-files</code> to show only untracked files?</p> <p>The reason I'm asking is because I use the following command to process all deleted files:</p> <pre><code>git ls-files -d | xargs git rm </code></pre> <p>I'd like something similar for untracked files:</p> <pre><c...
245,609
106,302
2024-12-13 00:16:06
3,801,554
748
2010-09-27 06:29:49
234,780
2019-01-12 04:41:52
https://stackoverflow.com/q/3801321
https://stackoverflow.com/a/3801554
<p>To list untracked files try:</p> <pre><code>git ls-files --others --exclude-standard </code></pre> <p>If you need to pipe the output to <code>xargs</code>, it is wise to mind white spaces using <code>git ls-files -z</code> and <code>xargs -0</code>:</p> <pre><code>git ls-files -z -o --exclude-standard | xargs -0 ...
<p>To list untracked files try:</p> <pre><code>git ls-files --others --exclude-standard </code></pre> <p>If you need to pipe the output to <code>xargs</code>, it is wise to mind white spaces using <code>git ls-files -z</code> and <code>xargs -0</code>:</p> <pre><code>git ls-files -z -o --exclude-standard | xargs -0 ...
119, 54839, 74978, 107030, 112901
git, git-ls-files, git-rm, git-stage, git-status
<h1>Git: list only "untracked" files (also, custom commands)</h1> <p>Is there a way to use a command like <code>git ls-files</code> to show only untracked files?</p> <p>The reason I'm asking is because I use the following command to process all deleted files:</p> <pre><code>git ls-files -d | xargs git rm </code></pre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,144
git
# Git: list only "untracked" files (also, custom commands) Is there a way to use a command like `git ls-files` to show only untracked files? The reason I'm asking is because I use the following command to process all deleted files: ``` git ls-files -d | xargs git rm ``` I'd like something similar for untracked file...
To list untracked files try: ``` git ls-files --others --exclude-standard ``` If you need to pipe the output to `xargs`, it is wise to mind white spaces using `git ls-files -z` and `xargs -0`: ``` git ls-files -z -o --exclude-standard | xargs -0 git add ``` Nice alias for adding untracked files: ``` au = !git add ...
945654
Git checkout: updating paths is incompatible with switching branches
477
2009-06-03 16:16:52
<p>My problem is related to <a href="https://stackoverflow.com/questions/180064">Fatal Git error when switching branch</a>.</p> <p>I try to fetch a remote branch with the command</p> <pre><code>git checkout -b local-name origin/remote-name </code></pre> <p>but I get this error message:</p> <blockquote> <p>fatal: ...
221,044
20,261
2017-12-08 15:53:03
1,371,215
746
2009-09-03 02:52:50
167,628
2013-02-14 21:02:52
https://stackoverflow.com/q/945654
https://stackoverflow.com/a/1371215
<p>I believe this occurs when you are trying to checkout a remote branch that your local git repo is not aware of yet. Try:</p> <pre><code>git remote show origin </code></pre> <p>If the remote branch you want to checkout is under "New remote branches" and not "Tracked remote branches" then you need to fetch them fir...
<p>I believe this occurs when you are trying to checkout a remote branch that your local git repo is not aware of yet. Try:</p> <pre><code>git remote show origin </code></pre> <p>If the remote branch you want to checkout is under "New remote branches" and not "Tracked remote branches" then you need to fetch them fir...
119, 31678, 37230
git, git-checkout, remote-branch
<h1>Git checkout: updating paths is incompatible with switching branches</h1> <p>My problem is related to <a href="https://stackoverflow.com/questions/180064">Fatal Git error when switching branch</a>.</p> <p>I try to fetch a remote branch with the command</p> <pre><code>git checkout -b local-name origin/remote-name ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,145
git
# Git checkout: updating paths is incompatible with switching branches My problem is related to [Fatal Git error when switching branch](https://stackoverflow.com/questions/180064). I try to fetch a remote branch with the command ``` git checkout -b local-name origin/remote-name ``` but I get this error message: > ...
I believe this occurs when you are trying to checkout a remote branch that your local git repo is not aware of yet. Try: ``` git remote show origin ``` If the remote branch you want to checkout is under "New remote branches" and not "Tracked remote branches" then you need to fetch them first: ``` git remote update g...
32333383
Git: Cherry-Pick to working copy without commit
448
2015-09-01 13:48:40
<p>I have several branches where I keep certain commits that I want to apply to my working copy every now and then. Initially I tried cherry-picking but I do not want to have the commit in the target branch later. </p> <p>So I did <code>cherry-pick</code> + <code>reset HEAD~1 --soft</code></p> <p>Is there something s...
220,380
108,238
2024-03-08 14:45:51
32,333,564
745
2015-09-01 13:56:00
3,306,465
2022-02-22 15:41:33
https://stackoverflow.com/q/32333383
https://stackoverflow.com/a/32333564
<p>Use '-n' flag with the cherry-picking which is &quot;no commit&quot;</p> <p>See here: <a href="http://git-scm.com/docs/git-cherry-pick" rel="noreferrer">http://git-scm.com/docs/git-cherry-pick</a></p> <pre><code>git cherry-pick -n &lt;HASH&gt; </code></pre> <p>To then unstage the staged changes</p> <pre><code>git re...
<p>Use '-n' flag with the cherry-picking which is &quot;no commit&quot;</p> <p>See here: <a href="http://git-scm.com/docs/git-cherry-pick" rel="noreferrer">http://git-scm.com/docs/git-cherry-pick</a></p> <pre><code>git cherry-pick -n &lt;HASH&gt; </code></pre> <p>To then unstage the staged changes</p> <pre><code>git re...
119
git
<h1>Git: Cherry-Pick to working copy without commit</h1> <p>I have several branches where I keep certain commits that I want to apply to my working copy every now and then. Initially I tried cherry-picking but I do not want to have the commit in the target branch later. </p> <p>So I did <code>cherry-pick</code> + <cod...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,146
git
# Git: Cherry-Pick to working copy without commit I have several branches where I keep certain commits that I want to apply to my working copy every now and then. Initially I tried cherry-picking but I do not want to have the commit in the target branch later. So I did `cherry-pick` + `reset HEAD~1 --soft` Is there ...
Use '-n' flag with the cherry-picking which is "no commit" See here: <http://git-scm.com/docs/git-cherry-pick> ``` git cherry-pick -n <HASH> ``` To then unstage the staged changes ``` git reset ```
10762859
brew update: The following untracked working tree files would be overwritten by merge:
374
2012-05-26 00:58:03
<p>I tried to run <code>brew update</code> and I get an error about my local changes would be lost if I merged. I tried committing my local changes (don't remember making any, but it's been awhile), and that made things worse.</p> <p>Here's the output:</p> <pre><code>MBP:Library User$ sudo brew update error: The fol...
70,757
716,082
2020-10-21 18:58:18
12,031,907
745
2012-08-20 03:15:27
1,234,721
2020-10-21 18:58:18
https://stackoverflow.com/q/10762859
https://stackoverflow.com/a/12031907
<p>Don't forget to fetch the origin:</p> <pre class="lang-sh prettyprint-override"><code>cd /usr/local/Homebrew git fetch origin git reset --hard origin/master </code></pre> <p>What happens is that you are trying to update brew, but brew itself is either not up to date (likely), there is a permissions change via some O...
<p>Don't forget to fetch the origin:</p> <pre class="lang-sh prettyprint-override"><code>cd /usr/local/Homebrew git fetch origin git reset --hard origin/master </code></pre> <p>What happens is that you are trying to update brew, but brew itself is either not up to date (likely), there is a permissions change via some O...
119, 1067
git, homebrew
<h1>brew update: The following untracked working tree files would be overwritten by merge:</h1> <p>I tried to run <code>brew update</code> and I get an error about my local changes would be lost if I merged. I tried committing my local changes (don't remember making any, but it's been awhile), and that made things wor...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,147
git
# brew update: The following untracked working tree files would be overwritten by merge: I tried to run `brew update` and I get an error about my local changes would be lost if I merged. I tried committing my local changes (don't remember making any, but it's been awhile), and that made things worse. Here's the outpu...
Don't forget to fetch the origin: ``` cd /usr/local/Homebrew git fetch origin git reset --hard origin/master ``` What happens is that you are trying to update brew, but brew itself is either not up to date (likely), there is a permissions change via some OS update (also likely), or brew is slightly corrupt (unlikely)...
2419249
How can I stage and commit all files, including newly added files, using a single command?
568
2010-03-10 17:53:04
<p>How can I stage and commit all files, including newly added files, using a single command?</p>
751,132
225,381
2023-05-24 04:14:12
2,419,270
744
2010-03-10 17:56:40
70,605
2020-10-30 04:20:03
https://stackoverflow.com/q/2419249
https://stackoverflow.com/a/2419270
<p>Does</p> <pre class="lang-sh prettyprint-override"><code>git add -A &amp;&amp; git commit -m &quot;Your Message&quot; </code></pre> <p>count as a &quot;single command&quot;?</p> <h2>Edit based on @thefinnomenon's answer below</h2> <p>To have it as a <code>git alias</code>, use:</p> <pre class="lang-sh prettyprint-ov...
<p>Does</p> <pre class="lang-sh prettyprint-override"><code>git add -A &amp;&amp; git commit -m &quot;Your Message&quot; </code></pre> <p>count as a &quot;single command&quot;?</p> <h2>Edit based on @thefinnomenon's answer below</h2> <p>To have it as a <code>git alias</code>, use:</p> <pre class="lang-sh prettyprint-ov...
119
git
<h1>How can I stage and commit all files, including newly added files, using a single command?</h1> <p>How can I stage and commit all files, including newly added files, using a single command?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,148
git
# How can I stage and commit all files, including newly added files, using a single command? How can I stage and commit all files, including newly added files, using a single command?
Does ``` git add -A && git commit -m "Your Message" ``` count as a "single command"? ## Edit based on @thefinnomenon's answer below To have it as a `git alias`, use: ``` git config --global alias.coa "!git add -A && git commit -m" ``` and commit all files, including new files, with a message with: ``` git coa "A...
34519665
How can I move HEAD back to a previous location? (Detached head) & Undo commits
344
2015-12-29 21:53:03
<p>In Git, I was trying to do a <code>squash commit</code> by merging in another branch and then resetting <code>HEAD</code> to the previous place via:</p> <pre><code>git reset origin/master </code></pre> <p>But I need to step out of this. How can I move HEAD back to the previous location?</p> <p>I have the SHA-1 fr...
666,557
152,825
2024-04-23 09:54:08
34,519,716
744
2015-12-29 21:56:12
1,755,598
2024-04-23 09:54:08
https://stackoverflow.com/q/34519665
https://stackoverflow.com/a/34519716
<p>Before answering, let's add some background, explaining what this <code>HEAD</code> is.</p> <h1><em><strong><code>First of all what is HEAD?</code></strong></em></h1> <p><code>HEAD</code> is simply a reference to the current commit (latest) on the current branch. <br/> There can only be a single <code>HEAD</code> at...
<p>Before answering, let's add some background, explaining what this <code>HEAD</code> is.</p> <h1><em><strong><code>First of all what is HEAD?</code></strong></em></h1> <p><code>HEAD</code> is simply a reference to the current commit (latest) on the current branch. <br/> There can only be a single <code>HEAD</code> at...
119, 34403, 37230, 51381, 79719
git, git-checkout, git-reflog, git-reset, git-revert
<h1>How can I move HEAD back to a previous location? (Detached head) & Undo commits</h1> <p>In Git, I was trying to do a <code>squash commit</code> by merging in another branch and then resetting <code>HEAD</code> to the previous place via:</p> <pre><code>git reset origin/master </code></pre> <p>But I need to step ou...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,149
git
# How can I move HEAD back to a previous location? (Detached head) & Undo commits In Git, I was trying to do a `squash commit` by merging in another branch and then resetting `HEAD` to the previous place via: ``` git reset origin/master ``` But I need to step out of this. How can I move HEAD back to the previous loc...
Before answering, let's add some background, explaining what this `HEAD` is. # ***`First of all what is HEAD?`*** `HEAD` is simply a reference to the current commit (latest) on the current branch. There can only be a single `HEAD` at any given time (excluding `git worktree`). The content of `HEAD` is stored insid...
3882583
How to discard local commits in Git?
341
2010-10-07 14:20:53
<p>I'd been working on something, and decided it was completely screwed...after having committed some of it. So I tried the following sequence:</p> <pre><code>git reset --hard git rebase origin git fetch git pull git checkout </code></pre> <p>At which point I got the message</p> <pre><code>Your branch is ahead of 'o...
251,224
53,013
2024-04-21 05:28:32
3,882,696
744
2010-10-07 14:30:07
28,804
2015-09-03 11:15:45
https://stackoverflow.com/q/3882583
https://stackoverflow.com/a/3882696
<pre><code>git reset --hard origin/master </code></pre> <p>will remove all commits not in <code>origin/master</code> where <code>origin</code> is the repo name and <code>master</code> is the name of the branch.</p>
<pre><code>git reset --hard origin/master </code></pre> <p>will remove all commits not in <code>origin/master</code> where <code>origin</code> is the repo name and <code>master</code> is the name of the branch.</p>
119, 51381
git, git-reset
<h1>How to discard local commits in Git?</h1> <p>I'd been working on something, and decided it was completely screwed...after having committed some of it. So I tried the following sequence:</p> <pre><code>git reset --hard git rebase origin git fetch git pull git checkout </code></pre> <p>At which point I got the mess...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,150
git
# How to discard local commits in Git? I'd been working on something, and decided it was completely screwed...after having committed some of it. So I tried the following sequence: ``` git reset --hard git rebase origin git fetch git pull git checkout ``` At which point I got the message ``` Your branch is ahead of ...
``` git reset --hard origin/master ``` will remove all commits not in `origin/master` where `origin` is the repo name and `master` is the name of the branch.
49478
Git ignore file for Xcode projects
969
2008-09-08 11:07:49
<p>Which files should I include in <code>.gitignore</code> when using <em>Git</em> in conjunction with <em>Xcode</em>?</p>
357,536
5,156
2025-01-13 08:21:06
12,021,580
742
2012-08-18 19:22:10
153,422
2019-08-04 19:51:52
https://stackoverflow.com/q/49478
https://stackoverflow.com/a/12021580
<p>I was previously using the top-voted answer, but it needs a bit of cleanup, so here it is redone for Xcode 4, with some improvements.</p> <p>I've researched <em>every</em> file in this list, but several of them do not exist in Apple's official Xcode documentation, so I had to go on Apple mailing lists.</p> <p>Ap...
<p>I was previously using the top-voted answer, but it needs a bit of cleanup, so here it is redone for Xcode 4, with some improvements.</p> <p>I've researched <em>every</em> file in this list, but several of them do not exist in Apple's official Xcode documentation, so I had to go on Apple mailing lists.</p> <p>Ap...
119, 369, 456, 908, 25056
git, gitignore, macos, version-control, xcode
<h1>Git ignore file for Xcode projects</h1> <p>Which files should I include in <code>.gitignore</code> when using <em>Git</em> in conjunction with <em>Xcode</em>?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,151
git
# Git ignore file for Xcode projects Which files should I include in `.gitignore` when using *Git* in conjunction with *Xcode*?
I was previously using the top-voted answer, but it needs a bit of cleanup, so here it is redone for Xcode 4, with some improvements. I've researched *every* file in this list, but several of them do not exist in Apple's official Xcode documentation, so I had to go on Apple mailing lists. Apple continues to add undoc...
2199897
How to convert a normal Git repository to a bare one?
701
2010-02-04 13:18:17
<p>How can I convert a 'normal' Git repository to a bare one?</p> <p>The main difference seems to be:</p> <ul> <li><p>in the normal Git repository, you have a <code>.git</code> folder inside the repository containing all relevant data and all other files making up your working copy</p></li> <li><p>in a bare Git repos...
284,666
113,195
2024-05-23 16:22:51
2,200,662
741
2010-02-04 15:06:17
2,988
2024-05-23 16:22:51
https://stackoverflow.com/q/2199897
https://stackoverflow.com/a/2200662
<p>In short: replace the contents of <code>repo</code> with the contents of <code>repo/.git</code>, then tell the repository that it is now a bare repository.</p> <p>To do this, execute the following commands:</p> <pre><code>cd repo mv .git ../repo.git # renaming just for clarity cd .. rm -fr repo cd repo.git git confi...
<p>In short: replace the contents of <code>repo</code> with the contents of <code>repo/.git</code>, then tell the repository that it is now a bare repository.</p> <p>To do this, execute the following commands:</p> <pre><code>cd repo mv .git ../repo.git # renaming just for clarity cd .. rm -fr repo cd repo.git git confi...
119, 456, 34099, 64465, 106074
git, git-bare, git-clone, git-non-bare-repository, version-control
<h1>How to convert a normal Git repository to a bare one?</h1> <p>How can I convert a 'normal' Git repository to a bare one?</p> <p>The main difference seems to be:</p> <ul> <li><p>in the normal Git repository, you have a <code>.git</code> folder inside the repository containing all relevant data and all other files ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,152
git
# How to convert a normal Git repository to a bare one? How can I convert a 'normal' Git repository to a bare one? The main difference seems to be: - in the normal Git repository, you have a `.git` folder inside the repository containing all relevant data and all other files making up your working copy - in a bare G...
In short: replace the contents of `repo` with the contents of `repo/.git`, then tell the repository that it is now a bare repository. To do this, execute the following commands: ``` cd repo mv .git ../repo.git # renaming just for clarity cd .. rm -fr repo cd repo.git git config --bool core.bare true ``` Note that th...
2850369
Why does git perform fast-forward merges by default?
673
2010-05-17 15:26:16
<p>Coming from mercurial, I use branches to organize features. Naturally, I want to see this work-flow in my history as well.</p> <p>I started my new project using git and finished my first feature. When merging the feature, I realized git uses fast-forward, i.e. it applies my changes directly to the master branch if ...
169,658
256,843
2025-05-24 21:17:27
2,850,413
740
2010-05-17 15:31:36
6,309
2025-05-24 21:17:27
https://stackoverflow.com/q/2850369
https://stackoverflow.com/a/2850413
<p>Fast-forward merging makes sense for short-lived branches, but in a more <a href="http://nvie.com/posts/a-successful-git-branching-model/" rel="nofollow noreferrer">complex history</a>, non-fast-forward merging may make the history easier to understand, and make it easier to revert a group of commits.</p> <p><em><st...
<p>Fast-forward merging makes sense for short-lived branches, but in a more <a href="http://nvie.com/posts/a-successful-git-branching-model/" rel="nofollow noreferrer">complex history</a>, non-fast-forward merging may make the history easier to understand, and make it easier to revert a group of commits.</p> <p><em><st...
119, 28897, 52842, 76220
fast-forward, git, git-branch, git-merge
<h1>Why does git perform fast-forward merges by default?</h1> <p>Coming from mercurial, I use branches to organize features. Naturally, I want to see this work-flow in my history as well.</p> <p>I started my new project using git and finished my first feature. When merging the feature, I realized git uses fast-forward...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,153
git
# Why does git perform fast-forward merges by default? Coming from mercurial, I use branches to organize features. Naturally, I want to see this work-flow in my history as well. I started my new project using git and finished my first feature. When merging the feature, I realized git uses fast-forward, i.e. it applie...
Fast-forward merging makes sense for short-lived branches, but in a more [complex history](http://nvie.com/posts/a-successful-git-branching-model/), non-fast-forward merging may make the history easier to understand, and make it easier to revert a group of commits. ***Warning**: Non-fast-forwarding has potential side ...
14998923
How can I copy the content of a branch to a new local branch?
487
2013-02-21 09:41:39
<p>I have worked on a local branch and also pushed the changes to remote.</p> <p>I want to revert the changes on that branch and do something else on it, but I don't want to lose the work completely. I was thinking of something like create a new branch locally and copy the old branch there, then I can revert the change...
740,493
566,136
2023-04-12 21:12:48
14,998,980
740
2013-02-21 09:44:37
572,644
2013-02-21 10:00:35
https://stackoverflow.com/q/14998923
https://stackoverflow.com/a/14998980
<pre><code>git checkout old_branch git branch new_branch </code></pre> <p>This will give you a new branch "new_branch" with the same state as "old_branch".</p> <p>This command can be combined to the following:</p> <pre><code>git checkout -b new_branch old_branch </code></pre>
<pre><code>git checkout old_branch git branch new_branch </code></pre> <p>This will give you a new branch "new_branch" with the same state as "old_branch".</p> <p>This command can be combined to the following:</p> <pre><code>git checkout -b new_branch old_branch </code></pre>
119, 1879
branch, git
<h1>How can I copy the content of a branch to a new local branch?</h1> <p>I have worked on a local branch and also pushed the changes to remote.</p> <p>I want to revert the changes on that branch and do something else on it, but I don't want to lose the work completely. I was thinking of something like create a new bra...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,154
git
# How can I copy the content of a branch to a new local branch? I have worked on a local branch and also pushed the changes to remote. I want to revert the changes on that branch and do something else on it, but I don't want to lose the work completely. I was thinking of something like create a new branch locally and...
``` git checkout old_branch git branch new_branch ``` This will give you a new branch "new_branch" with the same state as "old_branch". This command can be combined to the following: ``` git checkout -b new_branch old_branch ```
2474353
How to copy commits from one branch to another?
1,283
2010-03-19 00:51:39
<p>I've got two branches from my master:</p> <ul> <li><strong>v2.1</strong>: (version 2) I've been working on for several months</li> <li><strong>wss</strong>: that I created yesterday to add one specific feature to my master (in production)</li> </ul> <p>Is there a way to copy yesterday's commits from wss to v2.1?</...
1,421,949
58,000
2024-01-04 10:32:49
2,474,371
738
2010-03-19 00:59:27
119,963
2010-03-19 01:18:18
https://stackoverflow.com/q/2474353
https://stackoverflow.com/a/2474371
<p>You should really have a workflow that lets you do this all by merging:</p> <pre><code>- x - x - x (v2) - x - x - x (v2.1) \ x - x - x (wss) </code></pre> <p>So all you have to do is <code>git checkout v2.1</code> and <code>git merge wss</code>. If for some reason you really can't do this, a...
<p>You should really have a workflow that lets you do this all by merging:</p> <pre><code>- x - x - x (v2) - x - x - x (v2.1) \ x - x - x (wss) </code></pre> <p>So all you have to do is <code>git checkout v2.1</code> and <code>git merge wss</code>. If for some reason you really can't do this, a...
119, 53847
branching-and-merging, git
<h1>How to copy commits from one branch to another?</h1> <p>I've got two branches from my master:</p> <ul> <li><strong>v2.1</strong>: (version 2) I've been working on for several months</li> <li><strong>wss</strong>: that I created yesterday to add one specific feature to my master (in production)</li> </ul> <p>Is th...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,155
git
# How to copy commits from one branch to another? I've got two branches from my master: - **v2.1**: (version 2) I've been working on for several months - **wss**: that I created yesterday to add one specific feature to my master (in production) Is there a way to copy yesterday's commits from wss to v2.1?
You should really have a workflow that lets you do this all by merging: ``` - x - x - x (v2) - x - x - x (v2.1) \ x - x - x (wss) ``` So all you have to do is `git checkout v2.1` and `git merge wss`. If for some reason you really can't do this, and you can't use [git rebase](http://kernel.org/p...
10853935
Change branch base
394
2012-06-01 16:19:10
<p>I've a tree like this:</p> <pre><code>(commit 1) - master \-- (commit 2) - (commit 3) - demo \-- (commit 4) - (commit 5) - PRO </code></pre> <p>and I have to move the PRO branch to master</p> <pre><code>(commit 1) - master |-- (commit...
299,088
299,897
2025-08-29 20:36:24
10,853,956
738
2012-06-01 16:20:25
785,065
2021-04-12 17:33:44
https://stackoverflow.com/q/10853935
https://stackoverflow.com/a/10853956
<p>Assuming <code>newBase</code> is the branch you want to move your commits onto, <code>oldBase</code> is the old basis for your branch, you can use <a href="https://git-scm.com/docs/git-rebase#git-rebase---ontoltnewbasegt" rel="noreferrer"><code>--onto</code></a> for that:</p> <pre><code>git rebase --onto newBase old...
<p>Assuming <code>newBase</code> is the branch you want to move your commits onto, <code>oldBase</code> is the old basis for your branch, you can use <a href="https://git-scm.com/docs/git-rebase#git-rebase---ontoltnewbasegt" rel="noreferrer"><code>--onto</code></a> for that:</p> <pre><code>git rebase --onto newBase old...
119
git
<h1>Change branch base</h1> <p>I've a tree like this:</p> <pre><code>(commit 1) - master \-- (commit 2) - (commit 3) - demo \-- (commit 4) - (commit 5) - PRO </code></pre> <p>and I have to move the PRO branch to master</p> <pre><code>(commit 1) - master...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,156
git
# Change branch base I've a tree like this: ``` (commit 1) - master \-- (commit 2) - (commit 3) - demo \-- (commit 4) - (commit 5) - PRO ``` and I have to move the PRO branch to master ``` (commit 1) - master |-- (commit 2) - (commit 3)...
Assuming `newBase` is the branch you want to move your commits onto, `oldBase` is the old basis for your branch, you can use [`--onto`](https://git-scm.com/docs/git-rebase#git-rebase---ontoltnewbasegt) for that: ``` git rebase --onto newBase oldBase feature/branch ``` Given your case: ``` git checkout PRO # Just to ...
18031946
When doing a 'git push', what does '--set-upstream' do?
608
2013-08-03 10:38:50
<p>What does git <code>--set-upstream</code> do? </p> <p>I tried to understand it by reading the <a href="http://git-scm.com/docs/git-push" rel="noreferrer">git manual</a>, but I didn't quite get it. </p>
865,818
1,514,072
2025-03-13 03:44:07
18,032,014
735
2013-08-03 10:48:52
319,204
2025-03-13 03:44:07
https://stackoverflow.com/q/18031946
https://stackoverflow.com/a/18032014
<blockquote> <p>To avoid confusion,<br /> recent versions of <code>git</code> deprecate this somewhat ambiguous <code>--set-upstream</code> option<br /> in favor of a more verbose <code>--set-upstream-to</code> option<br /> with identical syntax and behavior.<br /> [ <a href="https://git-scm.com/docs/git-branch#Documen...
<blockquote> <p>To avoid confusion,<br /> recent versions of <code>git</code> deprecate this somewhat ambiguous <code>--set-upstream</code> option<br /> in favor of a more verbose <code>--set-upstream-to</code> option<br /> with identical syntax and behavior.<br /> [ <a href="https://git-scm.com/docs/git-branch#Documen...
119, 4236, 28898, 41346, 115546
git, git-push, git-remote, push, upstream-branch
<h1>When doing a 'git push', what does '--set-upstream' do?</h1> <p>What does git <code>--set-upstream</code> do? </p> <p>I tried to understand it by reading the <a href="http://git-scm.com/docs/git-push" rel="noreferrer">git manual</a>, but I didn't quite get it. </p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,157
git
# When doing a 'git push', what does '--set-upstream' do? What does git `--set-upstream` do? I tried to understand it by reading the [git manual](http://git-scm.com/docs/git-push), but I didn't quite get it.
> To avoid confusion, > recent versions of `git` deprecate this somewhat ambiguous `--set-upstream` option > in favor of a more verbose `--set-upstream-to` option > with identical syntax and behavior. > [ [Reference](https://git-scm.com/docs/git-branch#Documentation/git-branch.txt---set-upstream) ] --- ``` gi...
17369254
Is there a way to cause git-reflog to show a date alongside each entry?
522
2013-06-28 16:18:01
<p>The git-reflog command doesn't by default show a date alongside each entry, which strikes me as a strange oversight; I think this would be very helpful.</p> <p>Are there any command-line options, or other tweaks, which can be employed to cause it to show when each reflog entry was added? The <a href="https://www.ke...
134,580
27,641
2024-06-26 21:47:12
17,369,548
729
2013-06-28 16:35:36
2,422,194
2020-07-14 15:35:41
https://stackoverflow.com/q/17369254
https://stackoverflow.com/a/17369548
<p>Per the man page, you can use <code>git log</code> options, e.g.,</p> <pre><code>git reflog --pretty=short git reflog --date=iso </code></pre>
<p>Per the man page, you can use <code>git log</code> options, e.g.,</p> <pre><code>git reflog --pretty=short git reflog --date=iso </code></pre>
119, 59545, 79719
git, git-reflog, reflog
<h1>Is there a way to cause git-reflog to show a date alongside each entry?</h1> <p>The git-reflog command doesn't by default show a date alongside each entry, which strikes me as a strange oversight; I think this would be very helpful.</p> <p>Are there any command-line options, or other tweaks, which can be employed ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,158
git
# Is there a way to cause git-reflog to show a date alongside each entry? The git-reflog command doesn't by default show a date alongside each entry, which strikes me as a strange oversight; I think this would be very helpful. Are there any command-line options, or other tweaks, which can be employed to cause it to s...
Per the man page, you can use `git log` options, e.g., ``` git reflog --pretty=short git reflog --date=iso ```
34730585
VS Code: How to stage and commit individual changes in a single file?
476
2016-01-11 20:35:22
<p>Visual Studio Code has excellent Git integration, but I can't find a way to partially stage changes like with <code>git add --interactive</code> or <code>git add --patch</code>. Basically, I want to be able to select specific changes in my files and stage them without staging the entire file. This functionality is s...
182,675
21,734
2025-08-17 13:49:35
34,736,732
723
2016-01-12 06:15:14
4,851,043
2023-04-16 22:45:34
https://stackoverflow.com/q/34730585
https://stackoverflow.com/a/34736732
<ul> <li><p>Open up the Source Control view, then click a changed file to open the comparison.</p> </li> <li><p>Select the lines you want to stage.</p> </li> <li><p>Click '...' then <code>Stage Selected Ranges</code> <em>(in the ··· at the top-right corner of the editor, <strong>not</strong> the ··· at the top of the g...
<ul> <li><p>Open up the Source Control view, then click a changed file to open the comparison.</p> </li> <li><p>Select the lines you want to stage.</p> </li> <li><p>Click '...' then <code>Stage Selected Ranges</code> <em>(in the ··· at the top-right corner of the editor, <strong>not</strong> the ··· at the top of the g...
119, 111608
git, visual-studio-code
<h1>VS Code: How to stage and commit individual changes in a single file?</h1> <p>Visual Studio Code has excellent Git integration, but I can't find a way to partially stage changes like with <code>git add --interactive</code> or <code>git add --patch</code>. Basically, I want to be able to select specific changes in m...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,159
git
# VS Code: How to stage and commit individual changes in a single file? Visual Studio Code has excellent Git integration, but I can't find a way to partially stage changes like with `git add --interactive` or `git add --patch`. Basically, I want to be able to select specific changes in my files and stage them without ...
- Open up the Source Control view, then click a changed file to open the comparison. - Select the lines you want to stage. - Click '...' then `Stage Selected Ranges` *(in the ··· at the top-right corner of the editor, **not** the ··· at the top of the git panel on the left)*. [![enter image description here](https://i...
24410208
gitignore does not ignore folder
290
2014-06-25 13:34:05
<p>In the root of my project I have a <code>foo</code> folder. Inside the <code>foo</code> folder I have a <code>bar</code> folder. I would like to ignore all changes to all files inside my <code>bar</code> folder. I have this in my <code>gitignore</code>:</p> <pre><code>/foo/bar </code></pre> <p>The folder is checke...
225,618
436,560
2024-11-25 12:22:50
24,410,260
723
2014-06-25 13:36:38
1,420,382
2018-12-13 10:17:59
https://stackoverflow.com/q/24410208
https://stackoverflow.com/a/24410260
<p>I'm guessing this folder has been checked into git before? </p> <p>Run <code>git rm -r --cached &lt;folder&gt;</code> and check again.</p>
<p>I'm guessing this folder has been checked into git before? </p> <p>Run <code>git rm -r --cached &lt;folder&gt;</code> and check again.</p>
119, 25056
git, gitignore
<h1>gitignore does not ignore folder</h1> <p>In the root of my project I have a <code>foo</code> folder. Inside the <code>foo</code> folder I have a <code>bar</code> folder. I would like to ignore all changes to all files inside my <code>bar</code> folder. I have this in my <code>gitignore</code>:</p> <pre><code>/foo/...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,160
git
# gitignore does not ignore folder In the root of my project I have a `foo` folder. Inside the `foo` folder I have a `bar` folder. I would like to ignore all changes to all files inside my `bar` folder. I have this in my `gitignore`: ``` /foo/bar ``` The folder is checked: it exists and it has the files to be ignore...
I'm guessing this folder has been checked into git before? Run `git rm -r --cached <folder>` and check again.
3596260
git remote add with other SSH port
432
2010-08-29 19:32:45
<p>In Git, how can I add a remote origin server when my host uses a different SSH port? </p> <pre><code>git remote add origin ssh://user@host/srv/git/example </code></pre>
445,995
348,081
2024-12-06 16:02:19
3,596,272
718
2010-08-29 19:38:50
289,985
2016-12-19 17:32:23
https://stackoverflow.com/q/3596260
https://stackoverflow.com/a/3596272
<p>You can just do this:</p> <pre><code>git remote add origin ssh://user@host:1234/srv/git/example </code></pre> <p><code>1234</code> is the ssh port being used</p>
<p>You can just do this:</p> <pre><code>git remote add origin ssh://user@host:1234/srv/git/example </code></pre> <p><code>1234</code> is the ssh port being used</p>
119, 386, 700
git, port, ssh
<h1>git remote add with other SSH port</h1> <p>In Git, how can I add a remote origin server when my host uses a different SSH port? </p> <pre><code>git remote add origin ssh://user@host/srv/git/example </code></pre>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,161
git
# git remote add with other SSH port In Git, how can I add a remote origin server when my host uses a different SSH port? ``` git remote add origin ssh://user@host/srv/git/example ```
You can just do this: ``` git remote add origin ssh://user@host:1234/srv/git/example ``` `1234` is the ssh port being used
9597410
List all developers on a project in Git
395
2012-03-07 07:31:52
<p>Is it possible to list all users that contributed to a project (users that have done commits) in Git?</p> <p>Any additional statistics?</p>
133,293
587,228
2024-04-15 06:50:05
9,597,462
718
2012-03-07 07:35:42
1,074,361
2019-06-03 13:57:16
https://stackoverflow.com/q/9597410
https://stackoverflow.com/a/9597462
<p>To show all users &amp; emails, and the number of commits in the CURRENT branch:</p> <pre><code>git shortlog --summary --numbered --email </code></pre> <p>Or simply:</p> <pre><code>git shortlog -sne </code></pre> <p>To show users from <strong>all branches</strong> (not only the ones in the current branch) you ha...
<p>To show all users &amp; emails, and the number of commits in the CURRENT branch:</p> <pre><code>git shortlog --summary --numbered --email </code></pre> <p>Or simply:</p> <pre><code>git shortlog -sne </code></pre> <p>To show users from <strong>all branches</strong> (not only the ones in the current branch) you ha...
119
git
<h1>List all developers on a project in Git</h1> <p>Is it possible to list all users that contributed to a project (users that have done commits) in Git?</p> <p>Any additional statistics?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,162
git
# List all developers on a project in Git Is it possible to list all users that contributed to a project (users that have done commits) in Git? Any additional statistics?
To show all users & emails, and the number of commits in the CURRENT branch: ``` git shortlog --summary --numbered --email ``` Or simply: ``` git shortlog -sne ``` To show users from **all branches** (not only the ones in the current branch) you have to add `--all` flag: ``` git shortlog -sne --all ```
9750606
git still shows files as modified after adding to .gitignore
476
2012-03-17 14:08:57
<p>i'm adding this to <strong>.gitignore</strong> file</p> <pre><code>.idea/* </code></pre> <p>but anyway the status is:</p> <pre><code># modified: .gitignore # modified: .idea/.generators # modified: .idea/dovezu.iml # modified: .idea/misc.xml # modified: .idea/workspace.xml ...
238,145
952,129
2024-01-25 08:24:19
9,750,651
715
2012-03-17 14:15:18
812,680
2019-07-25 16:51:24
https://stackoverflow.com/q/9750606
https://stackoverflow.com/a/9750651
<p>Your <code>.gitignore</code> is working, but it still tracks the files because they were already in the index. </p> <p>To stop this you have to do : <code>git rm -r --cached .idea/</code></p> <p>When you commit the <code>.idea/</code> directory will be removed from your git repository and the following commits wi...
<p>Your <code>.gitignore</code> is working, but it still tracks the files because they were already in the index. </p> <p>To stop this you have to do : <code>git rm -r --cached .idea/</code></p> <p>When you commit the <code>.idea/</code> directory will be removed from your git repository and the following commits wi...
119, 25056
git, gitignore
<h1>git still shows files as modified after adding to .gitignore</h1> <p>i'm adding this to <strong>.gitignore</strong> file</p> <pre><code>.idea/* </code></pre> <p>but anyway the status is:</p> <pre><code># modified: .gitignore # modified: .idea/.generators # modified: .idea/dovezu.iml # ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,163
git
# git still shows files as modified after adding to .gitignore i'm adding this to **.gitignore** file ``` .idea/* ``` but anyway the status is: ``` # modified: .gitignore # modified: .idea/.generators # modified: .idea/dovezu.iml # modified: .idea/misc.xml # modified: .idea/w...
Your `.gitignore` is working, but it still tracks the files because they were already in the index. To stop this you have to do : `git rm -r --cached .idea/` When you commit the `.idea/` directory will be removed from your git repository and the following commits will ignore the `.idea/` directory. PS: You could use...
15264553
How to unstash only certain files?
603
2013-03-07 06:26:24
<p>I stashed my changes. Now I want to unstash only some files from the stash. How can I do this?</p>
283,246
147,530
2025-01-17 12:59:43
15,264,717
714
2013-03-07 06:39:06
6,309
2023-09-27 18:37:54
https://stackoverflow.com/q/15264553
https://stackoverflow.com/a/15264717
<p>As <a href="https://stackoverflow.com/a/22555169/6309">mentioned below</a>, and detailed in &quot;<a href="https://stackoverflow.com/a/1105666/6309">How would I extract a single file (or changes to a file) from a git stash?</a>&quot;, you can apply use <a href="http://git-scm.com/docs/git-checkout" rel="noreferrer">...
<p>As <a href="https://stackoverflow.com/a/22555169/6309">mentioned below</a>, and detailed in &quot;<a href="https://stackoverflow.com/a/1105666/6309">How would I extract a single file (or changes to a file) from a git stash?</a>&quot;, you can apply use <a href="http://git-scm.com/docs/git-checkout" rel="noreferrer">...
119, 13091
git, git-stash
<h1>How to unstash only certain files?</h1> <p>I stashed my changes. Now I want to unstash only some files from the stash. How can 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,164
git
# How to unstash only certain files? I stashed my changes. Now I want to unstash only some files from the stash. How can I do this?
As [mentioned below](https://stackoverflow.com/a/22555169/6309), and detailed in "[How would I extract a single file (or changes to a file) from a git stash?](https://stackoverflow.com/a/1105666/6309)", you can apply use [`git checkout`](http://git-scm.com/docs/git-checkout) or [`git show`](http://git-scm.com/docs/git-...
436362
How to diff a commit with its parent
535
2009-01-12 18:03:57
<p>Aside from writing an alias or script, is there a shorter command for getting the diff for a particular commit?</p> <pre><code>git diff 15dc8^..15dc8 </code></pre> <p>If you only give the single commit id <code>git diff 15dc8</code>, it diffs that commit against HEAD.</p>
169,796
25,848
2021-07-07 17:53:45
436,368
712
2009-01-12 18:06:26
28,804
2009-01-12 18:06:26
https://stackoverflow.com/q/436362
https://stackoverflow.com/a/436368
<p>Use <code>git show $COMMIT</code>. It'll show you the log message for the commit, and the diff of that particular commit.</p>
<p>Use <code>git show $COMMIT</code>. It'll show you the log message for the commit, and the diff of that particular commit.</p>
119, 9033
git, git-diff
<h1>How to diff a commit with its parent</h1> <p>Aside from writing an alias or script, is there a shorter command for getting the diff for a particular commit?</p> <pre><code>git diff 15dc8^..15dc8 </code></pre> <p>If you only give the single commit id <code>git diff 15dc8</code>, it diffs that commit against HEAD.</p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,165
git
# How to diff a commit with its parent Aside from writing an alias or script, is there a shorter command for getting the diff for a particular commit? ``` git diff 15dc8^..15dc8 ``` If you only give the single commit id `git diff 15dc8`, it diffs that commit against HEAD.
Use `git show $COMMIT`. It'll show you the log message for the commit, and the diff of that particular commit.
1273108
How do I git rm a file without deleting it from disk?
417
2009-08-13 16:29:55
<p>The command removes the file in my system. I meant it to remove only the file from Git-repository.</p> <p>How can I remove the file from a Git repository, without removing the file in my system? </p>
161,280
54,964
2020-04-20 02:35:07
1,273,132
711
2009-08-13 16:34:34
115,738
2020-04-20 02:35:07
https://stackoverflow.com/q/1273108
https://stackoverflow.com/a/1273132
<pre><code>git rm --cached file </code></pre> <p>should do what you want.</p> <p>You can read more details at <code>git help rm</code></p>
<pre><code>git rm --cached file </code></pre> <p>should do what you want.</p> <p>You can read more details at <code>git help rm</code></p>
119, 112901
git, git-rm
<h1>How do I git rm a file without deleting it from disk?</h1> <p>The command removes the file in my system. I meant it to remove only the file from Git-repository.</p> <p>How can I remove the file from a Git repository, without removing the file in my system? </p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,166
git
# How do I git rm a file without deleting it from disk? The command removes the file in my system. I meant it to remove only the file from Git-repository. How can I remove the file from a Git repository, without removing the file in my system?
``` git rm --cached file ``` should do what you want. You can read more details at `git help rm`
7124486
What to do with commit made in a detached head
430
2011-08-19 16:17:16
<p>Using git I made something like this</p> <pre><code>git clone git checkout {a rev number tree rev before} (here I started to be in a detached head state) //hacking git commit //hacking git commit (some commit where made on origin/master) git pull (which does complete because there was some error due to the fact tha...
343,694
340,467
2025-03-11 18:59:20
7,124,513
706
2011-08-19 16:19:56
839,646
2024-03-19 16:51:30
https://stackoverflow.com/q/7124486
https://stackoverflow.com/a/7124513
<p>Create a branch where you are, then switch to master and merge it:</p> <pre><code>git switch -c my-temporary-work git switch master git merge my-temporary-work </code></pre>
<p>Create a branch where you are, then switch to master and merge it:</p> <pre><code>git switch -c my-temporary-work git switch master git merge my-temporary-work </code></pre>
119, 37230
git, git-checkout
<h1>What to do with commit made in a detached head</h1> <p>Using git I made something like this</p> <pre><code>git clone git checkout {a rev number tree rev before} (here I started to be in a detached head state) //hacking git commit //hacking git commit (some commit where made on origin/master) git pull (which does c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,167
git
# What to do with commit made in a detached head Using git I made something like this ``` git clone git checkout {a rev number tree rev before} (here I started to be in a detached head state) //hacking git commit //hacking git commit (some commit where made on origin/master) git pull (which does complete because ther...
Create a branch where you are, then switch to master and merge it: ``` git switch -c my-temporary-work git switch master git merge my-temporary-work ```
1967967
Git command to display HEAD commit id?
395
2009-12-28 04:30:57
<p>What command can I use to print out the commit id of HEAD?</p> <p>This is what I'm doing by hand:</p> <pre><code>$ cat .git/HEAD ref: refs/heads/v3.3 $ cat .git/refs/heads/v3.3 6050732e725c68b83c35c873ff8808dff1c406e1 </code></pre> <p>But I need a script that can reliably pipe the output of some command to a text...
423,930
46,926
2022-08-15 11:04:31
1,968,001
699
2009-12-28 04:44:26
22,483
2017-06-29 13:56:08
https://stackoverflow.com/q/1967967
https://stackoverflow.com/a/1968001
<p>Use the command:</p> <pre><code>git rev-parse HEAD </code></pre> <p>For the short version:</p> <pre><code>git rev-parse --short HEAD </code></pre>
<p>Use the command:</p> <pre><code>git rev-parse HEAD </code></pre> <p>For the short version:</p> <pre><code>git rev-parse --short HEAD </code></pre>
119, 456
git, version-control
<h1>Git command to display HEAD commit id?</h1> <p>What command can I use to print out the commit id of HEAD?</p> <p>This is what I'm doing by hand:</p> <pre><code>$ cat .git/HEAD ref: refs/heads/v3.3 $ cat .git/refs/heads/v3.3 6050732e725c68b83c35c873ff8808dff1c406e1 </code></pre> <p>But I need a script that can re...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,168
git
# Git command to display HEAD commit id? What command can I use to print out the commit id of HEAD? This is what I'm doing by hand: ``` $ cat .git/HEAD ref: refs/heads/v3.3 $ cat .git/refs/heads/v3.3 6050732e725c68b83c35c873ff8808dff1c406e1 ``` But I need a script that can reliably pipe the output of some command t...
Use the command: ``` git rev-parse HEAD ``` For the short version: ``` git rev-parse --short HEAD ```
6842687
The remote end hung up unexpectedly while git cloning
415
2011-07-27 10:12:13
<p>My <code>git</code> client repeatedly fails with the following error after trying to clone the repository for some time.</p> <p>What could be the issue here? </p> <p><strong>Note:</strong> I have registered my SSH key with the GIT hosting provider</p> <pre><code>Receiving objects: 13% (1309/10065), 796.00 KiB | ...
649,713
136,088
2026-01-19 14:17:29
6,849,424
698
2011-07-27 18:34:34
6,309
2026-01-19 14:17:29
https://stackoverflow.com/q/6842687
https://stackoverflow.com/a/6849424
<h3>Quick solution:</h3> <p>With this kind of error, I usually start by raising the <code>postBuffer</code> size by:</p> <pre><code>git config --global http.postBuffer 524288000 </code></pre> <p>(some comments below report having to double the value):</p> <pre><code>git config --global http.postBuffer 1048576000 </code...
<h3>Quick solution:</h3> <p>With this kind of error, I usually start by raising the <code>postBuffer</code> size by:</p> <pre><code>git config --global http.postBuffer 524288000 </code></pre> <p>(some comments below report having to double the value):</p> <pre><code>git config --global http.postBuffer 1048576000 </code...
119
git
<h1>The remote end hung up unexpectedly while git cloning</h1> <p>My <code>git</code> client repeatedly fails with the following error after trying to clone the repository for some time.</p> <p>What could be the issue here? </p> <p><strong>Note:</strong> I have registered my SSH key with the GIT hosting provider</p> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,169
git
# The remote end hung up unexpectedly while git cloning My `git` client repeatedly fails with the following error after trying to clone the repository for some time. What could be the issue here? **Note:** I have registered my SSH key with the GIT hosting provider ``` Receiving objects: 13% (1309/10065), 796.00 Ki...
### Quick solution: With this kind of error, I usually start by raising the `postBuffer` size by: ``` git config --global http.postBuffer 524288000 ``` (some comments below report having to double the value): ``` git config --global http.postBuffer 1048576000 ``` (For `npm publish`, [Martin Braun](https://stackove...
3833561
Why doesn't Git ignore my specified file?
345
2010-09-30 18:16:18
<p>I added the following line to <code>.gitignore</code>:</p> <pre><code>sites/default/settings.php </code></pre> <p>but when I type <code>git status</code> it shows the file as unstaged file.</p> <p>What's the problem? All other patterns work well.</p>
292,343
463,148
2024-02-12 20:33:10
3,833,675
697
2010-09-30 18:31:09
216,074
2023-05-31 15:53:29
https://stackoverflow.com/q/3833561
https://stackoverflow.com/a/3833675
<p>Make sure that your <code>.gitignore</code> is in the root of the working directory, and in that directory run <code>git status</code> and <em>copy</em> the path to the file from the status output and paste it into the <code>.gitignore</code>.</p> <p>If that doesn’t work, then it’s likely that your file is already t...
<p>Make sure that your <code>.gitignore</code> is in the root of the working directory, and in that directory run <code>git status</code> and <em>copy</em> the path to the file from the status output and paste it into the <code>.gitignore</code>.</p> <p>If that doesn’t work, then it’s likely that your file is already t...
119, 25056, 54839
git, gitignore, git-status
<h1>Why doesn't Git ignore my specified file?</h1> <p>I added the following line to <code>.gitignore</code>:</p> <pre><code>sites/default/settings.php </code></pre> <p>but when I type <code>git status</code> it shows the file as unstaged file.</p> <p>What's the problem? All other patterns work well.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,170
git
# Why doesn't Git ignore my specified file? I added the following line to `.gitignore`: ``` sites/default/settings.php ``` but when I type `git status` it shows the file as unstaged file. What's the problem? All other patterns work well.
Make sure that your `.gitignore` is in the root of the working directory, and in that directory run `git status` and *copy* the path to the file from the status output and paste it into the `.gitignore`. If that doesn’t work, then it’s likely that your file is already tracked by Git. You can confirm this through the o...
1514054
How do I delete a local repository in Git?
482
2009-10-03 15:30:00
<p>I can't find the command. I tried googling &quot;Git 'delete a repository'&quot;.</p>
1,495,797
182,172
2024-11-01 17:17:38
1,514,086
688
2009-10-03 15:39:17
null
2018-09-27 13:56:05
https://stackoverflow.com/q/1514054
https://stackoverflow.com/a/1514086
<p>Delete the <code>.git</code> directory in the root-directory of your repository if you only want to delete the git-related information (branches, versions).</p> <p>If you want to delete everything (git-data, code, etc), just delete the whole directory.</p> <p>.git directories are hidden by default, so you'll need ...
<p>Delete the <code>.git</code> directory in the root-directory of your repository if you only want to delete the git-related information (branches, versions).</p> <p>If you want to delete everything (git-data, code, etc), just delete the whole directory.</p> <p>.git directories are hidden by default, so you'll need ...
119
git
<h1>How do I delete a local repository in Git?</h1> <p>I can't find the command. I tried googling &quot;Git 'delete a repository'&quot;.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,173
git
# How do I delete a local repository in Git? I can't find the command. I tried googling "Git 'delete a repository'".
Delete the `.git` directory in the root-directory of your repository if you only want to delete the git-related information (branches, versions). If you want to delete everything (git-data, code, etc), just delete the whole directory. .git directories are hidden by default, so you'll need to be able to view hidden fi...
6004453
How to remove multiple deleted files in Git repository
256
2011-05-14 20:00:19
<p>I have deleted some files and git status shows as below.</p> <p>I have committed and pushed. </p> <p>GitHub still shows the deleted files in the repository. How can I delete files in the GitHub repository?</p> <pre><code># On branch master # Changes not staged for commit: # (use "git add/rm &lt;file&gt;..." to ...
182,143
119,198
2018-01-08 19:38:19
12,229,588
688
2012-09-01 16:48:11
1,640,778
2012-10-01 05:18:33
https://stackoverflow.com/q/6004453
https://stackoverflow.com/a/12229588
<pre><code>git add -u </code></pre> <p>updates all your changes </p>
<pre><code>git add -u </code></pre> <p>updates all your changes </p>
119, 112901
git, git-rm
<h1>How to remove multiple deleted files in Git repository</h1> <p>I have deleted some files and git status shows as below.</p> <p>I have committed and pushed. </p> <p>GitHub still shows the deleted files in the repository. How can I delete files in the GitHub repository?</p> <pre><code># On branch master # Changes ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,174
git
# How to remove multiple deleted files in Git repository I have deleted some files and git status shows as below. I have committed and pushed. GitHub still shows the deleted files in the repository. How can I delete files in the GitHub repository? ``` # On branch master # Changes not staged for commit: # (use "gi...
``` git add -u ``` updates all your changes
4604486
How do I move an existing Git submodule within a Git repository?
556
2011-01-05 13:24:29
<p>I would like to change the directory name of a Git submodule in my Git superproject.</p> <p>Lets suppose I have the following entry in my <code>.gitmodules</code> file:</p> <pre><code>[submodule ".emacs.d/vimpulse"] path = .emacs.d/vimpulse url = git://gitorious.org/vimpulse/vimpulse.git </code></pre> <p>What...
229,234
537,149
2022-07-13 06:58:30
6,310,246
685
2011-06-10 17:53:22
793,172
2022-03-26 18:12:02
https://stackoverflow.com/q/4604486
https://stackoverflow.com/a/6310246
<h2>Newer versions of git</h2> <p>Git now has native support for moving submodules:</p> <blockquote> <p>Since git 1.8.5, <code>git mv old/submod new/submod</code> works as expected and does all the plumbing for you. You might want to use git 1.9.3 or newer, because it includes fixes for submodule moving.</p> </blockquo...
<h2>Newer versions of git</h2> <p>Git now has native support for moving submodules:</p> <blockquote> <p>Since git 1.8.5, <code>git mv old/submod new/submod</code> works as expected and does all the plumbing for you. You might want to use git 1.9.3 or newer, because it includes fixes for submodule moving.</p> </blockquo...
119, 41612
git, git-submodules
<h1>How do I move an existing Git submodule within a Git repository?</h1> <p>I would like to change the directory name of a Git submodule in my Git superproject.</p> <p>Lets suppose I have the following entry in my <code>.gitmodules</code> file:</p> <pre><code>[submodule ".emacs.d/vimpulse"] path = .emacs.d/vimpuls...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,175
git
# How do I move an existing Git submodule within a Git repository? I would like to change the directory name of a Git submodule in my Git superproject. Lets suppose I have the following entry in my `.gitmodules` file: ``` [submodule ".emacs.d/vimpulse"] path = .emacs.d/vimpulse url = git://gitorious.org/vimpulse...
## Newer versions of git Git now has native support for moving submodules: > Since git 1.8.5, `git mv old/submod new/submod` works as expected and does all the plumbing for you. You might want to use git 1.9.3 or newer, because it includes fixes for submodule moving. ## Older versions of git *As mentioned in the co...
16350673
Depend on a branch or tag using a git URL in a package.json?
489
2013-05-03 02:28:22
<p>Say I've forked a node module with a bugfix and I want to use my fixed version, on a feature branch of course, until the bugfix is merged and released. </p> <p>How would I reference my fixed version in the <code>dependencies</code> of my <code>package.json</code>?</p>
334,774
407,845
2024-03-09 09:00:51
16,350,674
684
2013-05-03 02:28:22
407,845
2023-01-15 00:09:46
https://stackoverflow.com/q/16350673
https://stackoverflow.com/a/16350674
<h2>Solution 1</h2> <p>From the <a href="https://docs.npmjs.com/cli/v8/configuring-npm/package-json#git-urls-as-dependencies" rel="noreferrer">npm docs</a>, using a git URL:</p> <pre><code>https://github.com/&lt;user&gt;/&lt;project&gt;.git#&lt;branch&gt; https://github.com/&lt;user&gt;/&lt;project&gt;.git#feature\/&l...
<h2>Solution 1</h2> <p>From the <a href="https://docs.npmjs.com/cli/v8/configuring-npm/package-json#git-urls-as-dependencies" rel="noreferrer">npm docs</a>, using a git URL:</p> <pre><code>https://github.com/&lt;user&gt;/&lt;project&gt;.git#&lt;branch&gt; https://github.com/&lt;user&gt;/&lt;project&gt;.git#feature\/&l...
119, 1281, 1879, 60718, 61387
branch, dependencies, git, git-tag, npm
<h1>Depend on a branch or tag using a git URL in a package.json?</h1> <p>Say I've forked a node module with a bugfix and I want to use my fixed version, on a feature branch of course, until the bugfix is merged and released. </p> <p>How would I reference my fixed version in the <code>dependencies</code> of my <code>pa...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,176
git
# Depend on a branch or tag using a git URL in a package.json? Say I've forked a node module with a bugfix and I want to use my fixed version, on a feature branch of course, until the bugfix is merged and released. How would I reference my fixed version in the `dependencies` of my `package.json`?
## Solution 1 From the [npm docs](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#git-urls-as-dependencies), using a git URL: ``` https://github.com/<user>/<project>.git#<branch> https://github.com/<user>/<project>.git#feature\/<branch> ``` Don't use `git://` protocol for GitHub, it [is not longer suppor...
16329776
How to keep a branch synchronized/updated with master?
428
2013-05-02 03:15:17
<p>At the moment git is doing my head in, I cannot come up with the best solution for the following.</p> <p>There are two branches, one called <strong>master</strong> and one called <strong>mobiledevicesupport</strong>. I want to keep mobiledevicesupport as a continuous branch that will be merged/synced with the maste...
653,431
1,388,534
2024-11-14 18:17:04
16,330,001
684
2013-05-02 03:44:53
141,822
2022-04-24 02:43:29
https://stackoverflow.com/q/16329776
https://stackoverflow.com/a/16330001
<p>Yes, just do:</p> <pre class="lang-sh prettyprint-override"><code>git checkout master git pull git checkout mobiledevicesupport git merge master </code></pre> <p>to keep mobiledevicesupport in sync with master.</p> <p>Then, when you're ready to put mobiledevicesupport into master, first, merge in master like above, ...
<p>Yes, just do:</p> <pre class="lang-sh prettyprint-override"><code>git checkout master git pull git checkout mobiledevicesupport git merge master </code></pre> <p>to keep mobiledevicesupport in sync with master.</p> <p>Then, when you're ready to put mobiledevicesupport into master, first, merge in master like above, ...
119, 28897, 76220
git, git-branch, git-merge
<h1>How to keep a branch synchronized/updated with master?</h1> <p>At the moment git is doing my head in, I cannot come up with the best solution for the following.</p> <p>There are two branches, one called <strong>master</strong> and one called <strong>mobiledevicesupport</strong>. I want to keep mobiledevicesupport ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,177
git
# How to keep a branch synchronized/updated with master? At the moment git is doing my head in, I cannot come up with the best solution for the following. There are two branches, one called **master** and one called **mobiledevicesupport**. I want to keep mobiledevicesupport as a continuous branch that will be merged...
Yes, just do: ``` git checkout master git pull git checkout mobiledevicesupport git merge master ``` to keep mobiledevicesupport in sync with master. Then, when you're ready to put mobiledevicesupport into master, first, merge in master like above, then: ``` git checkout master git merge mobiledevicesupport git pus...
454734
How can one change the timestamp of an old commit in Git?
1,250
2009-01-18 06:13:46
<p>The answers to <a href="https://stackoverflow.com/questions/179123/how-do-i-edit-an-incorrect-commit-message-in-git">How to modify existing, unpushed commits?</a> describe a way to amend previous commit messages that haven't yet been pushed upstream. The new messages inherit the timestamps of the original commits. ...
742,129
14,468
2025-03-07 12:51:10
454,750
679
2009-01-18 06:48:07
39,975
2024-12-05 18:33:14
https://stackoverflow.com/q/454734
https://stackoverflow.com/a/454750
<p>Use <code>git filter-branch</code> with an env filter that sets <code>GIT_AUTHOR_DATE</code> and <code>GIT_COMMITTER_DATE</code> for the specific hash of the commit you're looking to fix.</p> <p>This will invalidate that and all future hashes.</p> <h3>Example</h3> <p>If you wanted to change the <a href="https://www....
<p>Use <code>git filter-branch</code> with an env filter that sets <code>GIT_AUTHOR_DATE</code> and <code>GIT_COMMITTER_DATE</code> for the specific hash of the commit you're looking to fix.</p> <p>This will invalidate that and all future hashes.</p> <h3>Example</h3> <p>If you wanted to change the <a href="https://www....
119, 2177, 5597, 91259
commit, git, git-rewrite-history, timestamp
<h1>How can one change the timestamp of an old commit in Git?</h1> <p>The answers to <a href="https://stackoverflow.com/questions/179123/how-do-i-edit-an-incorrect-commit-message-in-git">How to modify existing, unpushed commits?</a> describe a way to amend previous commit messages that haven't yet been pushed upstream....
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,178
git
# How can one change the timestamp of an old commit in Git? The answers to [How to modify existing, unpushed commits?](https://stackoverflow.com/questions/179123/how-do-i-edit-an-incorrect-commit-message-in-git) describe a way to amend previous commit messages that haven't yet been pushed upstream. The new messages in...
Use `git filter-branch` with an env filter that sets `GIT_AUTHOR_DATE` and `GIT_COMMITTER_DATE` for the specific hash of the commit you're looking to fix. This will invalidate that and all future hashes. ### Example If you wanted to change the [dates](https://www.kernel.org/pub/software/scm/git/docs/git-commit.html#...
4309156
Commit specific lines of a file to git
387
2010-11-29 23:28:47
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/1085162/how-can-i-commit-only-part-of-a-file-in-git">How can I commit only part of a file in git</a> </p> </blockquote> <p>How do I commit a few specific line ranges from a file to git? while ignoring some othe...
177,708
219,166
2025-08-28 07:45:46
4,309,173
676
2010-11-29 23:31:59
139,092
2010-11-29 23:31:59
https://stackoverflow.com/q/4309156
https://stackoverflow.com/a/4309173
<p>Try <code>git add -p</code> -- it will interactively let you add, skip, or split diff hunks.</p>
<p>Try <code>git add -p</code> -- it will interactively let you add, skip, or split diff hunks.</p>
119
git
<h1>Commit specific lines of a file to git</h1> <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/1085162/how-can-i-commit-only-part-of-a-file-in-git">How can I commit only part of a file in git</a> </p> </blockquote> <p>How do I commit a few specific line ran...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,179
git
# Commit specific lines of a file to git > **Possible Duplicate:** > [How can I commit only part of a file in git](https://stackoverflow.com/questions/1085162/how-can-i-commit-only-part-of-a-file-in-git) How do I commit a few specific line ranges from a file to git? while ignoring some other line changes in the sam...
Try `git add -p` -- it will interactively let you add, skip, or split diff hunks.
8146289
How to get "their" changes in the middle of conflicting Git rebase?
459
2011-11-16 03:25:35
<p>I have conflicting branches, <code>feature_x</code> branched from <code>main</code>.</p> <p>Let's say when rebasing <code>feature_x</code> on current <code>main</code>, while resolving conflicts, I decide to take <strong>some</strong> (not all) of &quot;their&quot; (i.e. <code>main</code>) files as-is. How do I do t...
279,212
145,989
2024-10-22 13:30:42
13,621,563
673
2012-11-29 08:24:44
362,378
2024-10-22 13:30:42
https://stackoverflow.com/q/8146289
https://stackoverflow.com/a/13621563
<p>You want to use:</p> <pre><code>git checkout --ours foo/bar.java git add foo/bar.java </code></pre> <p>If you rebase a branch <code>feature_x</code> against <code>main</code> (i.e. running <code>git rebase main</code> while on branch <code>feature_x</code>), during rebasing <code>ours</code> refers to <code>main</co...
<p>You want to use:</p> <pre><code>git checkout --ours foo/bar.java git add foo/bar.java </code></pre> <p>If you rebase a branch <code>feature_x</code> against <code>main</code> (i.e. running <code>git rebase main</code> while on branch <code>feature_x</code>), during rebasing <code>ours</code> refers to <code>main</co...
119, 8974, 29934
git, git-rebase, rebase
<h1>How to get "their" changes in the middle of conflicting Git rebase?</h1> <p>I have conflicting branches, <code>feature_x</code> branched from <code>main</code>.</p> <p>Let's say when rebasing <code>feature_x</code> on current <code>main</code>, while resolving conflicts, I decide to take <strong>some</strong> (not ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,180
git
# How to get "their" changes in the middle of conflicting Git rebase? I have conflicting branches, `feature_x` branched from `main`. Let's say when rebasing `feature_x` on current `main`, while resolving conflicts, I decide to take **some** (not all) of "their" (i.e. `main`) files as-is. How do I do that? I tried: ...
You want to use: ``` git checkout --ours foo/bar.java git add foo/bar.java ``` If you rebase a branch `feature_x` against `main` (i.e. running `git rebase main` while on branch `feature_x`), during rebasing `ours` refers to `main` and `theirs` to `feature_x`. As pointed out in the [git-rebase docs](https://git-scm.c...
34119866
Setting up and using Meld as your Git difftool and mergetool
428
2015-12-06 16:35:03
<p><a href="https://meldmerge.org/" rel="noreferrer">Meld</a> is a popular free, open-source, and cross-platform (Unix/Linux, macOS, Windows) merge tool.</p> <ul> <li>How do I set up and use Meld as my Git difftool?</li> <li>How do I set up and use Meld as my Git mergetool?</li> </ul>
351,134
2,102,457
2025-01-01 10:14:36
34,119,867
673
2015-12-06 16:35:03
2,102,457
2024-08-04 17:28:24
https://stackoverflow.com/q/34119866
https://stackoverflow.com/a/34119867
<h2>How do I set up and use Meld as my Git difftool?</h2> <p><a href="http://git-scm.com/docs/git-difftool" rel="noreferrer"><code>git difftool</code></a> displays the diff using a GUI diff program (i.e., Meld) instead of displaying the diff output in your terminal.</p> <p>Although you can set the GUI program on the co...
<h2>How do I set up and use Meld as my Git difftool?</h2> <p><a href="http://git-scm.com/docs/git-difftool" rel="noreferrer"><code>git difftool</code></a> displays the diff using a GUI diff program (i.e., Meld) instead of displaying the diff output in your terminal.</p> <p>Although you can set the GUI program on the co...
119, 13630
git, meld
<h1>Setting up and using Meld as your Git difftool and mergetool</h1> <p><a href="https://meldmerge.org/" rel="noreferrer">Meld</a> is a popular free, open-source, and cross-platform (Unix/Linux, macOS, Windows) merge tool.</p> <ul> <li>How do I set up and use Meld as my Git difftool?</li> <li>How do I set up and use M...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,181
git
# Setting up and using Meld as your Git difftool and mergetool [Meld](https://meldmerge.org/) is a popular free, open-source, and cross-platform (Unix/Linux, macOS, Windows) merge tool. - How do I set up and use Meld as my Git difftool? - How do I set up and use Meld as my Git mergetool?
## How do I set up and use Meld as my Git difftool? [`git difftool`](http://git-scm.com/docs/git-difftool) displays the diff using a GUI diff program (i.e., Meld) instead of displaying the diff output in your terminal. Although you can set the GUI program on the command line using `-t <tool> / --tool=<tool>` it makes...
3203228
git ignore exception
494
2010-07-08 11:54:13
<p>I have a gitignore file that makes git ignore <code>*.dll</code> files, and that is actually the behavior I want. However, if I want an exception ( i.e. to be able to commit <code>foo.dll</code>), how can I achieve this?</p>
177,283
162,325
2022-05-25 15:45:54
3,203,249
667
2010-07-08 11:55:30
49,376
2010-07-08 11:55:30
https://stackoverflow.com/q/3203228
https://stackoverflow.com/a/3203249
<p>Use:</p> <pre><code>*.dll #Exclude all dlls !foo.dll #Except for foo.dll </code></pre> <p>From <a href="http://git-scm.com/docs/gitignore" rel="noreferrer">gitignore</a>:</p> <blockquote> <p>An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included ...
<p>Use:</p> <pre><code>*.dll #Exclude all dlls !foo.dll #Except for foo.dll </code></pre> <p>From <a href="http://git-scm.com/docs/gitignore" rel="noreferrer">gitignore</a>:</p> <blockquote> <p>An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included ...
119, 25056
git, gitignore
<h1>git ignore exception</h1> <p>I have a gitignore file that makes git ignore <code>*.dll</code> files, and that is actually the behavior I want. However, if I want an exception ( i.e. to be able to commit <code>foo.dll</code>), how can I achieve this?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,183
git
# git ignore exception I have a gitignore file that makes git ignore `*.dll` files, and that is actually the behavior I want. However, if I want an exception ( i.e. to be able to commit `foo.dll`), how can I achieve this?
Use: ``` *.dll #Exclude all dlls !foo.dll #Except for foo.dll ``` From [gitignore](http://git-scm.com/docs/gitignore): > An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence pa...
35978550
How to show uncommitted changes in Git and some Git diffs in detail
403
2016-03-14 02:20:58
<p>How do I show uncommitted changes in Git?</p> <p>I <a href="https://en.wiktionary.org/wiki/STFW#Verb" rel="noreferrer">STFW'ed</a>, and these commands are not working:</p> <pre><code>teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice) $ git status On branch teyan/psservice Your branch is up...
611,307
3,822,670
2024-03-14 17:00:17
35,978,722
665
2016-03-14 02:44:03
1,755,598
2023-02-17 13:01:08
https://stackoverflow.com/q/35978550
https://stackoverflow.com/a/35978722
<blockquote> <p><em><strong>How to show uncommitted changes in Git</strong></em></p> </blockquote> <p>The command you are looking for is <a href="https://git-scm.com/docs/git-diff" rel="noreferrer"><em><strong><code>git diff</code></strong></em></a>.</p> <blockquote> <p><em><strong><code>git diff</code></strong></em> -...
<blockquote> <p><em><strong>How to show uncommitted changes in Git</strong></em></p> </blockquote> <p>The command you are looking for is <a href="https://git-scm.com/docs/git-diff" rel="noreferrer"><em><strong><code>git diff</code></strong></em></a>.</p> <blockquote> <p><em><strong><code>git diff</code></strong></em> -...
119, 9033
git, git-diff
<h1>How to show uncommitted changes in Git and some Git diffs in detail</h1> <p>How do I show uncommitted changes in Git?</p> <p>I <a href="https://en.wiktionary.org/wiki/STFW#Verb" rel="noreferrer">STFW'ed</a>, and these commands are not working:</p> <pre><code>teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,184
git
# How to show uncommitted changes in Git and some Git diffs in detail How do I show uncommitted changes in Git? I [STFW'ed](https://en.wiktionary.org/wiki/STFW#Verb), and these commands are not working: ``` teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice) $ git status On branch teyan/psser...
> ***How to show uncommitted changes in Git*** The command you are looking for is [***`git diff`***](https://git-scm.com/docs/git-diff). > ***`git diff`*** - Show changes between commits, commit and working tree, etc --- Here are some of the options it expose which you can use ***`git diff`*** (no parameters) Pr...
2405305
How to tell if a file is git tracked (by shell exit code)?
505
2010-03-08 22:31:04
<p>Is there a way to tell if a file is being tracked by running some <code>git</code> command and checking its exit code?</p> <p>In other words: is git tracking a file?</p>
188,601
285,546
2025-12-26 18:46:03
2,406,813
660
2010-03-09 05:12:15
35,364
2017-08-08 17:06:51
https://stackoverflow.com/q/2405305
https://stackoverflow.com/a/2406813
<p>try:</p> <pre><code>git ls-files --error-unmatch &lt;file name&gt; </code></pre> <p>will exit with 1 if file is not tracked</p>
<p>try:</p> <pre><code>git ls-files --error-unmatch &lt;file name&gt; </code></pre> <p>will exit with 1 if file is not tracked</p>
119
git
<h1>How to tell if a file is git tracked (by shell exit code)?</h1> <p>Is there a way to tell if a file is being tracked by running some <code>git</code> command and checking its exit code?</p> <p>In other words: is git tracking a file?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,187
git
# How to tell if a file is git tracked (by shell exit code)? Is there a way to tell if a file is being tracked by running some `git` command and checking its exit code? In other words: is git tracking a file?
try: ``` git ls-files --error-unmatch <file name> ``` will exit with 1 if file is not tracked
9035895
How do I add Git submodule to a sub-directory?
467
2012-01-27 15:39:08
<p>I have a Git repo in <code>~/.janus/</code> with a bunch of submodules in it. I want to add a submodule in <code>~/.janus/snipmate-snippets/snippets/</code>, but when I run <code>git submodule add &lt;git@github.com:...&gt;</code> in the <code>snipmate-snippets</code> directory, I get the following error message:</p...
475,637
123,016
2024-07-08 07:46:34
9,035,930
658
2012-01-27 15:41:40
247,675
2022-08-07 23:49:11
https://stackoverflow.com/q/9035895
https://stackoverflow.com/a/9035930
<p>You go into <code>~/.janus</code> and run:</p> <pre><code>git submodule add &lt;git@github ...&gt; snipmate-snippets/snippets/ </code></pre> <p>If you need more information about submodules (or git in general) <a href="https://git-scm.com/book/en/v2/Git-Tools-Submodules" rel="noreferrer">ProGit</a> is pretty useful....
<p>You go into <code>~/.janus</code> and run:</p> <pre><code>git submodule add &lt;git@github ...&gt; snipmate-snippets/snippets/ </code></pre> <p>If you need more information about submodules (or git in general) <a href="https://git-scm.com/book/en/v2/Git-Tools-Submodules" rel="noreferrer">ProGit</a> is pretty useful....
119, 41612
git, git-submodules
<h1>How do I add Git submodule to a sub-directory?</h1> <p>I have a Git repo in <code>~/.janus/</code> with a bunch of submodules in it. I want to add a submodule in <code>~/.janus/snipmate-snippets/snippets/</code>, but when I run <code>git submodule add &lt;git@github.com:...&gt;</code> in the <code>snipmate-snippets...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,188
git
# How do I add Git submodule to a sub-directory? I have a Git repo in `~/.janus/` with a bunch of submodules in it. I want to add a submodule in `~/.janus/snipmate-snippets/snippets/`, but when I run `git submodule add <git@github.com:...>` in the `snipmate-snippets` directory, I get the following error message: ``` ...
You go into `~/.janus` and run: ``` git submodule add <git@github ...> snipmate-snippets/snippets/ ``` If you need more information about submodules (or git in general) [ProGit](https://git-scm.com/book/en/v2/Git-Tools-Submodules) is pretty useful.
6682740
How can I unstage my files again after making a local commit?
403
2011-07-13 17:05:00
<p>I have executed the following command</p> <pre><code>git add &lt;foo.java&gt; git commit -m "add the foo.java file" </code></pre> <p>How can I delete my local commit now and unstage foo.java?</p> <p>If I type <code>git reset --hard</code>, I found that it reverts my modified <code>foo.java</code> to the original ...
508,755
514,316
2020-05-15 14:52:39
6,682,881
658
2011-07-13 17:15:22
484,899
2019-02-17 02:45:06
https://stackoverflow.com/q/6682740
https://stackoverflow.com/a/6682881
<p><code>git reset --soft HEAD~1</code> should do what you want. After this, you'll have the first changes in the index (visible with <code>git diff --cached</code>), and your newest changes not staged. <code>git status</code> will then look like this:</p> <pre><code># On branch master # Changes to be committed: # (...
<p><code>git reset --soft HEAD~1</code> should do what you want. After this, you'll have the first changes in the index (visible with <code>git diff --cached</code>), and your newest changes not staged. <code>git status</code> will then look like this:</p> <pre><code># On branch master # Changes to be committed: # (...
119
git
<h1>How can I unstage my files again after making a local commit?</h1> <p>I have executed the following command</p> <pre><code>git add &lt;foo.java&gt; git commit -m "add the foo.java file" </code></pre> <p>How can I delete my local commit now and unstage foo.java?</p> <p>If I type <code>git reset --hard</code>, I f...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,189
git
# How can I unstage my files again after making a local commit? I have executed the following command ``` git add <foo.java> git commit -m "add the foo.java file" ``` How can I delete my local commit now and unstage foo.java? If I type `git reset --hard`, I found that it reverts my modified `foo.java` to the origin...
`git reset --soft HEAD~1` should do what you want. After this, you'll have the first changes in the index (visible with `git diff --cached`), and your newest changes not staged. `git status` will then look like this: ``` # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # ...
1526794
Rename master branch for both local and remote Git repositories
891
2009-10-06 16:51:57
<p>I have the branch <code>master</code> which tracks the remote branch <code>origin/master</code>.</p> <p>I want to rename them to <code>master-old</code> both locally and on the remote. Is this possible? </p> <p>For other users who tracked <code>origin/master</code> (and who always updated their local <code>master<...
335,990
133,374
2022-11-09 03:39:57
1,527,004
654
2009-10-06 17:35:11
36,723
2021-04-09 18:36:23
https://stackoverflow.com/q/1526794
https://stackoverflow.com/a/1527004
<p>The closest thing to renaming is deleting and then recreating on the remote. For example:</p> <pre class="lang-bash prettyprint-override"><code>git branch -m master master-old git push remote :master # Delete master git push remote master-old # Create master-old on remote git checkout -b master some-re...
<p>The closest thing to renaming is deleting and then recreating on the remote. For example:</p> <pre class="lang-bash prettyprint-override"><code>git branch -m master master-old git push remote :master # Delete master git push remote master-old # Create master-old on remote git checkout -b master some-re...
119, 28896, 76220
git, git-branch, git-pull
<h1>Rename master branch for both local and remote Git repositories</h1> <p>I have the branch <code>master</code> which tracks the remote branch <code>origin/master</code>.</p> <p>I want to rename them to <code>master-old</code> both locally and on the remote. Is this possible? </p> <p>For other users who tracked <co...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,190
git
# Rename master branch for both local and remote Git repositories I have the branch `master` which tracks the remote branch `origin/master`. I want to rename them to `master-old` both locally and on the remote. Is this possible? For other users who tracked `origin/master` (and who always updated their local `master`...
The closest thing to renaming is deleting and then recreating on the remote. For example: ``` git branch -m master master-old git push remote :master # Delete master git push remote master-old # Create master-old on remote git checkout -b master some-ref # Create a new local master git push remote master...
5066041
moving committed (but not pushed) changes to a new branch after pull
661
2011-02-21 12:39:43
<p>I've done a fair bit of work ("Your branch is ahead of 'origin/master' by 37 commits.") which really should have gone into its own branch rather than into <code>master</code>. These commits only exist on my local machine and have not been pushed to <code>origin</code>, but the situation is complicated somewhat in t...
320,341
18,914
2025-04-28 11:08:32
5,066,120
653
2011-02-21 12:45:22
223,092
2011-02-21 12:58:51
https://stackoverflow.com/q/5066041
https://stackoverflow.com/a/5066120
<p>This should be fine, since you haven't pushed your commits anywhere else yet, and you're free to rewrite the history of your branch after <code>origin/master</code>. First I would run a <code>git fetch origin</code> to make sure that <code>origin/master</code> is up to date. Assuming that you're currently on <code...
<p>This should be fine, since you haven't pushed your commits anywhere else yet, and you're free to rewrite the history of your branch after <code>origin/master</code>. First I would run a <code>git fetch origin</code> to make sure that <code>origin/master</code> is up to date. Assuming that you're currently on <code...
119
git
<h1>moving committed (but not pushed) changes to a new branch after pull</h1> <p>I've done a fair bit of work ("Your branch is ahead of 'origin/master' by 37 commits.") which really should have gone into its own branch rather than into <code>master</code>. These commits only exist on my local machine and have not been...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,191
git
# moving committed (but not pushed) changes to a new branch after pull I've done a fair bit of work ("Your branch is ahead of 'origin/master' by 37 commits.") which really should have gone into its own branch rather than into `master`. These commits only exist on my local machine and have not been pushed to `origin`, ...
This should be fine, since you haven't pushed your commits anywhere else yet, and you're free to rewrite the history of your branch after `origin/master`. First I would run a `git fetch origin` to make sure that `origin/master` is up to date. Assuming that you're currently on `master`, you should be able to do: ``` gi...
1196415
What datatype to use when storing latitude and longitude data in SQL databases?
427
2009-07-28 20:04:59
<p>When storing latitude or longitude data in an ANSI SQL compliant database, what datatype would be most appropriate? Should <code>float</code> be used, or <code>decimal</code>, or ...?</p> <p>I'm aware that Oracle, MySql, and SQL Server have added some special datatypes specifically for handling geo data, but I'm in...
370,736
19,112
2023-12-12 21:11:26
1,196,429
653
2009-07-28 20:07:09
40,822
2021-05-05 15:37:05
https://stackoverflow.com/q/1196415
https://stackoverflow.com/a/1196429
<p>For latitudes use: <code>Decimal(8,6)</code>, and longitudes use: <code>Decimal(9,6)</code></p> <p>If you're not used to precision and scale parameters, here's a format string visual:</p> <p>Latitude and Longitude <code>##.######</code> and <code>###.######</code></p> <p>To 6 decimal places should get you to around ...
<p>For latitudes use: <code>Decimal(8,6)</code>, and longitudes use: <code>Decimal(9,6)</code></p> <p>If you're not used to precision and scale parameters, here's a format string visual:</p> <p>Latitude and Longitude <code>##.######</code> and <code>###.######</code></p> <p>To 6 decimal places should get you to around ...
22, 30, 2965, 20301
database, geocoding, latitude-longitude, sql
<h1>What datatype to use when storing latitude and longitude data in SQL databases?</h1> <p>When storing latitude or longitude data in an ANSI SQL compliant database, what datatype would be most appropriate? Should <code>float</code> be used, or <code>decimal</code>, or ...?</p> <p>I'm aware that Oracle, MySql, and SQ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,192
git
# What datatype to use when storing latitude and longitude data in SQL databases? When storing latitude or longitude data in an ANSI SQL compliant database, what datatype would be most appropriate? Should `float` be used, or `decimal`, or ...? I'm aware that Oracle, MySql, and SQL Server have added some special datat...
For latitudes use: `Decimal(8,6)`, and longitudes use: `Decimal(9,6)` If you're not used to precision and scale parameters, here's a format string visual: Latitude and Longitude `##.######` and `###.######` To 6 decimal places should get you to around ~10cm of accuracy on a coordinate.
4456532
How can I see what has changed in a file before committing to git?
437
2010-12-16 01:04:01
<p>I've noticed that while working on one or two tickets, if I step away, I'm not sure what I worked on, what changed, etcetera.</p> <p>Is there a way to see the changes made for a given file before git add and then git commit?</p>
371,122
92,679
2022-06-08 14:33:17
4,456,846
652
2010-12-16 02:03:03
119,963
2020-08-22 22:41:01
https://stackoverflow.com/q/4456532
https://stackoverflow.com/a/4456846
<p>You're looking for</p> <h3><a href="http://git-scm.com/docs/git-diff" rel="noreferrer"><code>git diff --staged</code></a></h3> <p>Depending on your exact situation, there are three useful ways to use <code>git diff</code>:</p> <ol> <li>Show differences between index and working tree; that is, changes you haven't sta...
<p>You're looking for</p> <h3><a href="http://git-scm.com/docs/git-diff" rel="noreferrer"><code>git diff --staged</code></a></h3> <p>Depending on your exact situation, there are three useful ways to use <code>git diff</code>:</p> <ol> <li>Show differences between index and working tree; that is, changes you haven't sta...
119
git
<h1>How can I see what has changed in a file before committing to git?</h1> <p>I've noticed that while working on one or two tickets, if I step away, I'm not sure what I worked on, what changed, etcetera.</p> <p>Is there a way to see the changes made for a given file before git add and then git commit?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,193
git
# How can I see what has changed in a file before committing to git? I've noticed that while working on one or two tickets, if I step away, I'm not sure what I worked on, what changed, etcetera. Is there a way to see the changes made for a given file before git add and then git commit?
You're looking for ### [`git diff --staged`](http://git-scm.com/docs/git-diff) Depending on your exact situation, there are three useful ways to use `git diff`: 1. Show differences between index and working tree; that is, changes you haven't staged to commit: ``` git diff [filename] ``` 2. Show differences between...
7527982
Applying .gitignore to committed files
630
2011-09-23 11:02:14
<p>I have committed loads of files that I now want to ignore. How can I tell git to now ignore these files from future commits? </p> <p>EDIT: I do want to remove them from the repository too. They are files created after ever build or for user-specific tooling support.</p>
232,647
880,954
2024-08-07 17:38:32
7,528,016
650
2011-09-23 11:05:50
139,010
2016-12-14 22:23:02
https://stackoverflow.com/q/7527982
https://stackoverflow.com/a/7528016
<ol> <li>Edit <code>.gitignore</code> to match the file you want to ignore</li> <li><code>git rm --cached /path/to/file</code></li> </ol> <p>See also:</p> <ul> <li><a href="https://stackoverflow.com/questions/1273108/how-do-i-git-rm-a-file-without-deleting-it-from-disk">How do I git rm a file without deleting it from...
<ol> <li>Edit <code>.gitignore</code> to match the file you want to ignore</li> <li><code>git rm --cached /path/to/file</code></li> </ol> <p>See also:</p> <ul> <li><a href="https://stackoverflow.com/questions/1273108/how-do-i-git-rm-a-file-without-deleting-it-from-disk">How do I git rm a file without deleting it from...
119
git
<h1>Applying .gitignore to committed files</h1> <p>I have committed loads of files that I now want to ignore. How can I tell git to now ignore these files from future commits? </p> <p>EDIT: I do want to remove them from the repository too. They are files created after ever build or for user-specific tooling support.</...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,194
git
# Applying .gitignore to committed files I have committed loads of files that I now want to ignore. How can I tell git to now ignore these files from future commits? EDIT: I do want to remove them from the repository too. They are files created after ever build or for user-specific tooling support.
1. Edit `.gitignore` to match the file you want to ignore 2. `git rm --cached /path/to/file` See also: - [How do I git rm a file without deleting it from disk?](https://stackoverflow.com/questions/1273108/how-do-i-git-rm-a-file-without-deleting-it-from-disk) - [Remove a file from a Git repository without deleting it ...
16086962
How to get a time zone from a location using latitude and longitude coordinates?
468
2013-04-18 15:24:09
<p>Given the latitude and longitude of a location, how does one know what time zone is in effect in that location?</p> <p>In most cases, we are looking for an IANA/Olson time zone id, although some services may return just a UTC offset, or some other time zone identifier. Please read the <a href="https://stackoverflow...
414,853
634,824
2023-12-31 18:59:58
16,086,964
650
2013-04-18 15:24:09
634,824
2023-12-31 18:59:58
https://stackoverflow.com/q/16086962
https://stackoverflow.com/a/16086964
<p><strong>Time Zone Location Web Services</strong></p> <ul> <li><a href="https://developers.google.com/maps/documentation/timezone/" rel="noreferrer">Google Maps Time Zone API</a></li> <li><a href="https://learn.microsoft.com/bingmaps/rest-services/timezone/" rel="noreferrer">Bing Maps Time Zone API</a></li> <li><a hr...
<p><strong>Time Zone Location Web Services</strong></p> <ul> <li><a href="https://developers.google.com/maps/documentation/timezone/" rel="noreferrer">Google Maps Time Zone API</a></li> <li><a href="https://learn.microsoft.com/bingmaps/rest-services/timezone/" rel="noreferrer">Bing Maps Time Zone API</a></li> <li><a hr...
982, 10580, 20301
geolocation, latitude-longitude, timezone
<h1>How to get a time zone from a location using latitude and longitude coordinates?</h1> <p>Given the latitude and longitude of a location, how does one know what time zone is in effect in that location?</p> <p>In most cases, we are looking for an IANA/Olson time zone id, although some services may return just a UTC o...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,195
git
# How to get a time zone from a location using latitude and longitude coordinates? Given the latitude and longitude of a location, how does one know what time zone is in effect in that location? In most cases, we are looking for an IANA/Olson time zone id, although some services may return just a UTC offset, or some ...
**Time Zone Location Web Services** - [Google Maps Time Zone API](https://developers.google.com/maps/documentation/timezone/) - [Bing Maps Time Zone API](https://learn.microsoft.com/bingmaps/rest-services/timezone/) - [Azure Maps Time Zone API](https://learn.microsoft.com/en-us/rest/api/maps/timezone) - [GeoNames Time...
10564
How can I set up an editor to work with Git on Windows?
667
2008-08-14 01:43:04
<p>I'm trying out <strong>Git on Windows</strong>. I got to the point of trying "git commit" and I got this error:</p> <blockquote> <p>Terminal is dumb but no VISUAL nor EDITOR defined. Please supply the message using either -m or -F option.</p> </blockquote> <p>So I figured out I need to have an environment va...
465,682
437
2023-05-21 03:46:17
773,973
649
2009-04-21 18:34:54
6,309
2018-01-29 06:57:35
https://stackoverflow.com/q/10564
https://stackoverflow.com/a/773973
<p>Update September 2015 (6 years later)</p> <p>The <a href="https://github.com/git-for-windows/git/releases/tag/v2.5.3.windows.1" rel="noreferrer">last release of git-for-Windows (2.5.3)</a> now includes:</p> <blockquote> <p>By configuring <strong><code>git config core.editor notepad</code></strong>, users <a href...
<p>Update September 2015 (6 years later)</p> <p>The <a href="https://github.com/git-for-windows/git/releases/tag/v2.5.3.windows.1" rel="noreferrer">last release of git-for-Windows (2.5.3)</a> now includes:</p> <blockquote> <p>By configuring <strong><code>git config core.editor notepad</code></strong>, users <a href...
64, 119, 1731, 5025
cygwin, editor, git, windows
<h1>How can I set up an editor to work with Git on Windows?</h1> <p>I'm trying out <strong>Git on Windows</strong>. I got to the point of trying "git commit" and I got this error:</p> <blockquote> <p>Terminal is dumb but no VISUAL nor EDITOR defined. Please supply the message using either -m or -F option.</p> </...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,196
git
# How can I set up an editor to work with Git on Windows? I'm trying out **Git on Windows**. I got to the point of trying "git commit" and I got this error: > Terminal is dumb but no VISUAL nor > EDITOR defined. Please supply the > message using either -m or -F option. So I figured out I need to have an environment ...
Update September 2015 (6 years later) The [last release of git-for-Windows (2.5.3)](https://github.com/git-for-windows/git/releases/tag/v2.5.3.windows.1) now includes: > By configuring **`git config core.editor notepad`**, users [can now use `notepad.exe` as their default editor](https://github.com/git-for-windows/gi...
8533202
List files in local Git repo?
403
2011-12-16 10:59:40
<p>I'm using SparkleShare, which uses Git to sync files between my laptop and my backup server.</p> <p>Now I want to be able to browse the files and dirs that I've uploaded to my server, but I do not know how.</p> <p>I understand that Git uses some sort of special file hierarchy and that I cannot just list my files, ri...
301,623
1,101,781
2024-01-02 23:40:11
8,533,413
649
2011-12-16 11:16:37
176,769
2018-12-26 16:22:58
https://stackoverflow.com/q/8533202
https://stackoverflow.com/a/8533413
<p>This command:</p> <pre><code>git ls-tree --full-tree -r --name-only HEAD </code></pre> <p>lists all of the already committed files being tracked by your git repo. </p>
<p>This command:</p> <pre><code>git ls-tree --full-tree -r --name-only HEAD </code></pre> <p>lists all of the already committed files being tracked by your git repo. </p>
119
git
<h1>List files in local Git repo?</h1> <p>I'm using SparkleShare, which uses Git to sync files between my laptop and my backup server.</p> <p>Now I want to be able to browse the files and dirs that I've uploaded to my server, but I do not know how.</p> <p>I understand that Git uses some sort of special file hierarchy a...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,197
git
# List files in local Git repo? I'm using SparkleShare, which uses Git to sync files between my laptop and my backup server. Now I want to be able to browse the files and dirs that I've uploaded to my server, but I do not know how. I understand that Git uses some sort of special file hierarchy and that I cannot just...
This command: ``` git ls-tree --full-tree -r --name-only HEAD ``` lists all of the already committed files being tracked by your git repo.
433111
How to make git mark a deleted and a new file as a file move?
825
2009-01-11 16:01:08
<p>I've moved a file manually and then I've modified it. According to Git, it is a new file and a removed file. Is there any way to force Git into treating it as a file move?</p>
303,899
6,068
2025-09-09 09:45:07
433,142
647
2009-01-11 16:18:36
43,582
2024-01-03 23:57:04
https://stackoverflow.com/q/433111
https://stackoverflow.com/a/433142
<p>Git will automatically detect the move/rename if your modification is not too severe.</p> <p>Just <code>git add</code> the new file, and <code>git rm</code> the old file.</p> <p><code>git status</code> will then show whether it has detected the rename.</p> <p>additionally, for moves around directories, you may need ...
<p>Git will automatically detect the move/rename if your modification is not too severe.</p> <p>Just <code>git add</code> the new file, and <code>git rm</code> the old file.</p> <p><code>git status</code> will then show whether it has detected the rename.</p> <p>additionally, for moves around directories, you may need ...
119
git
<h1>How to make git mark a deleted and a new file as a file move?</h1> <p>I've moved a file manually and then I've modified it. According to Git, it is a new file and a removed file. Is there any way to force Git into treating it as a file move?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,198
git
# How to make git mark a deleted and a new file as a file move? I've moved a file manually and then I've modified it. According to Git, it is a new file and a removed file. Is there any way to force Git into treating it as a file move?
Git will automatically detect the move/rename if your modification is not too severe. Just `git add` the new file, and `git rm` the old file. `git status` will then show whether it has detected the rename. additionally, for moves around directories, you may need to: 1. cd to the top of that directory structure. 2. ...
253055
How do I push amended commit to the remote Git repository?
876
2008-10-31 10:23:14
<p>When I've worked a bit with my source code, I did my usual thing commit and then I pushed to a remote repository. But then I noticed I forgot to organize my imports in the source code. So I do the amend command to replace the previous commit:</p> <pre><code>&gt; git commit --amend </code></pre> <p>Unfortunately th...
680,849
3,713
2024-07-27 05:59:59
432,518
645
2009-01-11 07:36:32
null
2018-11-12 21:40:47
https://stackoverflow.com/q/253055
https://stackoverflow.com/a/432518
<p>I actually once pushed with <code>--force</code> and <code>.git</code> repository and got scolded by Linus <strong>BIG TIME</strong>. In general this will create a lot of problems for other people. A simple answer is "Don't do it".</p> <p>I see others gave the recipe for doing so anyway, so I won't repeat them her...
<p>I actually once pushed with <code>--force</code> and <code>.git</code> repository and got scolded by Linus <strong>BIG TIME</strong>. In general this will create a lot of problems for other people. A simple answer is "Don't do it".</p> <p>I see others gave the recipe for doing so anyway, so I won't repeat them her...
119, 30968, 53850
git, git-amend, git-commit
<h1>How do I push amended commit to the remote Git repository?</h1> <p>When I've worked a bit with my source code, I did my usual thing commit and then I pushed to a remote repository. But then I noticed I forgot to organize my imports in the source code. So I do the amend command to replace the previous commit:</p> <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,199
git
# How do I push amended commit to the remote Git repository? When I've worked a bit with my source code, I did my usual thing commit and then I pushed to a remote repository. But then I noticed I forgot to organize my imports in the source code. So I do the amend command to replace the previous commit: ``` > git comm...
I actually once pushed with `--force` and `.git` repository and got scolded by Linus **BIG TIME**. In general this will create a lot of problems for other people. A simple answer is "Don't do it". I see others gave the recipe for doing so anyway, so I won't repeat them here. But here is a tip to recover from the situa...
1527234
Finding a branch point with Git?
607
2009-10-06 18:22:29
<p>I have a repository with branches master and A and lots of merge activity between the two. How can I find the commit in my repository when branch A was created based on master?</p> <p>My repository basically looks like this:</p> <pre><code>-- X -- A -- B -- C -- D -- F (master) \ / \ / ...
295,781
1,070,430
2025-07-04 05:13:35
4,991,675
644
2011-02-14 11:35:35
313,756
2025-07-03 02:43:55
https://stackoverflow.com/q/1527234
https://stackoverflow.com/a/4991675
<p>I found that the answers I see here don't seem to <em>quite</em> give the answer you asked for (or that I was looking for) -- they seem to give the <code>G</code> commit, instead of the <code>A</code> commit.</p> <p>So, I've created the following tree (letters assigned in chronological order), so I could test things...
<p>I found that the answers I see here don't seem to <em>quite</em> give the answer you asked for (or that I was looking for) -- they seem to give the <code>G</code> commit, instead of the <code>A</code> commit.</p> <p>So, I've created the following tree (letters assigned in chronological order), so I could test things...
119, 1879
branch, git
<h1>Finding a branch point with Git?</h1> <p>I have a repository with branches master and A and lots of merge activity between the two. How can I find the commit in my repository when branch A was created based on master?</p> <p>My repository basically looks like this:</p> <pre><code>-- X -- A -- B -- C -- D -- F (m...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,200
git
# Finding a branch point with Git? I have a repository with branches master and A and lots of merge activity between the two. How can I find the commit in my repository when branch A was created based on master? My repository basically looks like this: ``` -- X -- A -- B -- C -- D -- F (master) \ / ...
I found that the answers I see here don't seem to *quite* give the answer you asked for (or that I was looking for) -- they seem to give the `G` commit, instead of the `A` commit. So, I've created the following tree (letters assigned in chronological order), so I could test things out: ``` A - B - D - F - G <- "mas...
3826748
How to search in commit messages using command line?
424
2010-09-29 23:59:27
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/746684/how-to-search-through-all-commits-in-the-repository">How to search through all commits in the repository?</a> </p> </blockquote> <p>Is there a way to search through commit headers using the command line?...
172,689
427,499
2022-07-11 22:39:11
3,826,800
643
2010-09-30 00:09:53
152,948
2022-07-11 22:39:11
https://stackoverflow.com/q/3826748
https://stackoverflow.com/a/3826800
<pre><code>git log --grep=&lt;pattern&gt; Limit the commits output to ones with log message that matches the specified pattern (regular expression). </code></pre> <p>from <a href="https://git-scm.com/docs/git-log#Documentation/git-log.txt---grepltpatterngt" rel="noreferrer"><code>git help log</code></a>.</p>
<pre><code>git log --grep=&lt;pattern&gt; Limit the commits output to ones with log message that matches the specified pattern (regular expression). </code></pre> <p>from <a href="https://git-scm.com/docs/git-log#Documentation/git-log.txt---grepltpatterngt" rel="noreferrer"><code>git help log</code></a>.</p>
119, 488
console, git
<h1>How to search in commit messages using command line?</h1> <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/746684/how-to-search-through-all-commits-in-the-repository">How to search through all commits in the repository?</a> </p> </blockquote> <p>Is there ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,202
git
# How to search in commit messages using command line? > **Possible Duplicate:** > [How to search through all commits in the repository?](https://stackoverflow.com/questions/746684/how-to-search-through-all-commits-in-the-repository) Is there a way to search through commit headers using the command line?
``` git log --grep=<pattern> Limit the commits output to ones with log message that matches the specified pattern (regular expression). ``` from [`git help log`](https://git-scm.com/docs/git-log#Documentation/git-log.txt---grepltpatterngt).
5471174
Move branch pointer to different commit without checkout
1,095
2011-03-29 10:37:03
<p>To move the branch pointer of a checked out branch, one can use the <code>git reset --hard</code> command. But how to move the branch pointer of a not-checked out branch to point at a different commit (keeping all other stuff like tracked remote branch)?</p>
618,346
209,706
2023-03-02 20:47:07
8,206,536
642
2011-11-21 02:06:00
37,685
2020-07-02 17:16:39
https://stackoverflow.com/q/5471174
https://stackoverflow.com/a/8206536
<p>You can do it for arbitrary refs. This is how to move a branch pointer:</p> <pre><code>git update-ref -m &quot;reset: Reset &lt;branch&gt; to &lt;new commit&gt;&quot; refs/heads/&lt;branch&gt; &lt;commit&gt; </code></pre> <p>where <code>-m</code> adds a message to the reflog for the branch.</p> <p>The general form i...
<p>You can do it for arbitrary refs. This is how to move a branch pointer:</p> <pre><code>git update-ref -m &quot;reset: Reset &lt;branch&gt; to &lt;new commit&gt;&quot; refs/heads/&lt;branch&gt; &lt;commit&gt; </code></pre> <p>where <code>-m</code> adds a message to the reflog for the branch.</p> <p>The general form i...
119, 76220
git, git-branch
<h1>Move branch pointer to different commit without checkout</h1> <p>To move the branch pointer of a checked out branch, one can use the <code>git reset --hard</code> command. But how to move the branch pointer of a not-checked out branch to point at a different commit (keeping all other stuff like tracked remote branc...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,203
git
# Move branch pointer to different commit without checkout To move the branch pointer of a checked out branch, one can use the `git reset --hard` command. But how to move the branch pointer of a not-checked out branch to point at a different commit (keeping all other stuff like tracked remote branch)?
You can do it for arbitrary refs. This is how to move a branch pointer: ``` git update-ref -m "reset: Reset <branch> to <new commit>" refs/heads/<branch> <commit> ``` where `-m` adds a message to the reflog for the branch. The general form is ``` git update-ref -m "reset: Reset <branch> to <new commit>" <ref> <comm...
5788037
Recover from losing uncommitted changes by "git reset --hard"
721
2011-04-26 08:52:08
<p>Is there any way to recover uncommitted changes to the working directory from a <code>git reset --hard HEAD</code>? </p>
452,107
84,359
2025-09-04 15:11:03
5,788,069
642
2011-04-26 08:55:05
85,371
2019-03-21 13:29:53
https://stackoverflow.com/q/5788037
https://stackoverflow.com/a/5788069
<p>You <em>cannot</em> get back uncommitted changes in general. </p> <p>Previously staged changes (<code>git add</code>) should be recoverable from index objects, so if you did, use <code>git fsck --lost-found</code> to locate the objects related to it. (This writes the objects to the <code>.git/lost-found/</code> dir...
<p>You <em>cannot</em> get back uncommitted changes in general. </p> <p>Previously staged changes (<code>git add</code>) should be recoverable from index objects, so if you did, use <code>git fsck --lost-found</code> to locate the objects related to it. (This writes the objects to the <code>.git/lost-found/</code> dir...
119
git
<h1>Recover from losing uncommitted changes by "git reset --hard"</h1> <p>Is there any way to recover uncommitted changes to the working directory from a <code>git reset --hard HEAD</code>? </p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,204
git
# Recover from losing uncommitted changes by "git reset --hard" Is there any way to recover uncommitted changes to the working directory from a `git reset --hard HEAD`?
You *cannot* get back uncommitted changes in general. Previously staged changes (`git add`) should be recoverable from index objects, so if you did, use `git fsck --lost-found` to locate the objects related to it. (This writes the objects to the `.git/lost-found/` directory; from there you can use `git show <filename>...
19542301
Delete all tags from a Git repository
379
2013-10-23 12:55:15
<p>I want to delete all the tags from a Git repository. How can I do that?</p> <p>Using <code>git tag -d tagname</code> delete the tag <code>tagname</code> locally, and using <code>git push --tags</code> I update the tags on the git provider.</p> <p>I tried:</p> <pre><code>git tag -d * </code></pre> <p>But I see th...
142,647
1,420,197
2025-08-28 16:32:13
19,542,426
642
2013-10-23 13:01:30
851,498
2021-04-30 06:36:37
https://stackoverflow.com/q/19542301
https://stackoverflow.com/a/19542426
<pre><code>git tag | xargs git tag -d </code></pre> <p>Simply follow the <a href="https://en.wikipedia.org/wiki/Unix_philosophy" rel="noreferrer">Unix philosophy</a> where you pipe everything.</p> <p>On Windows use git bash with the same command.</p>
<pre><code>git tag | xargs git tag -d </code></pre> <p>Simply follow the <a href="https://en.wikipedia.org/wiki/Unix_philosophy" rel="noreferrer">Unix philosophy</a> where you pipe everything.</p> <p>On Windows use git bash with the same command.</p>
119, 60718
git, git-tag
<h1>Delete all tags from a Git repository</h1> <p>I want to delete all the tags from a Git repository. How can I do that?</p> <p>Using <code>git tag -d tagname</code> delete the tag <code>tagname</code> locally, and using <code>git push --tags</code> I update the tags on the git provider.</p> <p>I tried:</p> <pre><c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,205
git
# Delete all tags from a Git repository I want to delete all the tags from a Git repository. How can I do that? Using `git tag -d tagname` delete the tag `tagname` locally, and using `git push --tags` I update the tags on the git provider. I tried: ``` git tag -d * ``` But I see that `*` means the files from the c...
``` git tag | xargs git tag -d ``` Simply follow the [Unix philosophy](https://en.wikipedia.org/wiki/Unix_philosophy) where you pipe everything. On Windows use git bash with the same command.
16862933
How to resolve git's "not something we can merge" error
515
2013-05-31 17:41:29
<p>I just encountered a problem when merging a branch into master in git. First, I got the branch name by running <code>git ls-remote</code>. Let's call that branch "branch-name". I then ran <code>git merge branch-name</code> command and got the following result:</p> <pre><code>fatal: branch-name - not something we ca...
612,101
1,486,275
2025-10-10 18:30:10
16,862,934
641
2013-05-31 17:41:29
1,486,275
2013-12-19 15:57:15
https://stackoverflow.com/q/16862933
https://stackoverflow.com/a/16862934
<p>As shown in <a href="https://stackoverflow.com/questions/14388625/how-does-not-something-we-can-merge-arise">How does &quot;not something we can merge&quot; arise?</a>, this error can arise from a typo in the branch name because you are trying to pull a branch that doesn't exist.</p> <p>If that is not the problem (...
<p>As shown in <a href="https://stackoverflow.com/questions/14388625/how-does-not-something-we-can-merge-arise">How does &quot;not something we can merge&quot; arise?</a>, this error can arise from a typo in the branch name because you are trying to pull a branch that doesn't exist.</p> <p>If that is not the problem (...
119, 53847
branching-and-merging, git
<h1>How to resolve git's "not something we can merge" error</h1> <p>I just encountered a problem when merging a branch into master in git. First, I got the branch name by running <code>git ls-remote</code>. Let's call that branch "branch-name". I then ran <code>git merge branch-name</code> command and got the following...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,208
git
# How to resolve git's "not something we can merge" error I just encountered a problem when merging a branch into master in git. First, I got the branch name by running `git ls-remote`. Let's call that branch "branch-name". I then ran `git merge branch-name` command and got the following result: ``` fatal: branch-nam...
As shown in [How does "not something we can merge" arise?](https://stackoverflow.com/questions/14388625/how-does-not-something-we-can-merge-arise), this error can arise from a typo in the branch name because you are trying to pull a branch that doesn't exist. If that is not the problem (as in my case), it is likely th...
372506
How can I search Git branches for a file or directory?
469
2008-12-16 20:02:03
<p>In Git, how could I search for a file or directory by path across a number of branches?</p> <p>I've written something in a branch, but I don't remember which one. Now I need to find it.</p> <p><strong>Clarification</strong>: I'm looking for a file which I created on one of my branches. I'd like to find it by pa...
223,331
4,937
2024-08-21 21:35:14
372,970
641
2008-12-16 22:17:50
39,975
2019-09-16 15:15:49
https://stackoverflow.com/q/372506
https://stackoverflow.com/a/372970
<p><code>git log</code> + <code>git branch</code> will find it for you:</p> <pre><code>% git log --all -- somefile commit 55d2069a092e07c56a6b4d321509ba7620664c63 Author: Dustin Sallings &lt;dustin@spy.net&gt; Date: Tue Dec 16 14:16:22 2008 -0800 added somefile % git branch -a --contains 55d2069 otherbranc...
<p><code>git log</code> + <code>git branch</code> will find it for you:</p> <pre><code>% git log --all -- somefile commit 55d2069a092e07c56a6b4d321509ba7620664c63 Author: Dustin Sallings &lt;dustin@spy.net&gt; Date: Tue Dec 16 14:16:22 2008 -0800 added somefile % git branch -a --contains 55d2069 otherbranc...
119, 1879
branch, git
<h1>How can I search Git branches for a file or directory?</h1> <p>In Git, how could I search for a file or directory by path across a number of branches?</p> <p>I've written something in a branch, but I don't remember which one. Now I need to find it.</p> <p><strong>Clarification</strong>: I'm looking for a file w...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,209
git
# How can I search Git branches for a file or directory? In Git, how could I search for a file or directory by path across a number of branches? I've written something in a branch, but I don't remember which one. Now I need to find it. **Clarification**: I'm looking for a file which I created on one of my branches. ...
`git log` + `git branch` will find it for you: ``` % git log --all -- somefile commit 55d2069a092e07c56a6b4d321509ba7620664c63 Author: Dustin Sallings <dustin@spy.net> Date: Tue Dec 16 14:16:22 2008 -0800 added somefile % git branch -a --contains 55d2069 otherbranch ``` Supports globbing, too: ``` % git ...
44048982
Abort a Git Merge
286
2017-05-18 13:22:04
<p>I am working on a project using Git as the VCS. I got a branch <code>xyz</code> cut from the mainline branch of master. After working for a while, I committed my code and took a pull of the branch mainline.</p> <p>The pull was fine. I then merged the code with master. After the merge, there were problems in certain...
463,880
4,340,520
2023-12-14 12:17:58
44,049,103
639
2017-05-18 13:27:35
7,023,245
2017-05-18 13:27:35
https://stackoverflow.com/q/44048982
https://stackoverflow.com/a/44049103
<p>as long as you did not commit you can type</p> <pre><code>git merge --abort </code></pre> <p>just as the command line suggested.</p>
<p>as long as you did not commit you can type</p> <pre><code>git merge --abort </code></pre> <p>just as the command line suggested.</p>
119, 28897
git, git-merge
<h1>Abort a Git Merge</h1> <p>I am working on a project using Git as the VCS. I got a branch <code>xyz</code> cut from the mainline branch of master. After working for a while, I committed my code and took a pull of the branch mainline.</p> <p>The pull was fine. I then merged the code with master. After the merge, the...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,210
git
# Abort a Git Merge I am working on a project using Git as the VCS. I got a branch `xyz` cut from the mainline branch of master. After working for a while, I committed my code and took a pull of the branch mainline. The pull was fine. I then merged the code with master. After the merge, there were problems in certain...
as long as you did not commit you can type ``` git merge --abort ``` just as the command line suggested.
35941566
Git says remote ref does not exist when I delete remote branch
311
2016-03-11 13:31:09
<p>I ran <code>git branch -a</code> </p> <pre><code>* master remotes/origin/test remotes/origin/master </code></pre> <p>I want to delete my remote branch </p> <p>I've tried </p> <pre><code>git push origin --delete remotes/origin/test </code></pre> <p>I got </p> <blockquote> <p>error: unable to delete 'remot...
180,417
4,480,164
2024-09-27 09:58:04
35,941,658
638
2016-03-11 13:35:51
216,074
2017-03-06 09:46:00
https://stackoverflow.com/q/35941566
https://stackoverflow.com/a/35941658
<p>The command <code>git branch -a</code> shows remote branches that exist <em>in your local repository</em>. This may sound a bit confusing but to understand it, you have to understand that there is a difference between a remote branch, and a branch that exists in a remote repository. Remote branches are <em>local</em...
<p>The command <code>git branch -a</code> shows remote branches that exist <em>in your local repository</em>. This may sound a bit confusing but to understand it, you have to understand that there is a difference between a remote branch, and a branch that exists in a remote repository. Remote branches are <em>local</em...
119
git
<h1>Git says remote ref does not exist when I delete remote branch</h1> <p>I ran <code>git branch -a</code> </p> <pre><code>* master remotes/origin/test remotes/origin/master </code></pre> <p>I want to delete my remote branch </p> <p>I've tried </p> <pre><code>git push origin --delete remotes/origin/test </code...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%git%'; a.Body LIKE '%<code>%git%'; q.Score > 5; a.Score > 10
14,211
git
# Git says remote ref does not exist when I delete remote branch I ran `git branch -a` ``` * master remotes/origin/test remotes/origin/master ``` I want to delete my remote branch I've tried ``` git push origin --delete remotes/origin/test ``` I got > error: unable to delete 'remotes/origin/test': remote ref...
The command `git branch -a` shows remote branches that exist *in your local repository*. This may sound a bit confusing but to understand it, you have to understand that there is a difference between a remote branch, and a branch that exists in a remote repository. Remote branches are *local* branches that map to branc...