Gitkraken - when rebasing error "cannot add submodule without HEAD to index" - gitkraken

I want to rebase in GitKraken, but it does not work and I see this error:
Cannot add submodule without HEAD to index
But if I do this in Git bash, everything works.
How is that?

Related

How to configure submodule remote and push

I have a third party repo as a submodule sub living in parent/data/.
In parent/data/sub/, git status gives me
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (use "git push" to publish your local commits)
#
nothing to commit, working directory clean
Apparently, I've made changes to the submodule and my local commit is recognised but has not pushed. Because the remote is origin/master, the third party repo, I get permission denied if I simply git push. However, pushing my customised and local changes to the original third party is not my goal anyway, as I only intend to customise the code so that I can use in my parent project.
Also, git show HEAD gives a hash abc123 (made dummy for illustration purpose) and the correct changes that I've made.
Under parent/, git submodule status gives me
abc123 data/sub (heads/master)
and vim .gitmodules gives me
[submodule "data/sub"]
path = data/sub
url = https://github.com/owner-id/sub
everything seems fine to me. The obvious issue it seems is the non-pushed commit mentioned above. As a result, when I navigate to my repo online at parent/data/sub#abc123 it shows 404. Meanwhile, when I try to git clone https://github.com/my-id/parent.git --recurse-submodules it shows
fatal: reference is not a tree: abc123
Unable to checkout 'abc123' in submodule path 'data/sub'
Question: how to push my local commits in sub to my own repo so that when others clone my parent the parent/data/sub is my customised version?
Eventually I forked a copy of the external repo and made that as the submodule. Apparently making changes to submodules so that everyone else can get the modified external repo is not the main use case of submodule, and it can't be done without forking first.

Github file removal after push

I accidentally pushed a file to my Github repository, and I am trying to understand where it is.
I have read many posts in here, but none of them had the solution, so I wanted to ask.
My steps were:
git status
git add normal_file.txt
git add sensitive_content_file.txt
git rm --cached sensitive_content_file.txt
#It was the time that I realized I have added a wrong file and need to remove it.
git commit -m "new changes"
git push
I saw that it pushed the "normal_file.txt " into my repository however I have not seen the "sensitive_content_file.txt" in my repository, so I assume it is not being pushed? So that all is okay?
I have tried to clean cache but now my repository complains as:
" Your branch and 'origin/master' have diverged, and have 1 and 1 different commit each, respectively."
However, I did not do any changes to itself.
How can I clear every connection to this file with I tried to remove its caches?
git rm --cached sensitive_content_file.txt before the commit was enough to not pushing it to GitHub.
But now, it would be best to add that file to your .gitignore, in order to be sure to not add it again by mistake:
echo sensitive_content_file.txt>>.gitignore
git add .gitignore
git commit -m "Ingore sensitive_content_file.txt"
git push
If you did any rebase/commit --amend, that would change the local history compared to what was pushed.
If you have not done any local modification, a git reset --hard origin/master would reset master, then you can modify the .gitignore and push.

GIT: fatal: ambiguous argument 'FETCH_HEAD': unknown revision or path not in the working tree

I'm working on branch of my git repository and I'm trying to reset all my changes using:
git reset --hard FETCH_HEAD
But I'm getting the following error:
fatal: ambiguous argument 'FETCH_HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Is the first I get this kind error reseting my changes on my repositories. Any of knows why or way around this error to reset my repository?
I'll really appreciate your help.
To overwrite any local changes and synchronize your repo to "origin", run these commands:
git fetch
git reset --hard origin
This is also useful when you rewrite git history with a rebase and git push -f to origin.
I use this when I'm working on changes on my dev system and building on a remote server. I don't necessarily want all of the little back and forth changes in my git history so I rebase and squash, but then a normal pull will not work on the remote server because the histories no longer align.

git / github unresolved conflicts but no visible differences

I am using eclipse, git and github. A friend of mine forked my github repo and changed some code. There was a pull request, I accepted the changes to my github repo. Now I tried to commit my own files and I am not able to 'commit and push'. As you can see in my screenshot there are no visible differences in the file. What procedure will solve this conflict?
Assuming your friend's work got merged into master and you are on branch your-feature-branch then:
git checkout master
git pull
git checkout your-feature-branch
git rebase master
will attempt to rebase your work on top of master, which already includes your friend's changes. The rebase procedure will process your commits one at a time and inform you of any conflicts which you can then resolve. Each file with conflicts will have conflict markers that tell you the changes introduced by each branch. After resolving the conflicts stage your changes then do
git rebase --continue
Repeat until rebase finishes. If at any point you become confused you can always abandon the rebase with
git rebase --abort
Once your work is rebased push your-feature-branch to origin, open a pull request, then merge.
I got the same issue sometimes, without a visible reason. Using a git rm on the directory containing the bad file, followed by a git reset --hard solved the issue for me.
git rm --cached -r DIRECTORY
git reset --hard

how to resolve conflict with git after autoformat in Eclipse?

We have two users working on the same class files in two separate git branches.
User A does nothing else but an "autoformat" Ctrl-Sift-F in Eclipse
User B just adds a space in a comment
Now we get a "conflicting change" and can't merge anymore.
Basically we are stuck just because of the autoformat.
How to resolve this situation in Eclipse git or on command line git bash?
You can use git merge -s ours or git merge -s their to decide which version of the file you wanna keep after the merge.
Resolve the conflict as you would with any merge conflict. It sounds like a pretty simple conflict to resolve. Or since the changes were trivial, the person doing the merge (i.e. the person who hasn't pushed their commit) can just reset back to a common commit, allowing them to pull the other person's changes.
git reset --hard THECOMMITID^
Where THECOMMITID is the unwanted formatting change. If it's just the most recent commit then you can use HEAD^.