For my project I keep an online repository on github
and local repositories on two computers (say A, B) where I write code and run tests and also on three other machines (say, C, D, E) where I just run tests.
Now, it happened a few times that there are conflicts whenever I want to just download updated code on C, D, E and doing just git pull origin $someBranch
won't work, probably due to some small modifications that I did on the local source code just for testing purposes and which I don't want to keep.
What should I do in this case? Should I always do git clone $URLofMyRepository
or are there less aggressive ways?
git pull is a (clone(download) + merge) operation and mostly used when you are working as teamwork. In other words, when you want the recent changes in that project, you can pull. The clone will setup additional remote-tracking branches.
After the clone, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will in addition merge the remote master branch into the current master branch, if any (this is untrue when "--single-branch" is given; see below).
git clone is primarily used to point to an existing repo and make a clone or copy of that repo at in a new directory, at another location. The original repository can be located on the local filesystem or on remote machine accessible supported protocols. The git clone command copies an existing Git repository.
The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content.
You can remove the changes to your branch if you do not want to keep them using:
git checkout .
This should remove all unsaved changes to your working directory, allowing you to perform a pull.
git pull origin $someBranch
If you want to keep the changes in your branch try stashing them, then running the pull command.
git stash
Assuming no other stashes have occurred these changes can be applied at a later time by performing:
git stash apply
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With