2

I'm trying to understand Git, I'm pretty new to it. I have a fork on Github that I forked from someone else's repository and I'm trying to contribute to his repository.

I do my changes and I'm happy so I want to do a pull request. But I can't do the pull request because Github for Windows says it can't be merged with no conflicts. So I do:

git fetch upstream 
git merge upstream/master

And then I get some conflicts from some stuff the other guy did, which I resolve using Beyond Compare.

I then create a pull request by clicking the create pull request in Github for Windows. Then he looks at my changes, but he's never happy with them so he makes little modifications and then commits to his branch. The change on his fork just shows 1 commit with my avatar and his avatar in the corner.

So I figure I should get his new version so I do:

git fetch upstream 
git merge upstream/master

again.

Doing this gives me another ton of conflicts that I have to resolve. I don't understand why I'm getting conflicts, I haven't done anything since my last merge. Shouldn't I just be getting an exact copy of his fork?

Also my pull requests seem to list all the commits I've done since I started contributing to the project, shouldn't it just show the commits since my last pull request?

Edit:

As requested by bg17aw here are my git config --list settings

alias.c=commit
alias.co=checkout
alias.dt=difftool
alias.mt=mergetool
alias.praise=blame
alias.ff=merge --ff-only
alias.st=status
alias.sync=!git pull && git push
apply.whitespace=nowarn
core.symlinks=false
core.autocrlf=true
core.editor=gitpad
core.preloadindex=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
color.ui=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle-ghfw.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
credential.helper=!github --credentials
filter.ghcleansmudge.clean=cat
filter.ghcleansmudge.smudge=cat
push.default=upstream
diff.tool=vs2013
diff.algorithm=histogram
difftool.prompt=false
difftool.bc4.cmd="c:/program files (x86)/beyond compare 3/bcomp.exe" "$LOCAL" "$REMOTE"
difftool.p4.cmd="c:/program files/Perforce/p4merge.exe" "$LOCAL" "$REMOTE"
difftool.vs2012.cmd="c:/program files (x86)/microsoft visual studio 11.0/common7/ide/devenv.exe" '//diff' "$LOCAL" "$REM
OTE"
difftool.vs2013.cmd="c:/program files (x86)/microsoft visual studio 12.0/common7/ide/devenv.exe" '//diff' "$LOCAL" "$REM
OTE"
merge.tool=bc3
mergetool.prompt=false
mergetool.keepbackup=false
mergetool.bc3.cmd="c:/program files (x86)/beyond compare 3/bcomp.exe" "$LOCAL" "$REMOTE" "$BASE" "$MERGED"
mergetool.bc3.trustexitcode=true
mergetool.p4.cmd="c:/program files/Perforce/p4merge.exe" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
mergetool.p4.trustexitcode=false
user.name=dallasm15
filter.hawser.clean=git hawser clean %f
filter.hawser.smudge=git hawser smudge %f
filter.hawser.required=true
diff.tool=bc4
difftool.bc3.path=c:/Program Files (x86)/Beyond Compare 4/bcomp.exe
difftool.bc4.path=c:/Program Files (x86)/Beyond Compare 4/bcomp.exe
push.default=simple
filter.lfs.clean=git lfs clean %f
filter.lfs.smudge=git lfs smudge %f
filter.lfs.required=true
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
remote.origin.url=https://github.com/dallasm15/Khazad.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
remote.ImpalerWrG.url=https://github.com/ImpalerWrG/Khazad.git
remote.ImpalerWrG.fetch=+refs/heads/*:refs/remotes/ImpalerWrG/*
remote.upstream.url=https://github.com/ImpalerWrG/Khazad
remote.upstream.fetch=+refs/heads/*:refs/remotes/upstream/*
branch.digging_creates_rocks.remote=origin
branch.digging_creates_rocks.merge=refs/heads/digging_creates_rocks

The diffs mostly show him replacing my spaces with tabs.

Mus
  • 7,290
  • 24
  • 86
  • 130
Dallas
  • 78
  • 1
  • 7

2 Answers2

3

I don't understand why I'm getting conflicts, I haven't done anything since my last merge

Since you have no changes, there is nothing to stash. I would use in this case:

git fetch origin
git reset --hard origin/master

(your remote might be named differently).

I don't understand why I'm getting conflicts, I haven't done anything since my last merge. Shouldn't I just be getting an exact copy of his fork?

If you keep having the issues every time, you might have an issue regarding git settings. You can see your settings using:

git config –list

Now if possible, you should also check the settings of the repo owner. Look for core.autocrlf=true to check if line endings are not the issue (if he is using a Mac/Linux and you are using a Windows machine, there is a chance of this happening).

Also look for core.filemode=false. This would prevent file permissions being tracked (if yours is set to true, change it to false). Git only knows about 755 and 644.

Another possible reason for your problem is whitespace (tabs v spaces). SUGGESTION: always use setting to set TAB = 4spaces. Again, you should get in sync with the repo owner. Depending on what IDE you are using, you can set it to match the setting of the repo owner.

Other useful things you might try to get to the bottom of this:

  • run git diff filename on one file and add the output to your question

  • use Sourcetree as a free GUI to help you with long lists of file with conflicts (you will still be able to use command line to progress with your understanding of git)

Mus
  • 7,290
  • 24
  • 86
  • 130
bg17aw
  • 2,818
  • 1
  • 21
  • 27
  • I tried 'git reset --hard upstream/master' and then in GitHub for Windows it said I was behind 38 commits, when I hit sync it spun for a while and said I was up to date. If youre interested the repo is at https://github.com/ImpalerWrG/Khazad so you can look at the commits. (I am dallasm15) – Dallas Apr 09 '15 at 11:58
  • I took a quick look, seems like the repo owner is using Netbeans for Linux, and using TABs. I think it would be much better practice to set TAB to be 4 spaces. The tab as set now takes 8 spaces which is too much in my opinion, but this is in the end personal preference. – bg17aw Apr 10 '15 at 11:16
  • And if I am correct you are using Windows, and he is using Linux, the differences may occur from the things mentioned in my answer. But like I said, try posting more examples of what is going on, output of `git diff filename`, the values you have for the two git settings and so on. – bg17aw Apr 10 '15 at 11:17
  • We are both using windows and jmonkey for the IDE. But he has this obsession with replacing spaces with tabs so he does that with all my commits. – Dallas Apr 10 '15 at 11:24
  • as requested I've posted my git config --list in my question. – Dallas Apr 10 '15 at 11:50
  • well without knowing that, I assumed correctly in my answer that the issue you have is related to the white space (tabs v spaces). The repo has a nbproject folder, that's why I assumed he is using Netbeans. – bg17aw Apr 10 '15 at 11:53
  • Ok I'll try to make sure I replace all my spaces with tabs and hopefully that will give a lot less conflicts. Thanks. – Dallas Apr 10 '15 at 11:57
  • You might also research on this setting: `apply.whitespace=nowarn` here: http://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#Commit-Guidelines and http://stackoverflow.com/questions/2947653/git-whitespace-errors-squelching-and-autocrlf-the-definitive-answers – bg17aw Apr 10 '15 at 13:21
1

Try doing: git pull --rebase

It stashes your changes first pulls the upstream's changes and then stash pop and apply your changes on top of it.

KP_G
  • 460
  • 4
  • 15
  • I tried that just now and it says current branch is up to date. So I should do that instead of git fetch upstream? – Dallas Apr 09 '15 at 10:51
  • It depends on your situation. You can refer to http://stackoverflow.com/questions/3357122/git-pull-vs-git-fetch-git-rebase & http://www.derekgourlay.com/archives/428 to get more understanding. – KP_G Apr 09 '15 at 10:54
  • I found out the command I actually need to run is git pull --rebase upstream master. When I do this it wants me to remerge every single commit I have ever made. What's up with that? There is no way I am doing that. – Dallas Apr 10 '15 at 10:00