Sesha S
Sesha S

Reputation: 283

Git pull after local commit

I am new to git. I have a few local commits but I want to pull the latest code from the repository and don't yet want to push mine. However git pull, creates unnecessary merges. What is the right way to do this i.e update your local repository without losing the changes.

Upvotes: 12

Views: 14812

Answers (1)

Daniel Pittman
Daniel Pittman

Reputation: 17232

The tool you are looking for is git rebase, though you should look at the documentation about that before you start using it. It is also generally good practice to do development in a local branch to reduce the overhead of this sort of operation.

When you are comfortable, you can use git pull --rebase to use rebase rather than merge to resolve differences after the pull -- but, do read the docs first, because this can lose data or cause headaches if misused. It is a useful but dangerous tool.

Upvotes: 19

Related Questions