Say I have a command that looks as follows:
git checkout -b my-branch origin/dev
Assuming I have already fetched from origin before, so I know it has a dev branch, do I need to run git fetch before git checkout, or will checkout always fetch up to the latest commit in the remote branch?
git checkout -b branch origin/branchwill check out from the remote repository without fetching the repository. The checked out branch will be what the branch looks like on the remote repo.Note: Your local repository will not have the updated knowledge of the remote repository, so
git branch -amay not show the remote branch you are checking out or it may show an older reference to it.