Tuesday, August 29, 2023

GIT one liners

 

GIT One-Liners

  • git add -- Add files to the index
    (git add . | git add <filename>)
  • git status -- Obtain a summary of which files have changes that are staged for the next commit
  • git commit -m <msg> -- Record changes to the repository
    (git commit -m "first commit")
  • git branch -- List, create, or delete branches
    (git branch test | git branch -D test)
  • git checkout -- Switch branches or restore working tree files
    (git checkout -b test | git checkout master)
  • git clone -- Clone a repository into a new directory
    (git clone https://github.com/test2020/test.git)
  • git init -- Create an empty Git repository or reinitialize an existing one
  • git log -- Show commit logs
  • git merge [branch] -- Combines the specified branch's history into current branch
  • git pull -- Fetch from and integrate with another repository or a local branch
    (git pull origin master)
  • git push -- Update remote refs along with associated objects
    (git push origin master | git push origin master -f)
  • git rm -- Remove files from the working tree and from the index
  • git switch -- Switch branches
    (git switch test | git switch master)
  • git remote -- Manage set of tracked repositories
    (git remote | git remote -v | git remote add origin https://github.com/test2020/test.git | git remote set-url origin
    https://github.com/test2020/test.git)
  • git config --list -- lists all config values set
  • git config --global user.name "[name]" -- Sets the name you want attached to your commit transactions
  • git config --global user.email "[email address]" -- Sets the email you want attached to your commit transactions