Just documenting a pro-tip from a friend. Any dev opinion is precious to me due to not working amongst them. Please don't go to twitter to flame him.
I'm just making notes for my future self.
Liquid error: internal
polar vortex jen@jenninat0r@conradmuan Rly? Did you mean rename master... 🤪21:39 PM - 28 Feb 2019
Conr🙏d Muan@conradmuan@jenninat0r nope!
git fetch origin master
git checkout -b my-branch-name origin/master
git push origin my-branch-name
repeat. No need to checkout master ever again.22:13 PM - 28 Feb 2019
polar vortex jen@jenninat0r@conradmuan And.... change the deploy branch to my-branch-Name?23:38 PM - 28 Feb 2019
Conr🙏d Muan@conradmuan@jenninat0r depends on the team / project. In my case, we'd issue a PR and merge into master via github. CI takes over for deploying. The reason I don't checkout and pull master is I find it faster to fetch and checkout from origin esp for a LARGE mono repo23:47 PM - 28 Feb 2019
My initial thoughts: Perhaps the trick here is the difference between pull and fetch. Pull attempts to merge your changes with existing commits on remote, and with a huge repo that's risky...?
Update, for my own education and edification:
@joelnet pointed out:
"For those of you that are confused, master is not deleted on the remote repo. It is only deleted on the local repo. The way git fetch works, you always have a local copy. ...once you do `git checkout -b my-new-branch origin/master`, you'll have an identical copy of `origin/master`[.] it'll just be called `my-new-branch` locally."
"He means not checking out the master branch locally, just to use it [it] as base to checkout your branch. You can checkout your new branch directly from the remote ("origin" in this case). The difference is that, when you checkout master locally then git build[s] a working tree for it. ...to understand it correctly, you need to keep in mind that you can't work in all of the branches. ...git stores the changes differentially, when you checkout a branch it needs to calculate the complete state of the files and make the needed changes to you local files to reach those changes."
Conrad's school of thought seems to resound with something I read a long while back on Mark Longair's blog "GIT: FETCH AND MERGE, DON’T PULL" :
...by both fetching and merging in one [git pull] command, your working directory is updated without giving you a chance to examine the changes you’ve just brought into your repository. The safe ways to change remote-tracking branches are with git fetch or as a side-effect of git-push; you can’t work on remote-tracking branches directly. In contrast, you can always switch to local branches and create new commits to move the tip of the branch forward. So what you mostly do with remote-tracking [local] branches is one of the following: 1. Update them with git fetch 2. Merge from them into your current branch 3. Create new local branches based on them
I have yet to try working this way but can see git repos being updated like the former in very large projects.
@codemouse92 prefers to maintain an easy to access, canonical copy of what worked before.
You [already] pull the entire thing down the first time with `git fetch`, and then the incremental changes later with a basic `git pull`. ...`git pull` uses the same bandwidth as `git fetch`, you'll still saving yourself a step by not deleting master off your local copy every time. ...Don't delete `master`, leave it alone.