Skip to main content
I was wrong, so tone down a bit, fix minor issues.
Source Link
MayeulC
  • 1.8k
  • 20
  • 26

No, it's not. You hadNot that I knew of before editing this answer (the other solution rightly points to makegit fsck).

In case you come across the same situation, you should have made a git commit instead of a git merge --abort. 

As @Muneer Bits put it, I advise you to read a bit on the git basics. The official site contains a lot of documentation, and examples. You can even try it online with an interactive tutorial. The point is, you can't lose your work if it has been commited or stashed. I strongly encourage you to read the advices git is outputting all the time (unless you have an old version, in which case you should upgrade too). These tips should have told you to mark the commit resolved by adding the file first, then finalize the merge by performing a git commit.

Merge commits are just special commits with two parents. That means they need to be commitedcommitted at some point, be it automatically (if there is no conflict) or manually. When you aborted the merge, you reverted (reset) all your changes to the point you were before the merge. And thus you lost every changeschange you made.

Possible solution (depending on your workflow):

git pull
#merge conflict, solve it manually
git add modified_files_for_merging
git commit
touch test.txt
git add test.txt
git commit

Note that the merge wasn't aborted.

Be also aware that merging is not always the best solution when pulling. You can also pull with rebase. But I strongly encourage you to become a bit more familiar with git before attempting risky things with your work. And, as always, the solution you choose in the end will depend on your workflow.

No, it's not. You had to make a git commit instead of a git merge --abort. As @Muneer Bits put it, I advise you to read a bit on the git basics. The official site contains a lot of documentation, and examples. You can even try it online with an interactive tutorial. The point is, you can't lose your work if it has been commited or stashed. I strongly encourage you to read the advices git is outputting all the time (unless you have an old version, in which case you should upgrade too). These tips should have told you to mark the commit resolved by adding the file first, then finalize the merge by performing a git commit.

Merge commits are just special commits with two parents. That means they need to be commited at some point, be it automatically (if there is no conflict) or manually. When you aborted the merge, you reverted (reset) all your changes to the point you were before the merge. And thus you lost every changes you made.

Possible solution (depending on your workflow):

git pull
#merge conflict, solve it manually
git add modified_files_for_merging
git commit
touch test.txt
git add test.txt
git commit

Note that the merge wasn't aborted.

Be also aware that merging is not always the best solution when pulling. You can also pull with rebase. But I strongly encourage you to become a bit more familiar with git before attempting risky things with your work. And, as always, the solution you choose in the end will depend on your workflow.

Not that I knew of before editing this answer (the other solution rightly points to git fsck).

In case you come across the same situation, you should have made a git commit instead of a git merge --abort. 

As @Muneer Bits put it, I advise you to read a bit on the git basics. The official site contains a lot of documentation, and examples. You can even try it online with an interactive tutorial. The point is, you can't lose your work if it has been commited or stashed. I strongly encourage you to read the advices git is outputting all the time (unless you have an old version, in which case you should upgrade too). These tips should have told you to mark the commit resolved by adding the file first, then finalize the merge by performing a git commit.

Merge commits are just special commits with two parents. That means they need to be committed at some point, be it automatically (if there is no conflict) or manually. When you aborted the merge, you reverted (reset) all your changes to the point you were before the merge. And thus you lost every change you made.

Possible solution (depending on your workflow):

git pull
#merge conflict, solve it manually
git add modified_files_for_merging
git commit
touch test.txt
git add test.txt
git commit

Note that the merge wasn't aborted.

Be also aware that merging is not always the best solution when pulling. You can also pull with rebase. But I strongly encourage you to become a bit more familiar with git before attempting risky things with your work. And, as always, the solution you choose in the end will depend on your workflow.

Source Link
MayeulC
  • 1.8k
  • 20
  • 26

No, it's not. You had to make a git commit instead of a git merge --abort. As @Muneer Bits put it, I advise you to read a bit on the git basics. The official site contains a lot of documentation, and examples. You can even try it online with an interactive tutorial. The point is, you can't lose your work if it has been commited or stashed. I strongly encourage you to read the advices git is outputting all the time (unless you have an old version, in which case you should upgrade too). These tips should have told you to mark the commit resolved by adding the file first, then finalize the merge by performing a git commit.

Merge commits are just special commits with two parents. That means they need to be commited at some point, be it automatically (if there is no conflict) or manually. When you aborted the merge, you reverted (reset) all your changes to the point you were before the merge. And thus you lost every changes you made.

Possible solution (depending on your workflow):

git pull
#merge conflict, solve it manually
git add modified_files_for_merging
git commit
touch test.txt
git add test.txt
git commit

Note that the merge wasn't aborted.

Be also aware that merging is not always the best solution when pulling. You can also pull with rebase. But I strongly encourage you to become a bit more familiar with git before attempting risky things with your work. And, as always, the solution you choose in the end will depend on your workflow.