Shubham0n/Git-and-Python-Django-Commands

Repository files navigation

CommandDescription
git --versionCheck Git version
CommandDescription
ssh-Generate ssh key
FILE-PATH/.ssh/ADD HERE HOST NAMEEnter the file in which to save the key
CommandDescription
cat ~/.ssh/ADD HERE HOST NAME.pubshow ssh key 
cat ~/.ssh/configList of all host and identity files
vi ~/.ssh/configOpen the SSH client configuration file in the Vi text editor
touch configCreate config file
CommandDescription
type FILE-PATH.ssh\ ADD HERE HOST NAME.pubshow ssh key (window)
notepad FILE-PATH.ssh\ ADD HERE HOST NAME.pubshow ssh key (window)
code FILE-PATH.ssh\ ADD HERE HOST NAME.pubshow ssh key 
New-Item -Name configCreate config file with Powershell
notepad -Name configOpen config file with notepad and Add Configurations
Generating public/private rsa key pair.
</br>Enter file in which to save the key (C:\Users\admin/.ssh/id_rsa): "ADD HERE HOST NAME"
Host .com-`SET HOST`
  HostName .com
  User git
  IdentityFile ~/.ssh/`ADD HERE HOST NAME`
  IdentitiesOnly yes
CommandDescription
git config --global user.name USER-NAMEset Global configuration of User Name and also check config without adding USER-NAME
git config --global user.email USER-EMAILSet Global configuration of User Email and also check config without adding USER-EMAIL
git config user.name USER-NAMESet Username config in particular folder
git config user.email USER-EMAILSet Email config in particular folder
CommandDescription
git clone git@SET HOST:USERNAME/Git-Python-Commands.gitTo use a specific SSH key when cloning a project from a different host, you need to update the SSH configuration file (~/.ssh/config) to define a custom host and associate it with the desired SSH key.
CommandDescription
git initCreate an empty Git repository or reinitialize an existing one
git init --bareCreate a bare Git repository
git init --template=/path/to/templateUse a custom directory as a template for the repository
CommandDescription
git clone <repository-url>Clone a repository into a new directory
git clone --branch <branch-name> <repository-url>Clone a specific branch from a repository
git clone --single-branch --branch <branch-name> <repository-url>Clone only a single branch from a repository
git clone --depth 1 <repository-url>Clone a shallow copy of a repository
CommandDescription
git remote add origin <repository-url>Add a remote repository named "origin"
git remote -vList all remote repositories
git remote rename <old-name> <new-name>Rename a remote repository
git remote remove <name>Remove a remote repository
git remote set-url origin <new-url>Change the URL of a remote repository
git remote show originShow information about a remote repository
git remote prune originRemove remote tracking branches no longer on the remote
git remote updateFetch updates from all remote repositories
CommandDescription
git branch <branch-name>Create a new branch
git branchList branches (the asterisk denotes the current branch)
git branch -rList all remote branches
git branch -aList all branches (local and remote)
git branch --allList all local and remote branches (alias for git branch -a)
git branch -vShow latest commit on each branch
git branch --mergedList branches merged into the current branch
git branch --no-mergedList branches not merged into the current branch
git branch --contains <commit>List branches containing a specific commit
git branch --no-contain <commit>List branches not containing a specific commit
git branch --remotesList remote-tracking branches
git branch -D <branch-name>Delete the branch
git branch -m <old-branch-name> <new-branch-name>Rename the Branch
CommandDescription
git checkout <branch-name>Switch to the specified branch
git checkout -b <new-branch>Create and switch to a new branch
git checkout -b <new-branch> <start-point>Create a new branch from a specific commit or branch
git checkout -Switch to the branch last checked out
git checkout -- <filename>Restore a specific file from the last commit
git checkout -pInteractively choose individual changes to restore
git checkout -qQuiet mode - suppress output
git checkout -fForce checkout
git checkout --detachDetach HEAD from any branch, checking out a specific commit
git checkout -B <branch> [<start-point>]Create or reset a branch to a specific commit
CommandDescription
git switch <branch-name>Switch to the specified branch
git switch -c <new-branch>Create and switch to a new branch
git switch -d <branch-name>Delete a branch
git switch -rSwitch to a remote branch
git switch -f <branch-name>Force switch to a branch, discarding changes
git switch -t <remote-branch>Switch to a tracking remote branch
git switch -c <new-branch> <start-point>Create a new branch based on a specific commit
git switch -c <new-branch> <start-point>Create a new branch based on a specific commit
CommandDescription
git statusShow the working tree status
git status -sShow short status
git status -bShow the branch information along with status
git status --ignoredShow ignored files
git status --porcelainShow output in a machine-readable format
git status --untracked-files=<mode>Control handling of untracked files
CommandDescription
git add filename.txtAdd file contents to the index
git add -pInteractively stage changes
git add .Add all changes in the current directory
git add -uAdd modified and deleted files
git add -AAdd all changes in the entire working tree
git add -N filename.txtAdd a new file to the index without content
git add -iStart an interactive add session
CommandDescription
git commit -m "Commit message"Record changes to the repository
git commit -a -m "Commit message"Stage and commit all modified files
git commit --amendAmend the last commit
git commit --amend --no-editAmend the last commit without editing the message
git commit --signoffAdd a Signed-off-by line to commit messages
git commit --date="YYYY-MM-DD HH:MM:SS"Set the commit date
git commit --allow-emptyAllow an empty commit
git commit --reuse-message=<commit>Reuse commit message from a specified commit
CommandDescription
git notes add -m "Note message" <commit-hash>Add a note to a commit
git notes show <commit-hash>Show the notes associated with a commit
git notes edit <commit-hash>Edit the notes associated with a commit
git notes remove <commit-hash>Remove the notes associated with a commit
git notes copy <from-commit> <to-commit>Copy notes from one commit to another
git notes merge <commit1> <commit2>Merge notes from two commits
git notes append -m "Additional message"Append a message to the existing notes of the current commit
git notes show-refShow the refs that have notes
git notes pruneRemove notes for commits that no longer exist
git notes listList the notes refs
CommandDescription
git logShow commit logs
git log --onelineShow abbreviated commit logs
git log --graphShow ASCII graph of branch and merge history
git log --decorateShow refs names of any commits in the output
git log --author=<author>Show commits by a specific author
git log --since=<date>Show commits since a specific date
git log --until=<date>Show commits until a specific date
git log --grep=<pattern>Show commits with a commit message matching a pattern
git log --statShow commit stats
git log --Show commit diffs
git log <since>..<until>Show commits in a range of revisions
git log --author=<author> --grep=<pattern>Show commits by a specific author matching a pattern
CommandDescription
git shortlogSummarize 'git log' output by author
git shortlog -sShow commit count only
git shortlog -nSort authors by number of commits (in descending order)
git shortlog -eShow email addresses along with author names
git shortlog -wIgnore whitespace changes
git shortlog --since=<date>Show commits since a specific date
git shortlog --after=<date>Show commits after a specific date
git shortlog --before=<date>Show commits before a specific date
git shortlog --no-mergesExclude merge commits from the summary
git shortlog --abbrev-commitShow abbreviated commit hashes
CommandDescription
git pushPush changes to remote repository OR remembered branch
git push origin masterPush changes to the "master" branch
git push -u origin <local-branch>:<remote-branch>Push a local branch to a specific remote branch
git push origin --delete <remote-branch>Delete a remote branch
git push origin --tagsPush tags to the remote repository
git push origin :<remote-branch>Delete a remote branch (alternative)
git push --force origin <branch>Force push changes to a branch
git push origin HEADPush the current branch
git push origin --allPush all branches to the remote repository
git push origin --mirrorMirror all refs to the remote repository
git push --set-upstream origin branch-nameSet branch to remote repository
git push -u origin branch-namePush changes to the remote repository OR remember the branch
git push -fForce push a branch to your remote repository
git push origin +masterPush local changes to the remote master branch
CommandDescription
git revert <commit>Revert some existing commits
git revert --no-commit <commit>Revert changes without committing
git revert --edit <commit>Edit the commit message before reverting
git revert --abortAbort the revert operation
git revert HEADRevert changes in the last commit
git revert --no-commit HEADRevert changes from the last commit without committing
git revert --edit HEADEdit the commit message before reverting the last commit
git revert --abortAbort the revert operation
git revert --soft HEAD^Soft revert changes from the previous commit
git revert --no-commit --soft HEAD^Soft revert changes without committing
git revert --edit --soft HEAD^Edit the commit message before soft reverting
CommandDescription
git reset HEAD <file>Unstage file(s) from the staging area
git reset --soft HEAD~1Move HEAD to the previous commit, keeping changes
git reset --mixed HEAD~1Move HEAD to the previous commit, unstaging changes
git reset --hard HEAD~1Discard changes and move HEAD to the previous commit
git reset --merge ORIG_HEADUndo a failed merge
git reset --keep HEAD~2Move HEAD to two commits ago, keeping local changes
CommandDescription
git restore <file>Restore working tree files
git restore --source=HEAD~2 --staged <file>Restore staged changes from a specific commit
git restore --worktree --source=HEAD <file>Restore a file to the state at the last commit
git restore --staged <file>Unstage changes for a specific file
git restore --source=HEAD --staged <file>Unstage changes for a specific file from the last commit
git restore --source=HEAD~2 <file>Restore a file to the state at a specific commit
git restore --source=HEAD~2 --staged .Restore all files to the state at a specific commit
git restore --source=HEAD --worktree .Restore all files to the state at the last commit
git restore --staged .Unstage all changes for all files
git restore --source=HEAD --staged .Unstage all changes for all files from the last commit
CommandDescription
git stash save "Work in progress"Stash the changes in a dirty working directory away
git stash listList all stashed changes
git stash showShow the changes in the latest stash
git stash show -pShow the representing the changes in the latest stash
git stash applyApply the changes from the latest stash
git stash apply <stash@{n}>Apply the changes from a specific stash
git stash popApply and remove the changes from the latest stash
git stash pop <stash@{n}>Apply and remove the changes from a specific stash
git stash dropRemove the latest stash
git stash drop <stash@{n}>Remove a specific stash
git stash clearRemove all stashed changes
CommandDescription
git show-branchShow branches and their commits
git show-branch --more=10Show more commits
git show-branch --topicGroup commits by topic
git show-branch --sha1-nameShow full commit SHA-1 names
git statusShow the working tree status
git status -sShow short status
git status -vShow verbose status
git status --ignoredShow ignored files
git status --untracked-files=allShow untracked files
git status --ignored --untracked-files=allShow all ignored and untracked files
CommandDescription
git fetchDownload objects and refs from another repository
git fetch originFetch updates from the remote named "origin"
git fetch --allFetch updates from all remote repositories
git fetch --pruneRemove remote tracking branches no longer on the remote
git fetch origin <branch>Fetch updates for a specific branch from the remote
git fetch origin <branch>:<local-branch>Fetch updates for a specific branch and rename it locally
git fetch --tagsFetch tags from the remote repository
git fetch --depth=<depth>Limit fetching to the specified number of commits back in history
git fetch --unshallowConvert a shallow clone to a complete repository
CommandDescription
git merge <branch>Merge a branch into the current branch
git merge --abortAbort the current merge operation
git merge --continueContinue the current merge operation
git merge --no-commitPerform the merge without creating a commit
git merge --squash <branch>Squash all changes from a branch into a single commit
git merge --strategy=<strategy> <branch>Specify a merge strategy
git merge --strategy-option=<option>Pass an option to the merge strategy
git merge --no-ff <branch>Create a merge commit even for fast-forward merges
git merge --ff-only <branch>Allow only fast-forward merges
git merge --no-edit <branch>Do not open an editor to edit the merge message
CommandDescription
git fetch --pruneFetch updates and prune deleted remote branches
git remote prune originRemove remote tracking branches no longer on the remote
git branch --pruneRemove local branches that have been deleted on the remote
git gc --prune=<mode>Cleanup unnecessary files and optimize the local repository
CommandDescription
git pull <remote> <branch>Fetch from and integrate with another repository or a local branch
git pull --rebase <remote> <branch>Fetch and rebase from another repository or a local branch
git pull --ff-only <remote> <branch>Perform only a fast-forward merge during pull
git pull --no-commit <remote> <branch>Fetch and integrate without committing the merge
git pull --no-rebase <remote> <branch>Fetch and integrate without rebasing
git pull --squash <remote> <branch>Integrate changes as a single squashed commit
git pull --recurse-submodules=<option>Update submodules along with the pull operation
CommandDescription
git cherry-pick <commit>Apply the changes introduced by a specific commit
git cherry-pick <start>..<end>Apply the changes from a range of commits
git cherry-pick --continueContinue the cherry-pick process after resolving conflicts
git cherry-pick --abortAbort the cherry-pick process and return to the pre-cherry-pick state
git cherry-pick --quitStop the cherry-pick process without committing or reverting changes
git cherry-pick --no-commit <commit>Apply changes from a commit without committing
git cherry-pick --edit <commit>Edit the commit message during cherry-pick
git cherry-pick --signoff <commit>Add a Signed-off-by line to the commit message during cherry-pick
git cherry-pick --strategy=<strategy> <commit>Use a specific merge strategy during cherry-pick
CommandDescription
git rebase <branch>Reapply commits on top of another base tip
git rebase --abortAbort a rebase in progress
git rebase --continueContinue a rebase after resolving conflicts or applying a manually
git rebase --skipSkip the current commit and continue with the next one
git rebase --edit-todoEdit the todo list during an interactive rebase
git rebase --onto <new-base>Rebase commits onto a new base
CommandDescription
git submodule add <repository-url> <path>Add a new submodule to the repository
git submodule initInitialize submodules
git submodule updateUpdate submodules
git submodule update --initInitialize and update submodules in one command
git submodule update --recursiveUpdate submodules recursively
git submodule update --remoteUpdate submodules to the latest commit on their remote branch
git submodule syncSynchronize submodule URLs
git submodule foreach <command>Run a command in each submodule
git submodule statusShow the status of submodules
git submodule deinit <submodule-path>Deinitialize a submodule
git submodule absorbgitdirsMove submodule directories into the superproject
CommandDescription
git mv <old-filename> <new-filename>Move or rename a file, a directory, or a symlink
git mv <file1> <file2> <directory>Move multiple files to a directory
git mv --force <file1> <file2>Force move, even if the target exists
git mv --dry-run <file1> <file2>Perform a dry run, see what would be done
git mv --verbose <file1> <file2>Run verbosely, showing files as they are moved
git mv --quiet <file1> <file2>Suppress output, only show errors
git mv --no-checkout <file1> <file2>Skip checkout and only move/delete
git mv --index-only <file1> <file2>Only update the index, not the working directory
git mv --dry-run --verbose <file1> <file2>Perform a dry run verbosely
git mv --force --dry-run <file1> <file2>Force move in a dry run
git mv --force --verbose <file1> <file2>Force move and run verbosely
CommandDescription
git rm <filename>Remove a file from the working directory and the index
git rm --cached <filename>Remove a file from the index only
git rm -r <directory>Remove a directory and its contents recursively
CommandDescription
git range-diff <commit1>..<commit2>Compare two commit ranges
git range-diff <commit1>..<commit2> <path>Compare two commit ranges for a specific file or directory
git range-diff --dual-color <commit1>..<commit2>Use dual color highlighting for comparison
git range-diff --color-moved <commit1>..<commit2>Highlight moved lines during comparison
git range-diff --stat <commit1>..<commit2>Show abbreviated statistics for changes
git range-diff --no-color <commit1>..<commit2>Disable color highlighting during comparison
git range-diff --submodule=log <commit1>..<commit2>Include submodule changes in the comparison
git range-diff --submodule=short <commit1>..<commit2>Summarize submodule changes in the comparison
git range-diff --submodule=diff <commit1>..<commit2>Show detailed submodule diffs in the comparison
git range-diff --submodule=short --dual-color <commit1>..<commit2>Summarize submodule changes with dual color highlighting
git range-diff --submodule=diff --color-moved <commit1>..<commit2>Show detailed submodule diffs with moved lines highlighted
git range-diff --submodule=none <commit1>..<commit2>Exclude submodule changes from the comparison
CommandDescription
git describeDescribe the current commit with the nearest tag
git describe --tagsDescribe the current commit with the nearest tag, including tags that are not on the commit's history
git describe --abbrev=<n>Set the number of hex digits to abbreviate object names
git describe --contains <commit>Find the tag that contains a specific commit
git describe --allShow all references (not just tags)
CommandDescription
git bundle create <file> <ref>Create a binary file containing references and objects
git bundle verify <file>Check the validity of a bundle file
git bundle list-heads <file>List references in a bundle file
git bundle unbundle <file> <path>Extract objects and references from a bundle file
git bundle create --all <file>Create a bundle with all references
git bundle create --branches=<pattern> <file>Create a bundle with references matching a pattern
git bundle create --tags=<pattern> <file>Create a bundle with tags matching a pattern
git bundle create --since=<date> <file>Create a bundle with references after a certain date
git bundle create --exclude=<pattern> <file>Create a bundle excluding references matching a pattern
git bundle create --stdout <ref>... > <file>Write a bundle file to standard output
CommandDescription
git clean -nDry run: Show which files would be removed
git clean -fForce removal of untracked files
git clean -fdForce removal of untracked files and directories
git clean -n -dDry run: Show which directories would be removed
git clean -f -dForce removal of untracked directories
git clean -xdfForce removal of untracked files and directories recursively
git clean -iInteractive mode: Choose which untracked files to remove
git clean -xRemove ignored files also
git clean -XRemove only ignored files
git clean -e <pattern>Exclude files matching the specified pattern from removal
CommandDescription
git grep <pattern>Search for a pattern in files tracked by Git
git grep -n <pattern>Show line numbers for matching lines
git grep -c <pattern>Show only the count of matching lines
git grep -l <pattern>Show only the names of files with matching lines
git grep -e <pattern>Specify a pattern using regular expressions
git grep -i <pattern>Perform a case-insensitive search
git grep -w <pattern>Match whole words only
git grep -v <pattern>Invert the match, displaying non-matching lines
git grep -f <file>Read patterns from a file
git grep -L <pattern>Search for files not matching the pattern
git grep --recurse-submodules <pattern>Search in submodules
CommandDescription
git diffShow changes between commits, commit and working tree, etc
git diff <commit1> <commit2>Show changes between two commits
git diff <file>Show changes for a specific file
git diff --stagedShow changes staged for the next commit
git diff --cachedShow changes staged for the next commit (alias for --staged)
git diff --name-onlyShow only names of changed files
git diff --color-wordsShow word-level differences with color highlighting
git diff --statShow brief diffstat for changes
git diff HEADShow changes between the working directory and the last commit
git diff HEAD~3..HEADShow changes for a commit range
git diff --color-words <commit1>..<commit2>Show word-level differences between two commits
CommandDescription
git maintenance startStart maintenance on the repository
git maintenance stopStop maintenance on the repository
git maintenance statusCheck the status of maintenance operations
git maintenance packPack loose objects in the repository into pack files
git maintenance runRun maintenance tasks on the repository
git maintenance start-againRestart interrupted maintenance operations
CommandDescription
git showShow various types of objects
git show --name-onlyShow only names of changed files
git show --statShow statistics about changes
git show --Show the introduced by the commit
git show HEAD~3Show details of the commit three revisions back
git show <commit-hash>Show details of a specific commit
git show <commit-hash>^Show details of the parent of a commit
git show <commit-hash>^2Show details of the second parent of a merge commit
git show <tag-name>Show details of a specific tag
CommandDescription
git tagList all tags
git tag <tag-name>Create a lightweight tag
git tag -a <tag-name> -m "tag message"Create an annotated tag
git tag -d <tag-name>Delete a tag
git tag -l <pattern>List tags matching a pattern
git tag -v <tag-name>Verify the signature of a tag
git show <tag-name>Show information about a tag
git push origin <tag-name>Publish a tag to a remote repository
git push --tagsPublish all tags to a remote repository
git checkout <tag-name>Switch to a specific tag
git tag -a <tag-name> <commit-hash>Create an annotated tag at a specific commit
git tag -d $(git tag -l)Delete all local tags
git push origin --delete <tag-name>Delete a tag from a remote repository
git push --delete origin <tag-name>Delete a tag from a remote repository (alternative syntax)
git tag --contains <commit>List tags containing a specific commit
git describe --tagsDescribe the most recent tag reachable from a commit
CommandDescription
git reflogShow a log of the Git reference history
git reflog show <ref>Show the reflog for a specific reference
git reflog expire --expire-unreachable=now --allPrune reflog entries older than the specified time
git reflog delete <ref>@{<index>}Delete a specific entry from the reflog
git reflog delete --expire=<time>Delete reflog entries older than the specified time
git reflog expire --expire=now --rewrite --allRewrite and prune all reflog entries
CommandDescription
git annotate <file>Show line annotations for a file
git annotate -L <start>,<end> <file>Show annotations for a specific line range
git blame <file>Show what revision and author last modified each line
git blame -L <start>,<end> <file>Show annotations for a specific line range
git blame --reverse <file>Show what revision and author last modified each line (reversed)
CommandDescription
git annotate <file>Show line annotations for a file
git annotate -L <start>,<end> <file>Show annotations for a specific line range
git blame <file>Show what revision and author last modified each line
git blame -L <start>,<end> <file>Show annotations for a specific line range
git blame --reverse <file>Show what revision and author last modified each line (reversed)
CommandDescription
git send-email <options> <rev-list-options>Send a series of es via email
git send-email --annotate <options> <rev-list-options>Annotate the es with details before sending
git send-email --compose <options> <rev-list-options>Compose emails interactively before sending
git send-email --smtp-server=<server> <options> <rev-list-options>Use a specific SMTP server to send emails
git send-email --suppress-cc=<address> <options> <rev-list-options>Suppress CC recipients from emails
git send-email --no-validate <options> <rev-list-options>Skip email validation checks
git send-email --confirm=<number> <options> <rev-list-options>Confirm email before sending
git send-email --dry-run <options> <rev-list-options>Simulate sending emails without actually sending them
git send-email --confirm=always <options> <rev-list-options>Always confirm before sending emails
CommandDescription
git citoolOpen the Git Commit Tool
CommandDescription
git gcCleanup unnecessary files and optimize the local repository
git gc --autoRun automatic garbage collection
git gc --pruneRemove unreachable objects from the repository
git gc --aggressivePerform aggressive garbage collection
git gc --quietRun garbage collection quietly (suppress output)
git gc --auto --quietRun automatic garbage collection quietly
git gc --aggressive --prunePerform aggressive garbage collection with pruning
CommandDescription
gitkOpen the Git repository browser
CommandDescription
git guiLaunch the Git GUI
git gui blame <filename>View file history in Git GUI
git gui citoolLaunch the Git Commit Tool
git gui browserOpen the Git Repository Browser
CommandDescription
git worktree add <path> <branch>Create a new working directory linked to a branch
git worktree listList all linked working trees
git worktree lock <path>Lock a working tree to prevent modifications
git worktree unlock <path>Unlock a previously locked working tree
git worktree prunePrune stale working tree metadata
git worktree remove <path>Remove a linked working tree
git worktree move <path> <new-path>Move a linked working tree to a new location
git worktree add <path> <commit-ish>Create a new working directory linked to a specific commit
git worktree add <path> --detachCreate a new working directory linked to HEAD, detached from any branch
git worktree add <path> <branch> --lockCreate a new working directory linked to a branch and lock it
git worktree add <path> <branch> --forceCreate a new working directory even if the path already exists
git worktree add <path> <branch> --recurse-submodulesCreate a new working directory with submodules initialized

About

This repo stores essential Git commands, commit message formats, and Python commands for quick reference. It ensures consistent commits, improves workflow, and provides handy Python snippets for automation. Perfect for streamlining development and maintaining best practices. 🚀

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published