Linked Questions
84 questions linked to/from How can I reconcile detached HEAD with master/origin?
253
votes
2
answers
121k
views
How do I get my 'Detached HEAD' commits back into master [duplicate]
Looks like a few days ago I created a branch called detached HEAD and have been committing to it. My normal process is to commit to master and then push that to origin. But I can't push detached ...
2
votes
2
answers
2k
views
git stuck in detached head - cannot revert to previous file in branch [duplicate]
I committed a change to my script that completely broke it. I tried restoring to a previous commit in git using this command:
git checkout 2af6889905af99b78f7401cb17b718ba86240c2a aws_utils.sh
But ...
0
votes
1
answer
501
views
How to make detached head the original branch? [duplicate]
I have a branch. My local branch has 5 (m) commits which I have not pushed to remote. The same branch is 7 (n) commit ahead of me. Now what I want to do is remove my 5 (m) unnecessary commits and ...
1
vote
1
answer
259
views
Git branching django [duplicate]
I am looking to edit some of the documentation found on the django project. To do this I have forked, and cloned to my local machine a copy of the django repository on github.
The issue I am facing ...
1660
votes
21
answers
884k
views
How can I undo git reset --hard HEAD~1?
Is it possible to undo the changes caused by the following command? If so, how?
git reset --hard HEAD~1
1688
votes
19
answers
1.2m
views
How can I revert multiple Git commits?
I have a Git repository that looks like this:
A <- B <- C <- D <- HEAD
I want the head of the branch to point to A, i.e., I want B, C, D, and HEAD to disappear and I want head to be ...
852
votes
7
answers
1.1m
views
Go to a particular revision
I cloned a Git repository of a certain project. Can I turn the files to the initial state and when I review the files go to revision 2, 3, 4 ... most recent? I'd like to have an overview of how the ...
483
votes
15
answers
380k
views
Why did my Git repo enter a detached HEAD state?
I ended up with a detached head today, the same problem as described in: git push says everything up-to-date even though I have local changes
As far as I know I didn't do anything out of the ordinary,...
428
votes
7
answers
598k
views
Git update submodules recursively
My project struture
ProjectA
-FrameworkA (submodule)
--Twig (submodule of FrameworkA)
How I can update submodules recursively? I already tried some git commands (on ProjectA root)
git submodule ...
342
votes
6
answers
384k
views
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 ...
260
votes
10
answers
289k
views
Git: "Not currently on any branch." Is there an easy way to get back on a branch, while keeping the changes?
So I've done some work in the repository and when I'm about to commit I realize that I'm not currently on any branch.
This happens a lot when working with submodules and I am able to solve it, but ...
244
votes
9
answers
388k
views
Git clone particular version of remote repository
I cloned a remote git repository about a month ago. The remote repository has undergone many changes and has now become unstable. Now I need another copy of the repository, version identical to the ...
122
votes
7
answers
41k
views
Git restore last detached HEAD
I have a big problem in my project: this is the scenario.
I have an xcode project under Git. Today I realized that the last commit broke some tests, so i checked out the previous commit.
I used ...
85
votes
6
answers
93k
views
Git: How to move back and forth between commits
I have a newbie question about Git:
I need to move back and forth in a history of a branch.
That means, I need to get all the files to the state they were in in some old revision, and then I need to ...
70
votes
8
answers
16k
views
Where does a Git branch start and what is its length?
Every now and then I'm asked, on what commit a certain branch on git starts or if a certain commit has been created on a specific branch. The end point of a branch is pretty clear: that's where the ...
57
votes
2
answers
65k
views
How to move master to HEAD?
* [971f835] (HEAD, original_idea) Now working here. Some comment 9
* [692b673] Some comment 8
* [3ebff62] Reverted to original idea. Some comment 7
| * [72ea01d] (master) Decided it wasn't worth the ...
26
votes
2
answers
13k
views
How to recover commit from 'detached head state'?
I checked out another branch with updates then made a few changes, switched back to the main git and now the changes disappeared! Can I get them back? the terminal was basically:
$ git commit
[...
21
votes
6
answers
48k
views
cannot push to github: everything up-to-date
On github, I forked an old version of another project. I made some changes and am trying to push them onto my fork on github. I commited the changes locally, then tried git push, but this simply tells ...
33
votes
2
answers
17k
views
git checkout my_branch vs. git checkout origin/my_branch
I was on branch1 when I checkout branch2 like this (both branches are existing).
git checkout origin/branch2
then I got a detached head error:
You are in 'detached HEAD' state. You can look around, ...
28
votes
1
answer
23k
views
How to make submodule with detached HEAD to be attached to actual HEAD?
When I add a Git submodule to a Git repository like this,
git submodule add ssh://server/proj1/ proj1
git submodule init
git submodule update
the added submodule will be in detached HEAD mode. I don'...
6
votes
4
answers
9k
views
How to retrieve the git branch name that was built by Jenkins when using inverse branch selection strategy?
We have one Jenkins job which builds every branch except master when there are new commits. This behavior can be configured via git plugin's 'choosing strategy:inverse' so that it listens to every ...
17
votes
2
answers
2k
views
Why does Git not store the branch name as part of the commit?
Please note: I'm not trying to restart the argument whether Mercurial or Git is better, I just have a technical question that I, as a Mercurial user, don't understand. I'm also not sure whether SO is ...
6
votes
5
answers
15k
views
Set master branch to latest tag
This is an example of how my git repo is right now:
v1.0 v1.1 v1.2
| | |
a - b - c
| |
master HEAD
I usually commit, tag and push tags like ...
14
votes
2
answers
16k
views
Git Push From One Remote Branch To Another Remote Branch
I am working with three forked versions of a source code. FYI I changed the names to not disclose identities/repos. Here is how it is laid out:
MyMBP:~/Documents/_library$ git remote -v
abc https://...
13
votes
5
answers
9k
views
Can't get automated release working with Hudson + Git + Maven Release Plugin
As the title says, I'm trying to get an automated release job working on Hudson. It's a Maven project, and all the code is in Git. Manually, I do the release on my personal machine like so:
git ...
11
votes
1
answer
8k
views
HEAD detached at the HEAD commit id, what's the meaning?
git status says:
HEAD detached at e1997bd
and git rev-parse HEAD says:
e1997bd
What's the meaning of this?
I was thinking HEAD detached means HEAD is not pointing to to branch tip.
8
votes
3
answers
30k
views
Git push doesn't fail but doesn't work
I'm using Git and I'm in front of a several problem:
I can push, my coworkers can pull it, and the opposite. But the version which is on the remote is not up-to-date: if I write a TEST in the html, ...
9
votes
1
answer
9k
views
Git detached head issue
I've read many posts related to this issue today( one useful one here: Fix a Git detached head? & Why did my Git repo enter a detached HEAD state?).
Today I've been scratching my head. I'm not ...
2
votes
3
answers
21k
views
Git checkout to recent commit
I have a total of 24 commits, and I had checkout to commit 15. How can I go back to my last commit?
Note: I have run a lot of commits. For instances,
git revert, git checkout, git reset.
I don't know ...
3
votes
1
answer
8k
views
How to push with TortoiseGit
In push following errors occured
git.exe push "origin" master:master
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See ...