Github Cheatsheet
Pulling
Let’s say John and you (or more people) are working on the same branch.
[SITUATION 1] You have some changes and John pushes. Now your local Git is one commit behind.
i.e → 1
- Try
git pullto catch up your current branch. If successful, you’re done! - If you get
Fatal: Not possible to fast-forward, aborting, move on to SITUATION 2.
[SITUATION 2] You already have multiple commits and John pushes. Now your local repo looks like → 1 + 3
- Use
git pull --rebase. Think of this as putting your changes aside, pulling all the pushed changes from GitHub, and then applying your changes on top. This may cause merge conflicts if John changed files that you also changed. - If you run into
Fatal: Not possible to fast-forward, abortingagain, you may have pending changes that you haven’t committed. Try:git stashto stash your changesgit pull --rebaseto pull John’s commitgit stash popto restore your changes