"commit or discard the untracked or modified content in submodules" - gitlab

Since this morning I have a problem for committing my work :
I tried several commands to clean up my local repo but I still have the same problem, I have searched well in other topics where the problems encountered were similar to mine but the solutions differ without me being able to adapt anything ...
I await your answers
PS : Sorry for my lack of courtesy but obviously Stack Overflow does not want me to greet you ...

Actually it's not clear what you want to achieve exactly but to add the open change for committing just use
git add conFusion
Then you can commit again.
git commit -m "your description"
And finally push with
git push origin master
wheras origin master never seems to be required in your situation, so just git push will likely be enough.
I'm not sure why git commit -a didn't work, but the reason might be that the message with the parameter -m was missing.
Here you can find documentation about
git add
git commit
git push

Related

problem with my git repo, I lost all my commits?

I was trying to upload a file via terminal.I am trying to learn git.
**
git add /Users/serra/Documents/useSDWebImage
git commit -m "learning on process"
git remote add origin
git push -u origin master
**
then I got this message error: failed to push some refs to ....
I tried those commands then I have only the file I want to upload
to repository I have lost rest of the repository.What should I do?
**
git pull --rebase origin main
git push origin main
git pull origin master
git push origin master
git push origin master --force
**
TL;DR
You need to find a backup, somewhere, of origin/master.
git reflog might help you.
The error
First, let's go over your first four commands and explain what the mistake was.
In the first two commands, a git add and git commit, you are creating a commit in your local sandbox, building on whatever was in your sandbox beforehand.
In the third command, you add your remote, which means that your commit was not made on top of that remote, but on top of something else.
In your fourth command, Git correctly tells you that you cannot push, because your local sandbox is not built on top of the remote. It's important to pay attention to Git's error messages, they're almost always informative.
Now, you're not showing outputs from any of the commands you ran, but I'm guessing git push origin master --force is what deleted stuff on your remote.
What you should have done
Normally, you clone the remote first, then commit stuff on top of it:
git clone <URL>
cd <SANDBOX_DIR>
git add <file inside this directory>
git commit
git push
How to fix this
There are several ways, but they're all based on recovering stuff from a backup that hopefully exists somewhere.
If your remote is GitHub, it keeps a history of references, you should be able to find that old master branch somehow there. If your remote is some other server, that is hopefully true too. If another team member has a sandbox that had the valid master you want to restore, they can fix things by doing a git push origin master --force in their own sandbox, but make sure they understand what they're doing before they do it.
My answer here is not complete, because you didn't provide enough information. I will update it if you update your question with more details about your remote.
Update - git reflog might help
When you did git pull origin master, assuming master is the branch you care about, you probably got a local copy of the correct master commit you want on origin. You can use git reflog to see the history of your local HEAD in your sandbox. If you find the good commit there, this solution could work:
Here I'm assuming these is not work you want to preserve in your sandbox.
git checkout master
git reset --hard <good commit> # WARNING: destroys any uncommitted local changes
At this point, check that your sandbox contains the files you want to restore to origin. If so, proceed with this command:
git push --force origin master
But be warned, this will overwrite what's on origin. It's only appropriate if you have carefully validated that master in your sandbox really contains the history you want to restore on origin.

Commenting to issue when commiting to Gitlab does not work

I am running my own instance of a Gitlab-CE server with the following fairly-up-to-date specs:
Gitlab Version 10.8.4
Gitlab Shell 7.1.2
Gitlab Workhorse v4.2.1
Now my problem is that when I add a message to my commits referencing an issue, there is no commit mention in the issue as there should be.
As an example: git commit -m "handled issue #12" and the obligatory git push does not add anything to issue 12.
Any idea as to where the problem could be?
Edit: added the information that I am already pushing to the remote.
Found it: turns out that I had forgotten to change back my email adresse back to the one used in the remote repo – I had it changed locally a few weeks ago to test s.th.
So due to using my ssh key committing worked, but it showed the wrong user in my commits (which should have been a good hint for me as to what's up...) and due to that user not being a member of the project I had no access to the issues (at least that's my conclusion here).
Hope this might help anyone silly enough to run into similar issues...
git commit just creates a local commit in your branch. If you want GitLab to be aware of it, you need to push it:
$ git push origin my-branch

Close Gitlab issue via commit

I spend my day doing this:
Read an issue on a Gitlab-powered issue tracker,
Fix the issue,
Commit and push to the same Gitlab-powered Git server,
Mark the issue as closed.
To remove the 4th step, how can I close the issue automatically when committing?
Commit and push using this syntax:
git commit -m "Sort more efficiently" -m "Closes #843"
git push
This will commit and close the issue.
Note that unlike Github a single -m will not work.
The following will appear on the issue page:
References:
https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically
How to commit a change with both "message" and "description" from the command line?
According to this link from gitlab, you will be able to do that with a variety of words such as "fixes" or "closes". It does not need to be in a seperate line.
So you could have the following message:
Fixes #20. I had to replace "foo" with "bar".
And that will close issue #20.

Git fatal: cannot simplify commit

I have a repo that I have been committing for 2 months. I do not seem to get any error when I commit daily. However I was looking at git logs and I see that first ever git log (or maybe git can't see beyond that log point) has an error message like this
:100755 100755 1948ac6... 2af905e... M document.doc"
error: Could not read 190d54eb3278746a4e35fd4be82689eb4b1d20a8
fatal: cannot simplify commit cb0c2a3bf0a4ad665eb376b818bdcb0652a06eec (because of 190d54eb3278746a4e35fd4be82689eb4b1d20a8)
I tried the recommendation on: https://git.wiki.kernel.org/index.php/GitFaq#How_to_fix_a_broken_repository.3F
But I did not get what I was trying to achieve, whatever was recommended did not help my case.
This solution could help you:
Make a backup of your .git directory in case you corrupt things more in this process. Then, put back the best version of the packfiles you have available.
For each of the corrupt packfiles, run:
mv .git/objects/pack/pack-**yourpack**.pack oldpack
git-unpack-objects -r < oldpack
Run git fsck --full and git checkout again, give us the output.
Looks like now you should be able to check out, but you will have to run git checkout -f yourbranch, as you have changes in your working dir that are not yet committed. These changes will get lost when you run git checkout -f, though.
Note: This solution was sugested by #Chronial

git says Everything up-to-date

First of all, I am a noob at using git.
I was working on a project and did a commit and pushed to remote github repository.
But, then later I realized that I did some mistake, so I did $git --amend -am "My message"
Now, I was not able to push again to the remote server as I was getting error. So, I thought of deleting the remote github repo & recreated the same with the same name.
Now, when I try to push, it says "Everything up-to-date".
Please guide as to how do I solve this?
Sounds like two things have gone wrong, here.
First up, you amended a commit that had become part of the remote repository's history, which is a bit of a no-no. Rather than re-answer this gripe, I'll direct you to the answer: How do I push amended commit to the remote Git repository?
Next, chances are that even though you re-created the remote repository, your local repository still has the local history from the old one. what you'll want to do is run git remote rm origin, then git gc, then git remote add origin <path_to_repo>, then finally git fetch origin. This should pick up the new remote repository, and allow you to push your changes to it.

Resources