Here, we are migrating our source code to github, and this transaction is giving me headaches 🙂
what I did: I gone to our workspace (is an eclipse project), and did git init and git add . and then git commit -am "first commit"
everything worked fine, and then, i just pushed it to github. success too.
but there is a big problem: My friend just made a change on a file named A.java and I just changed B.java. ok, not a big deal. then, he pushed it to github. whei I try to push, my push is rejected. Ok, I did a git pull github master and then, push again, and now, my ‘commit message’ turns like Merge branch 'master' of github.com:germantech/projectName
Ok, what am I doing wrong?
ps: sorry about my english
Here, we are migrating our source code to github, and this transaction is giving
Share
You’re not doing anything wrong – when you do
git pull github master, git goes to the repository indicated by the remotegithub, fetches everything needed for themasterbranch, and then merges it into your current branch. Before the pull, you had the following history:… where
Ois the commit with the message “firts commit” andAis the commit that introduced your changes toA.java. Your friend, meanwhile, has the history:… and that has been pushed to GitHub. When your
git pull github mastermerges that into your history, it creates a “merge commit” to represent the state of the tree with the changes from bothmasterbranches:If, instead, you wanted to keep the history linear, you could do
git pull --rebase github master, which would instead would “replay” your commits that aren’t in the remote version of the branch on top of that remove version of the branch:Some people prefer that – I personally don’t care.