Lorenzo Vainigli

Software developer, passionate about programming

Git Commands

Here’s a list of useful commands to use Git.

Table of contents

  1. Basics
  2. Branching
  3. Tags
  4. Remove items
  5. Other

Basics

# Init a local repository
git init

# Clone a remote repository
git clone {remote_repository_url}

# Add remote to local repository
git remote add origin {remote_repository_url}

# Committing all changes
git add *
git commit -m "Commit message"

# Push to remote repository
git push origin master

Branching

# List all branches
git branch

# Change branch
git checkout {branch_name}

# Create a new branch
git checkout -b {branch_name}

# Push a branch to remote repository
git push origin {branch_name}

# Rename current branch
git branch -m {new_name}

Tags

# Add tags to the current commit
git tag -a {tag_name} -m "Tag message"

# Show tags
git tag

# Show tag data
git show {tag_name}

# Pushing all tags to the repository
git push origin --tags

# Delete local tag
git tag -d {tag_name}

# Delete remote tag
git push --delete origin {tag_name}

Remove items

# Remove remote directory
git rm -r --cached FolderName
git commit -m "Removed folder from repository"
git push origin master

Other

# List ignored files
git status --ignored

Lorenzo Vainigli

Android developer and passionate about computers and technology since I was a child.
I have a master's degree in Computer Science obtained at the University of Bologna.
I like astronomy 🌌 and Japanese culture ⛩ī¸.
Here I tell more about myself.