1

I'm knew in Git, I used SVN for three years before.

I cloned a repo and made local commits without creating a branch. Now I'd like to 'get' changes from master, merge it with my local commits (if there are conflicts) and push the result to origin.

In SVN it would be update -> merge -> commit. What is analog in Git for my situation?

AdamSkywalker
  • 11,408
  • 3
  • 38
  • 76

2 Answers2

2

Simply use git pull. It will download last commits from the remote, and merge your work with it.

The git pull command is a macro for 2 different commands:

  1. git fetch which download the latest commit and add them to the local remote-tracking branch
  2. git merge which merge your currernt work (your last local commits) with the latest commits downloaded from remote

I suggest you to take a few minutes to read some basic concepts of Git. The git book is a very comprehensive and interesting starting point.

Antwane
  • 20,760
  • 7
  • 51
  • 84
0

The analog in Git to the SVN workflow is fetch + rebase (not fetch + merge)!

Moreover, Git cannot simply integrate remote changes into your working tree like SVN does. Git merge/rebase can only operate on a clean working tree!

The whole Git equivalent to SVN update would be:

  • stash local changes to clean up the working tree;
  • fetch remote changes;
  • rebase;
  • stash pop to reintegrate local changes back into the working tree;
  • resolve conflicts;
  • (if there were conflicts) remove the stashed state manually with stash drop.
Eugen Labun
  • 2,561
  • 1
  • 22
  • 18