Trouble pushing code to gitlab repository - github

Project owner (michael365) maintain a repository and has provided developer access to me. I am trying to push the code but I am getting this error
remote: GitLab: API is not accessible
To gitlab.com:michael365/bim.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#gitlab.com:michael365/bim.git'
although I have set the public key in the SSH section, it still it doesn't work. I am issuing the following commands
$ git add .
$ git commit -m "Adding Initial Code"
On branch master
nothing to commit, working tree clean
$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
$ git push --set-upstream origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 868 bytes | 868.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: GitLab: API is not accessible
To gitlab.com:michael365/bim.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#gitlab.com:michael365/bim.git'
Any suggestions would be helpful

pre-receive hook declined indicates that your push was rejected by remote repository after a content check on the changes you are pushing failed.
Ask the admin of remote repo as in what check is rejecting your push. Usually you get a proper error with message stating what check failed.

Related

Git unable to push to branch master even master branch is available?

I am unable to push to git master, even master branch is there. I have tried git push -u origin master .
git --version
git version 2.32.0.windows.2
The commands executed .
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin http://url
git push -u origin main **//master is not working**
main branch is working
I have created a remote repository say git_example and then in the same name created a local repository(git_example) and tried to push it to remote.
D:\WORKSPACE\REACT\ems-backend-springboot>git push -u origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/subhashisz/ems-backend-boot.git'
D:\WORKSPACE\REACT\ems-backend-springboot>git push -u origin main
Enumerating objects: 67, done.
Counting objects: 100% (67/67), done.
Delta compression using up to 4 threads
Compressing objects: 100% (54/54), done.
Writing objects: 100% (67/67), 68.39 KiB | 1.27 MiB/s, done.
Total 67 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), done.
remote:
remote: Create a pull request for 'main' on GitHub by visiting:
remote: https://github.com/subhashisz/ems-backend-boot/pull/new/main
remote:
To https://github.com/subhashisz/ems-backend-boot.git
* [new branch] main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
You already set your "main" branch as main via the command:
git branch -M main
and set any following "git push" to push to the main branch via the command:
git push -u origin main
so in order to push to master, you need to execute:
git push origin master
also in this stackoverflow question you can find how to change your upstream branch if already set:
git branch branch_name --set-upstream-to origin/branch_name

Pushing commit to github repository throwing error

The error I am getting:
To https://github.com/Git-Username/Repo.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/user/repo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Command I am executing:
git push origin master
I have tried nearly everything when I googled this error, I tried pulling etc.
I tried pulling etc.
pulling should have been enough to solve the issue.
But if your local history is correct (git log), and you are the only one pushig to that repository, you could also simply force push
git push --force -u origin master
That will override the history on the remote.

Can't push to remote repository in github

I'm new to github so for the sake of testing I've been modifying my .gitconfig file (adding some useful aliases, etc.) and pushing it to my "Config Files" repository on github.
I have 2 computers, a desktop and a laptop. When I modify the local file in the desktop, commit and push to the remote repository it works fine.
However, when I try to do the same from the laptop I get this error.
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/User/Config-Files.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Aditionally I get this error if I try to pull first like the message suggests:
$ git pull origin master
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 4 (delta 2), reused 4 (delta 2), pack-reused 0
Unpacking objects: 100% (4/4), 355 bytes | 8.00 KiB/s, done.
From https://github.com/User/Config-Files
* branch master -> FETCH_HEAD
627ab06..b327e2b master -> origin/master
fatal: refusing to merge unrelated histories
The remote repository only has the .gitconfig file, the same file I'm trying to push from the laptop so why am I getting this error?
The answer is in your terminal, it is telling you to fetch first.
You pushed to master already from your desktop, and your commit on your laptop is behind. So you have to fetch, merge, and then you'll be able to push from your laptop..
This is bad practice but can always force it in.. (--force) but then any of the changes made on your desktop would be gone.

Unable to push because of insufficient permission

Need help to resolve this as I've been working on this since Friday.
So when I'm trying to push my changes, I get this error.
git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags origin master:master
Pushing to ssh://<username>/projects/ssm/ssmportal
remote: error: insufficient permission for adding an object to repository database ./objects
remote: fatal: failed to write object
error: remote unpack failed: unpack-objects abnormal exit
To ssh://mantis-oil.microlink.com.my/projects/ssm/ssmportal
= [up to date] Deployment -> Deployment
! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'ssh://<username>/projects/ssm/ssmportal'
I tried most of what is mentioned in Google but it still does not work. What I do is to remove everything and download everything which is very tiring for me.
Can you please help me with this?
UPDATE
I tried the one which Chip suggested, but it still did not work. Below is the result.
From this SO Answer:
First do git pull --rebase and
then try git push
Hope you can find more information in the link provided.

SourceTree and GitHub: unable to pull / push after reseting to a previous commit

I messed my repository while trying to resolve conflicts. Everything was quite OK (I'm getting familiar with Git) but things got bad when I tried to reset the current branch to a previous commit (not knowing exactly what I was doing, I admit). In SourceTree, I now have 2 commits to Pull from GitHub and 10 commits to Push. When I tried to Pull, I got this:
git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin
git -c diff.mnemonicprefix=false -c core.quotepath=false pull --no-commit origin master
From https://github.com/JnLlnd/CSVBuddy
* branch master -> FETCH_HEAD
error: The following untracked working tree files would be overwritten by merge:
TEST-TheBeatles-Tab (1).txt
TEST-TheBeatles-Tab-EXPORT (1).txt
TEST-TheBeatles-Tab-EXPORT.txt
html-doc/img/review2_5_CSV Buddy_award.png
icon/csvbuddy-16x16.png
icon/csvbuddy-32x32.png
Please move or remove them before you can merge.
Aborting
I moved the 6 files and tried to Pull again. It seems to work (no error message). However, I still have the indication that there are 2 Pull to do.
If I try to Push the 10 commits, I get this error message:
git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags origin master:master
Pushing to https://github.com/JnLlnd/CSVBuddy
To https://github.com/JnLlnd/CSVBuddy
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/JnLlnd/CSVBuddy'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Hum... I think I'm not that familiar with Git ;-) What should I do?
OK. Think I got it. I still had 2 conflicts to resolve before I can Pull / Push as desired.
Thanks for reading.