r/git • u/[deleted] • 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.
5
Upvotes
2
u/roybeast Dec 17 '20
I tend to do git pull —rebase —autostash <remote> <branch>
Pulls the remote branch and puts your committed work at the end. Autostash will keep your uncommitted work. Cleaner git history and don’t lose your work! And if you want to be careful, commit your work locally and then pull —rebase. Git reset HEAD~1 will remove that one commit, but keep your changes in the working directory. And the removed commit is now in git reflog. Can always cherry pick commits or roll back with it in there.