why is this not working like I expect it to:
how can I get my style sheets back?
git revert “commitID” did not work
why is this not working like I expect it to:
how can I get my style sheets back?
git revert “commitID” did not work
git checkout {commit hash}
, you don’t need to revert anything
Negative, that does not work.
that puts me in detached head state.
it does not let me commit back to the master branch. It gives me the option to checkout a new branch based off of the detached head. The new branch created from detached head looks good but merging that back to master does not work (i.e. I am still without my styles)
PS C:\wamp64\www\listings-master> git branch
* clean-filestructure
industrial-listing-app-5-16-simon
master
PS C:\wamp64\www\listings-master> git checkout master
Switched to branch 'master'
D admin/add_company.php
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
PS C:\wamp64\www\listings-master> git log --oneline
7215717 Revert "file structure cleanup"
d2fe38e (origin/master, origin/HEAD) Merge pull request #5 from KravMaguy/clean-filestructure
64ba617 (origin/clean-filestructure, clean-filestructure) file structure cleanup
b5b23b5 cleanup #2
d08f221 cleanup 1
4955458 social media
b0e6e21 my_listings
d66d818 uploads
462b0c0 fixed links
b60a41c admin area
PS C:\wamp64\www\listings-master> git checkout 64ba617
You are in 'detached HEAD' state. You can look around, make experimental
state without impacting any branches by performing another checkout.
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
D admin/add_company.php
PS C:\wamp64\www\listings-master> git checkout -b retain styles
fatal: 'styles' is not a commit and a branch 'retain' cannot be created from it
PS C:\wamp64\www\listings-master> git checkout -b retain-styles
Switched to a new branch 'retain-styles'
D admin/add_company.php
PS C:\wamp64\www\listings-master> git branch
clean-filestructure
industrial-listing-app-5-16-simon
master
tain-styles
Total 0 (delta 0), reused 0 (delta 0)
remote: tain-styles
remote: Create a pull request for 'retain-styles' on Giremote: https://github.com/KravMaguy/Industrial-listing-app/pull/new/retain-styles tHub by visiting:
remote: sting-app/pull/new/reta
To https://github.com/KravMaguy/Industrial-listing-app.Branch 'retain-styles' set up to track remote branch 'rPS C:\wamp64\www\listings-master> git branch git
clean-filestructure
industrial-listing-app-5-16-simon etain-styles' from 'ori
master
* retain-styles
PS C:\wamp64\www\listings-master> git checkout master
Switched to branch 'master'
D admin/add_company.php
Your branch is ahead of 'origin/master' by 2 commits.
PS C:\wamp64\www\listings-master> git merge retain-styles
Already up to date.
PS C:\wamp64\www\listings-master> git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: admin/add_company.php
PS C:\wamp64\www\listings-master> git branch
clean-filestructure
industrial-listing-app-5-16-simon
* master
retain-styles
Ive also verified that doing some change, and making a follow up commit off of the branch checked out from detached head and then trying to merge it back did not solve the problem either.
Checking out either of those two branches that were checked out from detached heads has what im looking for… Yet when I merge them to master I still dont have my styles.
I wish I knew a better answer as this has happened many times before. Ill make a mistake and then later realize I have to go back to some commit. My solution is always to checkout the detached head as a new branch, set that checked out branch as the new main branch, delete the master branch, and then rename that to master.
Have you tried adding a period after the commit id so you don’t have to worry about detached head?
git checkout <commit-id> .
That’s what I learned from this article when I try going back to a previous commit and not create a detached head.
Maybe this article will help.
There is also the nuclear option of git reset --hard <commit id>
.
It sounds like you are developing directly on main/master? This sort of thing is a good reason to develop features on a branch and merge the branch into the main branch.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.