GitHub synchronize failure result in rebase - how to get back the committed file - github

I've made a commit to GitHub but the synchronization was not successful and it abort half way. When I try to get back the files I realized the files in local has been rebased to the previous version that I submitted during the last synchronization.
The new files and editions were lost. May I know whether there's any way to get back the lost data?(now it says "Rebase origin/master **" on my project)
Thank you!

Use the following:
git log
copy any previous commit id.
git reset "commitid".
Now you will have your changes.
Then commit and rebase.

Related

Where does git rebase store commit message during conflict resolution?

During a git rebase conflict resolution, where does git store the commit message for the commit I'm resolving conflicts for?
Sometimes when I run git commit, the COMMIT_EDITMSG will be pre-populated, other times, it won't be.
The commit message for the commit you are resolving conflicts for is stored in this file:
.git/rebase-merge/message
First, you hit a rebase conflict.
If you stage changes, run git commit - then COMMIT_EDITMSG will be pre-populated with .git/rebase-merge/message.
You can even add changes to a totally unrelated file without conflicts, and git will pre-populate for you.
It will continue to pre-populate with this message until you've successfully made one commit.
After the first commit, it will no longer pre-populate with .git/rebase-merge/message when you run git commit. Undoing last commit, and redo-ing will not cause it to pre-populate again.
The file at .git/rebase-merge/message will still be the same at this time, however. I'm not sure why git decides to stop pre-populating with this message.
Eventually, once you stage all changes, and run git rebase --continue, the COMMIT_EDITMSG will pre-populate again with .git/rebase-merge/message.
I would like to understand why git no longer pre-populates your COMMIT_EDITMSG once you've made one commit!

Deleted all my commit after bad manipulation in GitHub

After a bad manipulation I deleted all the commit of my git.
Can I recover all my commit ?
It's for a university project and the professor wants to see our work throughout the project.
I don't know if my problem become after the command
git pull --rebase origin master
or
git reset --mixed origin/master
or another comand...
Someone can help me please
Check first you git reflog: if your work was committed (before any git pull/reset command), you will be able to git restore (with Git 2.23+) any past commit.
The next step will be to see if you have added files to the index or not.
Anything not staged (added to the index) and not committed would be likely lost (except for disk recovery utilities, or local IDE history)

Github stuck, can't sync, can't revert

I have a merge remote-tracking branch 'origin/master' in my timeline with a dozen changes since then by someone else.
I can't sync. When I try to revert and git revert --continue, it says can't commit because I have unmerged files. No idea what that means.
I looked at the files in question and there are no conflict there (the git comment blocks).
Also, these filed specifically have not been modified by anyone else.
How do I just force Github to take the folder from my current local folder and just move on?
I tried deleting the repository folder and recloning, but then it saied it can't clone. Took a while just to get it to clone. But still can't sync!
Thanks!
Try stashing your changes and then syncing/merging.
git stash
git pull
git stash pop
This should merge your local from upstream and have your changes which you can commit.
Note: In some cases, this might lead to a conflict depending on your code, but that should not be a big problem to solve.
Also, unmerged means that you have files that are not committed yet. Do a git status and it should show you.

Lost a bunch of code in Github, mistakingly reverted to an old push, what are my options?

The commit no longer shows up but rather the latest one now is the one named "Instructions work".
https://images.discordapp.net/.eJwFwQEOwiAMAMC_8ABahqNlv2mYcUYpy9plica_e_cN5_EOS9jcd1sA1qe1cazRcpQun6FyWWyjg7hL2_pd3aAWKnijMuGMzFQYEiYkToyUa5pznRBOfem4NO76CL8_2w8gBg.u1qWiqmlxQgWvh_ROTa4VHx2gCY.png?format=webp
That's the screenshot of my commit. I had a merge error and googled how to resolve it and did it. Didn't notice my commit disappeared. Pressed sync thinking i was pushing my commit. Actually reverted and my commits are gone.
git revertshouldn't do anything except create a new commit -- you should be able to undo the revert by reverting to head with git revert HEAD
EDIT:
You can also search for dangling commit blobs in your lost and found history using git fsck --lost-found and then find the one you want and then apply the commit with git merge <SHA1 of commit>.
You can try reverting the actual revert commit.

How can I retrieve the local changed files which I wrongly reset in git

Below is the situation which explains what's the matter about git.
I was using the 'develop' branch and already made several changes to the local files such as .sql, .java, .js...
I made a local branch called 'develop_some_future' since my boss wants to confirm my changes before merging main 'develop' repository.
Apparently my local file changes #'develop' branch have applied to 'develop_some_future' branch and I started editing local files again.
For some reason, I tried to pull the files that my co-workers already committed, but it has failed(Probably I couldn't set 'develop_some_future' branch well). So, I changed current branch to 'develop' branch and tried to pull them.
Fortunately it got worked, and then I tried to back to the 'develop_some_future' branch.
A dialog pops up suddenly while changing the branch and asked me that 'your local change for "~~~.sql" would be deleted since it's not committed yet. To avoid this, please commit that file or choose reset.'
Because I thought only '~~~.sql' would be changed to the latest committed state and that was not a problem, I selected 'reset' button, but unfortunately all local changes have gone.
Anyone knows how can I retrieve the date before reset?
I found that both 'git reflog' and 'git reset HEAD{}' commands are useful.
However, git reflog shows only commit, merge, and checkout changes and so I can't find reset status at all.
I'm afraid your files are gone for good, unless you had previously staged the file somehow (add or stash save).
If it had been staged, a blob object was created by Git which is now dangling (git fsck will tell you dangling objects). You can then resurrect the file by writing the blob's content with git cat-file to a new file.
If not, your'e screwed, and you have to do your work again.
It seems the problem arose in the first place, because you thought that unstaged/uncommitted changes belong to the current branch. They do not, and only live in the working directory. They will be carried over when switching branches (unless, of course, the same file was modified in the branch. Git will then refuse to checkout the other branch).