Slartibartfast
Slartibartfast

Reputation: 611

Git Pull with uncommitted changes

It often happens that I'll be working on something and notice another commit has been made on the main branch. More often than not I can't pull without either stashing (or committing) my changes. So I always stash my changes, pull, then re-apply my own changes to continue.

So basically I need to do the stash -> pull -> apply dance several times a day. Is there a feature I don't know about that will enable me to do this in one, and can it be done in Sourcetree?

Thanks.

Upvotes: 1

Views: 1957

Answers (2)

Prihex
Prihex

Reputation: 362

This can solve your problem:

git pull --rebase --autostash

Upvotes: 5

matt
matt

Reputation: 535121

It sounds like the question might be:

I'm on branch myBranch and I want to catch master up to the remote without leaving myBranch. Can I?

If so, the answer is: usually. You can say

git fetch origin master:master 

to update the local master branch provided this is a fast-forward — which it generally will be, in typical use patterns.

Note that SourceTree lets you peek at any commit (as a diff from the preceding commit) or diff any two commits (by selecting them). Thus you can usually tell quite easily what is germane about a branch.

Upvotes: 0

Related Questions