Skip to content

Instantly share code, notes, and snippets.

@shaishab316
Last active November 20, 2025 03:51
Show Gist options
  • Select an option

  • Save shaishab316/a6bea405cbf46a5712fbe577099b87ef to your computer and use it in GitHub Desktop.

Select an option

Save shaishab316/a6bea405cbf46a5712fbe577099b87ef to your computer and use it in GitHub Desktop.
A collection of useful Git commands and techniques to streamline your workflow, improve productivity, and enhance version control practices. This guide covers advanced features, troubleshooting tips, and lesser-known Git commands to help you work more efficiently with repositories, branches, commits, and remotes. Whether you're a beginner or an …

Git Tips and Tricks

Temporary Ignore a File

  1. Temporary Ignore a File:
    To ignore a file temporarily, use:
    git update-index --assume-unchanged <filename>
  2. Revert Temporary Ignore:
    To undo the ignore command and track the file again:
    git update-index --no-assume-unchanged <filename>
  3. See Temporarily Ignored Files:
    To view the temporarily ignored files:
    git ls-files -v | grep '^[[:lower:]]'

Remote Branches

  1. List Remote Branches: To list all remote branches:
    git branch -r
  2. Delete Remote Branch:
    To delete a remote branch:
    git push origin --delete <branch-name>
  3. Rename Remote Branch:
    To rename a remote branch:
    git push --set-upstream origin <new-branch-name>
  4. Fetch All Remote Branches: To fetch all remote branches: git fetch --all

Orphan Branch

  1. Create the Orphan Branch:
    git checkout --orphan <branchname>
    git rm -rf .
    git commit --allow-empty -m "Initial commit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment