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

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.

Related

Git merge conflict issue, gir merge conflict while pulling

My coworker and I are working in the same branch which was cut from develop. There are many files to be taken care of by both of us.
The scenario I’m facing is that
I did some changes and pushed my code to the remote repo. My coworker also did some changes in his local and and now he is not able to take a pull. It shows merge conflict while pulling.
Can someone let me know how can we resolve this?
Based on my understanding, I think we made some changes in the same files and now to merge them, git is causing that conflict.
First, make sure to use:
git config --global pull.rebase true
git config --global rebase.autoStash true
That way, a simple git pull will:
stash your work in progress
rebase your local commits (not yet pushed) on top of the updated remote upstream branch (instead of merging). That keep the history linear.
You can also activate rerere in order to not resolve the same conflict over and over again.
Finally, in case of merge/rebase conflict, you will need to chose between "our" and "their" version in each file with conflict markers. As shown here, an IDE can help facilitate the visualization and resolution of such conflicts.
I used tortoise git
git tortoise > git diff
Then I manually resolved the git merge conflict by removing or modifying the code I didn’t want.
Then I committed the code and the issues were gone.

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)

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).

Eclipse/Git - Pull Failed Dirty Worktree

As the title states, I'm attempting to pull from a git repository that I'm sharing between my friend and I and I can commit, he can commit, but whenever either one of us attempt to pull it brings back that it failed: DIRTY_WORKTREE
Both of us are extremely new to git, and have zero direction on how to fix this issue.
I was able to fix a similar issue by using the git command line client. While eclipse (egit) was only saying DIRTY_WORKTREE, in the command line I saw multiple conflicting files. Using git merge master from the command line, I could easily resolve the conflicts then in eclipse.
So for me this seems to be an egit issue.
Another approach, if you don't have any work in progress, is to try and reset --hard your HEAD.
With EGit: Resetting your current HEAD:
Select Team -> Reset... on a project. This opens a dialog where you can select a branch or a tag.
Reset HEAD on your current branch, in order to reset index and working tree to the last commit of said branch.
Then try your pull.
I had uncommitted changes. After I committed them, then merged, the dirty worktree issue disappeared.
Just delete the .gitignore present in the project folder, and then merge.
The merge will show conflicts , which you need to resolve and then push the changes.
It seems to mean that the version you are on now has edits that are not yet committed. So you either have to remove these edits, or commit them. Notice that if you commit them you may get merge conflicts.
This error is happening when you have made local changes to files that haven't been committed yet. In git's parlance, you have uncommitted changes in your working tree.
When you are in this situation and you try to pull, git is not sure what to do with the local changes you have. Should it discard those and pull the changes from the remote? Should it commit those before pulling the changes from the remote? That's why it fails.
To avoid this problem before you pull changes into your local repository you either have to commit your local changes, stash them, or discard them. Once you don't have pending local changes in your working tree, you should be able to pull with no errors.
In eclipse I went to Team Synchronizing View and from there right clicked on my project and hit 'overwrite' to overwrite all local changes. Then retry your merge.
Only to add another case, I've got DIRTY_WORKTREE, I'm the only one commiting to my Github project, so in EGit I did a Push branch... with "Force overwrite of branch on remote if it exists and has diverged"
DANGER: If other are working on the same project, this action will delete their commits since divergence.
I had similar problem on Eclipse with uncommited changes as ununiform.
After a commited I could merge and everything is back as it should be.
Take a look at your source code and check any changes. If none you can reset hard.
Delete the affected files and try to pull again. Thereafter push your changes to the git. I has the same issue and this worked for me.
In my case, the DIRTY_WORKTREE was caused by this sequence:
In a commit, I committed also some files that I should have ignored
In the next commit I modified the .gitignore that ignore the above files
Try to rebase on top of another branch where my change to .gitignore is missing
In this scenario, Eclipse thinks your working tree is dirty. Indeed, it is not obvious comparing two filesets when one of the two is ignoring some files and the other is not.
To solve the issue in Eclipse, I did the following:
Modify the .gitignore so it is the same as the one in the branch I want to rebase on
Happily start the rebasing or rebasing with merge.
If you have changes without commiting, eclipse will advise you if you try to pull changes. To solve it, you can discard the changes or do the commit of these files.
Source: https://www.eclipse.org/forums/index.php?t=msg&th=890477&goto=1565668&#msg_1565668
If you want to override you local branch to the origin branch.
Go to Git repo view> click on origin master> Choose reset ->it will show current HEAD and resetting to branch.
Choose HARD reset, if you want to completely overwrite your local changes
I think this problem is caused by EGit version.
When I used Spring Tools Suite with EGit 2.6, I also faced same problems.
EGit is included in STS Default package, so EGit upgrade is very difficult.
Currently I am using eclipse WTP with EGit 3.7, this problem is disappeared.