Garini
Garini

Reputation: 1204

How can I pull the changes from GitHub without pushing mine?

enter image description here

The problem is pretty simple. I use source tree to commit my changes, but I'm really a newbie and I don't want to mess up with the common project. What should I do for keep the files I added WITHOUT committing them and at the same time have the master branch updated to the common version?

Upvotes: 2

Views: 13259

Answers (3)

Abdennour TOUMI
Abdennour TOUMI

Reputation: 93183

You are looking for git fetch origin master instead of git pull origin master

You can think of git fetch as half of a git pull. The other half of git pull is the merging aspect.

git pull = git fetch + git merge

or more clearer:

git pull origin master = git fetch origin master + git merge origin/master


A one-minute explanation is available on Youtube: https://youtu.be/jwyQUfE1Eqw

Upvotes: 1

user1745356
user1745356

Reputation: 4673

In order to update your origin/master just run git fetch. This will sync your origin/master with the latest master on the remote repository. Then you will be able to compare origin/master and your local master branches and decide what to do next. You can then merge local master with origin/master or rebase local master onto origin/master assuming you are familiar with these commands. In order not to mess up your project I would highly recommend to ask for assistance from experienced developers from your team and/or spend some time on learning git. Git is not that simple and it takes time to "feel" it.

Upvotes: 1

Mladen
Mladen

Reputation: 1245

Pull never sends your changes to server. Any git pull equivalent will do (pull button in source tree)

If you have unstaged files (as I see in your screenshot), save it to a stash, do git pull, and pop the stash.

Command line equivalents are git stash && git pull && git stash pop

Upvotes: 7

Related Questions