Skip to content

Latest commit

 

History

History
79 lines (40 loc) · 1.3 KB

3-branch&merge.md

File metadata and controls

79 lines (40 loc) · 1.3 KB
  1. git branch

    list your branches. a * will appear next to the currently active branch



  1. git branch [branch-name]

    create a new branch at the current commit


    • git branch -a

      Shows remote and local branches


    • git branch

      Shows only local branches


    • git branch -d [branch_name]

      Deleting a local feature branch, forcefully using -D


    • git push -d [remote_name][branch]

      Deleting a remote branch


  2. git checkout [branch_name]

    switch to another branch and check it out into your working directory


    • git checkout -- <path_to_file>

      Discarding changes made on a file


    • git checkout -b [branch_name]

      Creating and checking in with a single line


  1. git merge [branch]

    merge the specified branch’s history into the current one



  1. git log

    show all commits in the current branch’s history



  1. git worktree

    Manage multiple working trees attached to the same repository.


    git worktree add [path_directory][branch_name]

    create path_directory and checkout branch_name into it

    git worktree list

    list details of each worktree