0

I checked out a branch: git checkout -b myBranch

Made some commits:

git commit -m 'msg'

git commit -m 'msg2'

Then I pulled from master. Now I have many staged files in which I did no work. How can I squash all the changes from master and move my commits on top?

yalpsid eman
  • 3,064
  • 6
  • 45
  • 71
  • You have many staged files after pulling master? Check them, perhaps you didn't finish a commit you wanted to? --- the answer to your technical question normally is `git rebase master` however I don't understand the "squash" part so I have excluded it. – hakre Jul 12 '21 at 18:45
  • Indeed I have many staged files after pulling from master. – yalpsid eman Jul 12 '21 at 18:46
  • `git rebase master error: cannot rebase: Your index contains uncommitted changes. error: Please commit or stash them.` Can't rebase, and if I commit, I am committing all the files from master – yalpsid eman Jul 12 '21 at 18:47
  • 1
    Try `git rebase --autostash master`. – hakre Jul 12 '21 at 18:51
  • and then commit? – yalpsid eman Jul 12 '21 at 19:16
  • commit, stash or reset - this is entirely up to you. do whatever suits you best, it's your repository. – hakre Jul 12 '21 at 19:21
  • 2
    `git pull` means *run `git fetch`, then run a second Git command*. That second Git command has *stalled out in the middle*. You must figure out what you want to do with that, and either complete the command, or abort it entirely and do something different. (This is why I recommend that newbies avoid `git pull` entirely. Avoiding it won't help you with the second command, but it will at least let you know that there *is* a second command, and that that's the one that has not yet succeeded.) – torek Jul 13 '21 at 06:02

0 Answers0