- Change default branch name BY
git config --global init.defaultBranch <new_default_branch_name>
Key points
- A commit in Git includes information about the state of the files in your repository, along with metadata such as the commit time, the commit creator, and the commit’s parent or parents.
- The hash of your commit becomes the unique ID, or key, to identify that particular commit in your repository.
- A branch in Git is simply a reference to a particular commit by way of its hash.
master
is simply a convenience convention, but has come to be accepted as the original branch of a repository. main
is also another common convenience branch name in lieu of master
.
- Use
git branch <branchname>
to create a branch.
- Use
git branch
to see all local branches.
- Use
git checkout <branchname>
to switch to a local branch, or to checkout and track a remote branch.
- Use
git branch -d <branchname>
to delete a local branch.
- Use
git branch --all
to see all local and remote branches.
origin
, like master
, is simply a convenience convention that is an alias for the URL of the remote repository.
- Use
git checkout -b <branchname>
to create and switch to a local branch in one fell swoop.