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.
Related
So I've recently started using github and made my own repo and pushed a project there. I understand that to fix the error saying "Remote repository contains unmerged into the local branch", you must pull or fetch.
The problem is that I made some major changes (remade file hiearchy, removed some files and added some as well) and now I do not want to pull since it would add back the files I removed and now, whenever I push, the error mentioned above pops up. How do I push the changes I made then?
You can force push the changes you have made
git push --force origin branch_name
Seems like Git stash is what you need here.
If you have made some changes then that will automatically get applied on top of the remote changes. So if you take a pull, still you will see your changes on top.
I'm an admin on this repo. In this PR I have removed multiple files and merged these changes from local to origin/develop. When merging origin/develop to origin/master I'm getting this conflict for one of the four files I've removed. Our flow is always local to origin/develop to origin/master. I had no conflicts when mergin local to origin/develop.
Github won't let me resolve the conflict.
Questions:
Why is the 'Resolve Conflicts' button disabled? I've never seen this before.
Why would this one file have a merge conflict? It's one of 3 config files that I removed completely in this PR.
Why am I getting this conflict on origin/develop to origin/master when I had no conflicts on local to origin/develop?
If the Resolve conflicts button is deactivated, your pull request's merge conflict is too complex to resolve on GitHub Enterprise or the site administrator has disabled the conflict editor for pull requests between repositories. You must resolve the merge conflict using another Git client like Atom's Git integration or the command line.
I know this is little old post. But putting my answer as I also faced the same issue and I could solve it using following.
As shown in screenshot attached, you can solve this on your local using command line.
Fetch the branch which has conflicts. (say master branch)
Checkout to that branch.
Pull the code from another branch you want to merge it into. (Take a pull from develop into master )
OR Rebase the branch as: checkout to develop branch, then take pull into it git pull origin develop. Then checkout to master branch and do git rebase develop.
Now resolve the conflicts, add the changed files, commit it, push onto the branch you want to merge it into (in this case master ). It might happen that you don't have permission to do it. In that case you can push this branch on your fork, and then raise PR to main repo)
There is one more method.
Using GitHub Desktop. Just that, it is not available for linux from official site.
For this you can check this link.
Read the instructions in the README doc and install it accordingly.
And you can find the method to solve the conflicts using GitHub Desktop here.
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
I'm using Eclipse 4.2.1 and EGIT. I've done the following:
Created an account on Github.
Created a Repo and initialized it with a readMe from Github at the time I created it.
Cloned the repo using EGIT.
Created a Java project in Eclipse, a single class with a main method.
Share the project with GIT. Team-> Share Project-> GIT
In the Configure GIT repo dialog: Selected the repo I just cloned from Github.
Do a commit.
Push to remote origin.
Go back to Github and make a change to the readMe. (This shows in the commits on Github)
Fetch the changes with EGIT.
The changed readMe is shown in the remote tracking branch in EGIT but not in my local master branch. I tried refreshing but it still doesn't work. After doing this my local master is one behind and I can't push. I get rejected non-fast forward.
I can fix this by creating a new local branch based on HEAD then merging it into my local master. But why is this happening? Is anyone else experiencing this?
Fetching only gets the changes from github into the remote tracking branch (imagine this as a kind of index) on your local machine, but not into your working directory (the real files you edit). You still have to merge the remote changes into your local branch (which you can do by expanding the repository node Branches -> Remote Tracking -> origin/master and selecting "Merge" in the context menu).
If you always just want to fetch and immediately merge the remote changes, use the "Pull" command instead of the "Fetch" command, it is a combination of fetch and merge.
I using guthub on different PC. clone the same repository, I modified the code and commit change in one PC. But when I open another PC, it alert me that I am behind 1 commit. how to process this issue?
You need to update the local git repository on the other PC.
Presumably you've already done:
git fetch
to pull the latest changes. Now you need to merge your local branch with the remote one:
git merge origin/master
(or whatever branch name you're behind on)
git pull and (merge if needed)
Also probable you started working on an old clone and did a minor commit there, just do a Git pull and that should fix it.