Home > database >  How to push my local commit when my github have another commit and i forgot to pull my commit in git
How to push my local commit when my github have another commit and i forgot to pull my commit in git

Time:11-18

Hi i'm here to asking you, how to push my commit/chage(s) when i have another commit and i forgot to pull the commit from github. This is the chronology: when i'm no have another work, i decide to make own project and i use git to be my vcs, and then i make my project to be repository. A few day's later, i decide to remoting my github. Everything is alright until the problem come. In one day, i'm edit my README.md and save the change, in git same to but a different is i updating my source code and save the change. After that i'm push my commit and this is happent. Screen shoted the problem But in here, i'm not realize i'm forgot to pull a commit from github until i'm realized that.

So please help me! I stuck in this condition! Please! And i'm sorry if my English is bad

CodePudding user response:

So, basically your solution might be to pull the changes from GitHub (that is, if I understand correctly you have did some changes to you remote Github - updated your README.md - not from your local - now you want that change to be reflected in your local and you need to push your new changes in the local to the remote). The best solution would be to first add all your changes to staging and then committing by doing:

git add .
git commit -m "Your commit message (One-liner of your change)"

and then do a rebase as follows:

git pull --rebase

Rebasing will pull the changes from the remote, and re-apply your local changes on top of it, thus your local repo is now in sync with the remote repo (they are essentially in the same state). Now you can do the push:

git push  <REMOTENAME> <BRANCHNAME>
  • Related