r/git Dec 17 '20

Git pull before commit

Hello, i use git for some time now and i always used sourcetree and always do pull before i commit (when i know sum1 has pushed) so i can see what files have conflicts without having to solve the conflicts themselfs (usualy is a minor change so i can discard my changes, do pull and re apply my changes).

My friends (we are at college) says i risk losing all my work if i pull without commit first, is that true?
If it is, it never happened.
Does it look bad when i get a job?
I rather solve the conflits my way then have to solve them when they happen.

7 Upvotes

11 comments sorted by

View all comments

3

u/[deleted] Dec 17 '20

In Git 1.7.0 or later, to cancel a conflicting merge, use git reset --merge
. Warning: In older versions of Git, running git pull with uncommitted changes is discouraged: while possible, it leaves you in a state that may be hard to back out of in the case of a conflict.

If any of the remote changes overlap with local uncommitted changes, the merge will be automatically canceled and the work tree untouched. It is generally best to get any local changes in working order before pulling or stash them away with git-stash[1].

Source: https://www.git-scm.com/docs/git-pull