What should I do when my local branch is at merging state after I pull the remote master? - github

I am an Android developer, and now I am doing a lot of changes locally and are trying to synchronize the local and github side of the code after I pull the merge to merge successfully and merge the code locally and run successfully.
But when I want to push always show the picture shown in the picture, push rejected. I am very puzzled, the left side of the figure is the local change, since I was a novice, no previous to ignore the file, so a series of build files, .idea files have been submitted to see the error is to show that these files are not merged.
Now I am very puzzled, how can I solve this situation, how can I submit the local code to my github library, who can help me? Many thanks!
Screenshot:

You have commits in the remote version of master that you're pushing to that are not in your local version, and vice versa. Since Git can't resolve this diversion automatically, you can't push your local version to your remote.
You may have to git pull, or if that doesn't work, git rebase, to get your branches to line up in a way that they can be merged.

Related

GitHub - no changes seen after successful commit

I'm struggling with an issue connected to GitHub. I've committed some changes using GitBash console and got an info that the push was successful and there's nothing to commit. When I went into logs, there was this particular log looking like this:
The issue is that when I go back into my GitHub account, I can see just an initial commit in there, nothing more.
And the console clearly says that the commit was successful.
Please help!
Git is a distributed version control system, so you have one local copy of the repository, Github has another copy. As far as git is concerned every copy is equally important.
For your changes to exist in Github, you have to push them there, with something like:
git push origin master
Try git remote -v to get more information on your tracked repositories. Github has some great help pages on this stuff.
For what you say in your question, I think you don't have actually pulled your local repository in your GitHub account.
To do that, use git push origin master
When you use git commit your changes are saved in your local repository, not in your remote (that in this case is GitHub)
Thanks to all that helped me understand my issue. Turns out the files did not copy between folders properly and that's why there're not changes detected on git. Now everything is working.
Thanks again!

How to recover replaced files in local Git repository after pull request?

Originally on my Github are some outdated styles.css and JavaScript files and others.
I was working on my project last night but didn't push it to Github or back it up. It was just saved in my local repository using a series of local, unpushed commits.
Being a newbie that I am, I did a git pull request master, and all the files in my local repository got replaced with the original styles.css and JavaScript that was in my github.
Is there a way to get those files back?
I did a git reset head#{2} where I believe the state of the repository before the pull request was, and it showed some unstaged files.
In Gitshell my command line has "master [+10 ~19 -42 !]" with the text master being yellow.
At this point, what do I do? Currently I seem to have lost a lot of work.
If you have performed commits often you can pretty much get to any of them.
Use git reflog first (https://git-scm.com/docs/git-reflog). It will show you all the interim commits you've made. Once you find a relevant one you can do git reset #commit_id.

How to get code from Github but don't want to commit from local?

How to get code from github using github desktop for windows?
I want to get latest code everytime from live repostiory as everyone commit there changes and it should be lock with my local changes. I mean I don't want to commit my local changes to live repository.
How to setup this thing?
Thank You.
If I understand you correctly, you want to be able to get updates to your Git project, but you want to leave your local branches alone.
A git pull is out of the question. A git pull is a fetch to update your remote branches, plus a merge to update your locals. Instead, only use git fetch. This will update only your remote branches (ie. your copy of the Github repository), but leave all your local branches alone.

Why my way to update local files with Github is not working?

First I have a master branch in my remote repo on the internet. And I know if I changed my local files, how to update my local changes to the remote repo. Now the problem is, if I don't want my new changes in my local tracked files, how to return back using updating from the remote repo in github?
I have tried the following things:
I use
git checkout origin master
to get to master repo.
I make sure that one tracked file, named main_32.f90 is changed a little bit in the comment line.
Then I use
git pull
it turns out that everything is up to date.
Already up-to-date.
I then checked the main_32.f90, it is not the original one but the changed one in comment line. So it means that the git pull is not working.
So how to do it?
If you don't want to keep your local changes, you can do a hard reset to a pointer, branch, sha1, etc to discard all changes. git reset --hard HEAD.
Use this kind of aliases to have a pretty view of your working tree if you are a console fan and don't want to use any GUI as suggested by other users.

EGit Commit to Remote Branch without Local Branch

I had a branch I was working on for a long time on my desktop. First I commit changes to my desktop's local branch, then push them to the remote branch and everything is dandy.
This morning, I was working on my laptop and selected the remote branch to change. The image below shows what my EGit repository window looked like on my laptop, except there was no local "MethodMigration" branch (there was a local master though). The remote "MethodMigration" branch had the little black check-mark next to it telling me that I'm viewing it as shown in the picture.
https://docs.google.com/file/d/0B7yGmb99B5enZm5OcTcydnEwLUE/edit (Sorry for the ghetto google drive link. I couldn't figure out how to get an image link)
Anyhow, I started adding a whole bunch of stuff. After I was done, I did a "Team->Commit->Commit & Push" after giving it a message. At that point, I remembered that I hadn't made a local branch for it yet... It told me "Nothing to push" even though a whole bunch of stuff had just been specified (which kind of makes sense since I never cloned the remote branch to make a local copy in the first place). The bad part is that all of my code was reverted back to the original "MethodMigration" remote branch code. Additionally, BitBucket shows no commits or anything.
Where did all my changed code go? Is there a way to get it back?
No worries!
You can use git reflog to find the commit id SHA of the lost commit. After that simply merge it with your local branch:
git merge <commit-id>