GitHUB rejected master -> master (non-fast-forward) - github

This might be recursive and i have seen answers about this questions on other thread here on Stackoverflow.
The reason i am asking is that i dont understand one thing, that when it gives this error, i have seen answers here that tell that it is because that the remote master on Github is no where in my history of master branch on my local repository that is why it gives this error.
I have also seen explanations where it is written that the changes on remote have to be merged locally and then push your changes from local to remote.
So what i have done is that i have created a remote repository on github and am trying to push my changes from eclipse to this remote repository and it throws me this error. Regarding second solution of merging the changes first from remote, but i dont have anything to merge it is a new repository. So why does it throw this error.

This particular error is because the Local Branch is not up to date in order to Push your commit(The remote branch is updated with other commits).
Fetch from the Upstream to sync your Local Branch and the Remote Branch
Pull the changes
Then Push your commits which will be fast forward without any conflicts

Related

Can't to push commits from local branch to github repository

I was committing and pushing in ordinary for my repository.
but once i used command of git checkout for change to the previous version of my repository.
after that i tried to commit and push, then it can not completed.
i try to use the --no-verify command to push the commit but it also not success.
error: failed to push some refs to 'https://github.com/ruwanliyanage123/Hair-4-U-Hospital.git'
i want to push my commit into github repository
Since you switched to a previous version of your repository, your head is most probably detached. You can't just go back anywhere in your history and make commits.
Consider making a branch from there and then commit to it.
Try to first check in which branch you are working do git branch, check is the one you are working. Then I sometimes do git pull to just make sure that the connection is working this should not delete your progress the you should be able to do git push. If you are afraid youll mess up first do a local back up of all project files except for the .git one which are hidden by default in windows.Lastly I would suggest never posting the actual link to your github repository in case whatever you are working is important, you can just replace with
https://github.com/user/projectname.git

Github - merging fork into master (locally)

So i have the following problem:
Back when i started programming, i FORKED a repository (using github for windows) for a browser-game. For some time now, i made stuff, did git commit and issued a pull request using the webpage.
The original author did authorize my pull request and my changes went live.
Recently, i have become an "official" author on the original repository.
So i dont want to work on my "fork" any longer but instead dev on the original.
Using github for windows, i decided to "clone" the original repo.
My github now shows my forked (AncientSion/FieryVoid) repository and the original (Aatu/FieryVoid).
Now what i would like to do is somehow "merge" my forked repo into my local clone of the original repo and from there commit to the master repo directly, that way deploying my local, not yet commited changes from my fork to the live version while at the same time getting rid of fork repository.
However, i have no idea if that works and if it does, how.
Can someone please advise ?
I don't think that the Github for Windows interface supports this, but this can definitely be done via the git bash console. This is untested, but the steps ought to be correct, since I've done something similar (identical, in fact) before. This assumes that your clone, AncientSion/FieryVoid, is up-to-date with Aatu/FieryVoid, which can be done with a pull followed by a merge, or, to avoid merge commits, with a git pull --rebase. So now you have AncientSion/FieryVoid and Aatu/FieryVoid, both present locally, with AncientSion/FieryVoid ahead of Aatu/FieryVoid by a few commits. What you need to do is pull in those commits into Aatu/FieryVoid by running the following:
cd path/to/local/clone/of/Aatu/FieryVoid
git remote add local_pull path/to/local/clone/of/AncientSion/FieryVoid
git pull local_pull master
git push origin master
Couple of assumptions:
You were working on the master branch of AncientSion/FieryVoid. If not, replace master in line 3 with your branch name.
origin is a remote that tracks the online repo Aatu/FieryVoid

recover github deleted remote branch that wasn't merged into master

I've accidentally deleted a branch on my github repository.
I've searched up for a solution, and tried the methods mentioned here and here, but because I never merged that branch into master - I don't see it in the reflog at all.
My only local working copy that still has that branch on it is unreachable for few days because of technical issues.
Is there any way to recover that deleted branch?
The quickest way remains to write to GitHub support: they do have access to the refleg of the GitHub repo, and can restore that branch for you.
Then a simple fetch would allow you to recover that same branch in your local repo.
If you are not working through GitHub(say BitBucket..) and the branch you have in your local does not lave the log for unmerged branches in reflog, then there are two options
1) find a team member who has last fetched from the repo and can access all the branches in his fetched repo. He can then transfer to each of the remote branch and push that particular code up to the repo. You can go back in your other workspaces/folders to see if you have fetched from any other feature branches and can do the same.
2) ask all other team members who are working on their local branch to push their code up the repo recreating the structure for (only live) branches.
This will be still incomplete as the restructuring will miss the commits after the last fetch till the current merge and the tree history will be modified in its refs . But at least it will avoid complete loss of code base and history.

can't push upstream using EGit

I use EGit in eclipse to pull and push.
my config is:
[remote "origin"]
fetch = refs/heads/*:refs/remotes/origin/*
push = refs/heads/*:refs/remotes/origin/*
local branch is master
Remote Tracking branch is origin/master
when I do push, it comes out "origin/master:master[up to date]". Actually the remote branch is not up to date. I wander if I configure the wrong way.
Sometimes I change different configure, I will get either "create a new branch"(which is wrong, as I just push some commits) or "reject-no fast forward"(which is strange, as I am the only user of the remote repository and I have already fetch before push)
Check with Egit if you aren't in a detached HEAD mode:
If HEAD is "detached", i.e. is not pointing to the tip of a local branch but to a commit or tag, then none or several "checked-out" markers may appear in the tree, since any number of remote branch or tags may point to the currently checked out commit.
The state you are in while your HEAD is detached is not recorded by any branch (which is natural --- you are not on any branch).
(See "Why did git detach my head?" for probable cause, and "Git: How can I reconcile detached HEAD with master/origin?" for reconciliation).
That is a common cause for an "up to date" message when pushing to a remote repo.
After I push to upstream successfully, like version 0.3.9, I continue to change my codes locally and submit a version 0.5.0. This submit should based on version 0.3.9. I don't know why. That's why I have to do merge every time, and sometimes merge make my codes messy.

eclipse and github: master: master rejected?

I'm working with a friend using github and eclipse. Initially he created the repository and pushed his code. The only way I'm able to push my changes are to "force" them but this unfortunately wipes out his data and replaces it with mine. If I uncheck the force option I see the following error when trying to push my changes:
master: master [rejected]
Do I need to start over and pull the source from the repository initially?
Before pushing your changes, you will need to merge his changes locally. Try:
git fetch
git merge origin/master
After you have performed this merge and resolved any conflicts, you should be able to push your changes back up to Github.
The reason your change is rejected is that the current master on Github does not appear anywhere in the history of your master branch.