Can not solve Git error "refusing to merge unrelated histories" - django

When I tried to pull
git pull https://myid#bitbucket.org/myid/abc.git
error occurred
branch HEAD -> FETCH_HEAD
fatal: refusing to merge unrelated histories
Then I tried this
git pull origin master --allow-unrelated-histories
error occurred
fatal: 'origin' does not appear to be a git repository fatal: Could
not read from remote repository.
Then I tried this
git mergetool
error occurred
This message is displayed because 'merge.tool' is not configured. See
'git mergetool --tool-help' or 'git help config' for more details.
'git mergetool' will now attempt to use one of the following tools:
tortoisemerge emerge vimdiff No files need merging
Check branch name
git branch --contains=HEAD
branch is only master
master
I can not figure out how to fix this problem, please teach me what I can do next??

Related

Go get errors "could not read from remote repository"

Using "go get", I enter this command:
go get github.com/company/code
The repository is private. The error that comes back says this:
go get: module github.com/company/code: git ls-remote -q origin in /Users/myusername/go/pkg/mod/cache/vcs/d3459c3c5732de488c7de6ddbb96dcbb5d3c220735157c316a37c431326e9181: exit status 128:
fatal: 'git#github.comcompany/code' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Note on the first "fatal" line that the URL location does not have a colon between .com and company. I don't know whether that's significant. If it is significant, I don't know where to go to change it. I'd appreciate any tips!
If I ask git to list the remotes, I get
$git remote -v
origin git#github.com:Company/code.git (fetch)
origin git#github.com:Company/code.git (push)
If I push using git ...
$git push
everything up-to-date
Any ideas? Many thanks for your help.

Build error "file not found" after git pull --rebase origin master

Remote repo has made some changes to project settings (added new folder and changed include path). How do I pull these settings into my repo please? I tried
git pull --rebase origin master
And then build the c++ codebase but the build throws "File not found". Appreciate any help this beginner can get.
It is indeed git pull origin master but:
check first git is recognized in your current shell and $PATH
git version
check you are in your local repository
cd /path/to/local/repo
git remote -v
git pull --rebase origin master

Django Heroku app moved to new computer - error on git push heroku master

I recently moved my Django project deployed on Heroku to a new computer. By cloning my repository on my new computer. I have now made changes to the project on the new computer and have committed to my GitHub repository.
Now I have added my project GitHub repository, as well as the Heroku remote repository to the remote and I, can see it when I run git remote -v:
heroku https://git.heroku.com/myapp.git (fetch)
heroku https://git.heroku.com/myapp.git (push)
origin https://github.com/username/repo.git (fetch)
origin https://github.com/username/repo.git (push)
Now when I want to commit new changes I do:
git add .
and then
git commit -m "commit message" - which commits to my GitHub repository? I do not know if this is correct
Now when I want to push to heroku master using the command git push heroku master
I get the following error:
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://git.heroku.com/myapp.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.
I have also added keys, using heroku keys:add which since I didn't have any keys on my new computer I created a new one, which now I can see it when I run heroku keys.
I want to just push the new changes I made on my repository to heroku master. How can I push the new changes? using the command git push heroku master?
I have tried these command:
git push heroku master -f
Which this gave me the error: ! [remote rejected] master -> master (pre-receive hook declined)
git push heroku +HEAD:master
Which this gave me the error: ! [remote rejected] master -> master (pre-receive hook declined)
I have tried git fetch and I still get the same error
EDIT
I ran git fetch heroku, However, Now I get a new error:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.heroku.com/myapp.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and 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
I have tried using git push -f heroku master however, I get the error:
master -> master (pre-receive hook declined)
try this:
git pull
git add .
git commit -m "commit message"
git push heroku master
Furthermore, check out here what `git commit -m "commit message" do.

Git commit from a bisect

I have only ever used git add . for this project, but somewhere along the line I started getting the strange "modified content, untracked content" error on one of my subdirectories (called users). Other stackoverflow answers didn't work for me. I used checkout to go back through previous commits, but the buggy/untracked subdirectory didn't change with the rest of the directory. I ended up making manual changes to it and then running git checkout master to make sure everything else was back where it started.
Git is saying that I'm bisecting, and it won't let me commit. I looked over stackoverflow answers, and tried some of the following commands:
git pull:
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
git pull origin master:
fatal: 'origin' does not appear to be a git repository
git branch --set-upstream-to=origin/master master:
error: the requested upstream branch 'origin/master' does not exist
hint:
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint:
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.
git pull --rebase:
There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
Apologies if these commands are all over the place. I intend to really learn how git works soon, but right now I just want to commit the changes so I can deploy my project.
UPDATE: I used git bisect reset, created a new branch out of my detached head, and then merged with the master. This kept the changes I made, so now I just need to figure out how to get users tracked again in my commits. git add users still isn't doing anything.

How to merge local branch with migrations created in docker

In my pet project I set up docker-compose for development. The issue is that I've create django migration inside docker and when I want to checkout to main branch and merge commits from sub branch I got an error:
error: The following untracked working tree files would be overwritten by merge:
apps/users/migrations/0002_auto_20190127_1652.py
Then I type git status and I can see that that migration file is still untracked. And I cannot return to the previous branch because of the same error.
I believe this may be related with the issue you have reported here.
If so the solution is the same I gave there on this answer.
So the above answer solve the permissions issues that I believe are the cause of your error when trying to use git to merge your branches.
With the permissions issue solved git should now work as expected.