Miss Clone: I get a fresh copy to local.
Mr Pull: I already have it locally, I just update it.
Miss Clone: I can do what you do! You are just my subset.
Mr Pull: Ditto!
Miss Clone: No, you don't create. This is what I do:
- Create empty bare repository in local computer.
- Populate remote-tracking branches (all branches in repo downloaded to local computer)
- Run git fetch without arguments
You only do #3, and then you merge(fetch + merge), which I do not need to do. Mine is fresh... girl!
Mr Pull: Smarty pants, no big deal, I will do a "git init" first! Then we are the same.
Miss Clone: No dear, don't you need a 'checked-out branch'... the git checkout
? Who will do it? me!
Mr Pull: Oh right.. I need a checked-out local branch to act on. But wait.. you checkout master
branch by default. Does anyone work on master branch? No! You are delivering a feature that is perhaps never used! I let the user decide the best branch to checkout and that is how I roll!
Git creators: Hold your horses Mr Pull, if --bare or --mirror is used with clone or init, your merge won't happen. It remains read-only. And for you Miss Clone, git checkout
can be replaced with a git fetch <remote> <srcBranch>:<destBranch>
unless you want to use a -s <strategy>
with pull which is missing in fetch.
Miss Clone: On that same note about 'master' branch, I automatically sets up my local master branch to track the remote master branch. Your command takes dev for a ride and they are clueless!
Mr Pull waves at friends and walks away.. face slightly red..
Miss Clone: Yes, walk away but you are dependant on git checkout
for remote tracking. pull
wont bring changes from 'remote', when it is not tracked! And when the dev tries to push
, they get merge issues! I don't depend on others to do my work. A maverick I am!
Git creators: Yes, it is tricky especially when checkout
decides remote tracking. But when you do git status
, or git branch -vv
, it will show if you are tracking any remote branch. Based on this you can take the decision to force a remote tracking or not. It really is not Mr. Pull's fault. Devs are advised to learn more about git checkout
and also commands to track origin.
Miss Clone: Somehow I feel like a winner already but let me drop this too: my command applies to all the branches in the repository. Are you that broad minded Mr. Pull?
Mr. Pull: I am broad minded when it comes to fetching all the branch names(just the 'name') from the repo. Because I don't like to fetch unnecessary branches and GBs to my hard drive (sometimes they 'pull' only to get latest branch names). But the merge will happen only on the current checked out branch. Exclusivity is the name!
Git Creators: Good job! Just one addition: Miss Clone can be restricted to just one branch if needed: git clone --single-branch --branch <branch name> <url>