Git Branch Creation

#202205251209 Branch could be created using branch {branch-name}. If the branch need to be started at one specific commit, pass a second argument to the command like branch {branch-name} {commit}.

If you want to immediately check out to the branch upon creation, run checkout -b {branch-name} {commit} where the commit is an optional argument that specifies where the starting point the branch should be at. It could be used alongside with 202205251604#.

You could move the branch’s starting point afterwards by the option -f for the command branch.

Links to this page
  • Git Revert Commits

    reset {commit} is used on local Git repositories. It moves the current branch starting position to the specified commit and discards all changes after that commit. This results in a new commit history. All discarded commits could be still found in Git Reflog.

  • Git Push

    One can pass in refspecs in the format of {local_branch}:{remote_branch} into the command push {remote} with 202205251604# in order to push the local branch# to a specific remote branch that is not referred by the local branch. If you do not name the local branch, the remote branch will be deleted instead. You could do this with 202205251612 and 202204262031 too.

  • Git Pull

    Similar to 202205251600, you can use refspecs with the format of {remote_branch}:{local_branch} for the command pull {remote} with 202205251604#. If the remote branch# is not named, it will create a local branch that #202205251612 all commits on the remote repository instead, and then merge it to the checkout branch.

  • Git HEAD

    Git HEAD is pointing to the current working commit. One could move the HEAD along the commit history in the repository without restrictions. We could move the HEAD to specific position by using checkout {commit} either by specifying the branch name, tag, individual commit or by using 202205251604#.

  • Git Archive

    Backing up a whole branch, work tree or a commit could be achieved using the command archive {tree-ish} -o {output-archive}. {tree-ish} could be a tree ID (like branch or work tree) or a commit ID. The resulting archive could be in the format of tar or zip.

  • Git
#vcs #git