Snippets Collections
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
git push origin <your_branch_name> --force
git branch -d <local-branch> (soft delete)

git branch -D <local-branch> (hard delete)

git push origin --delete <remote-branch-name>
git fetch origin master:tmp
git rebase tmp
git push origin HEAD:master
git branch -D tmp
git clone --branch <branchname> <remote-repo-url>
git for-each-ref --sort=committerdate --format='%(committerdate) %09 %(authorname) %09 %(refname)'
alias co_today="git hist | grep 'Alex' | grep $(date +"%Y-%m-%d") | grep -v "Merge" | sed -e 's/\[[^][]*\]//g' | sed -e 's/\((^())*\)//g' | sed 's@.*|@@'"
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone             Clone a repository into a new directory
   init              Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add               Add file contents to the index
   mv                Move or rename a file, a directory, or a symlink
   restore           Restore working tree files
   rm                Remove files from the working tree and from the index
   sparse-checkout   Initialize and modify the sparse-checkout

examine the history and state (see also: git help revisions)
   bisect            Use binary search to find the commit that introduced a bug
   diff              Show changes between commits, commit and working tree, etc
   grep              Print lines matching a pattern
   log               Show commit logs
   show              Show various types of objects
   status            Show the working tree status

grow, mark and tweak your common history
   branch            List, create, or delete branches
   commit            Record changes to the repository
   merge             Join two or more development histories together
   rebase            Reapply commits on top of another base tip
   reset             Reset current HEAD to the specified state
   switch            Switch branches
   tag               Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch             Download objects and refs from another repository
   pull              Fetch from and integrate with another repository or a local branch
   push              Update remote refs along with associated objects
- git init         #Initialise locat repositiry
- git add <file>   #Add files to index
- git status       #Check status of working tree
- git commit       #Commit changes in index
- git push         #Push to remote repository
- git pull         #Pull latest from remote repository
- git clone        #Clone repository into a new directory
1. Configure
- git config --global 'Ian Horne'
- git config --global ''
2. File to staging
- git add <file name> #Add file 
- git rm <file name>  #Remove file
- git add *.py        #Add all .py files to staging area
- git add .           #Add all files in directory to staging area
3. Commit staging area to your local repository
- git commit -m "your comments"
4. Ignore file
- create .git ignore file <touch .gitignore> 
- enter file or folder into .gitignore file to exclude it from the repository 
   -Add file           - <file.ext>
   -Add directory      - </dirname> 
   -Add all text files - <*.txt>
5. Branches -
- git branch <branch_name>    #Create branch
- git checkout <branch_name>  #move to branch
- git add <filename>          #add file change to branches
- git commit -m "comments"    #commit file and add comments
- git checkout <master>       #move to main branch
- git merge <branch name>     #merge branch into current branch location
- git push                    #push branch to hub
- git branch -d <branch>      #delete branch

6. Remove repositories
- Create new repository
- git remote                #list all remote repositories
- git remote add origin
- git push -u origin master
Future workflow
- change file
- git add .
- git push
Clone repository 
- git clone <get link from GIT hub>  #Clone repository from GIT Hub
- git pull                           #Get latest updates
- create a new repository on the command line
    git init
    git add
    git commit -m "first commit"
    git branch -M main
    git remote add origin <HTTPS>
    git push -u origin main

- push an existing repository from the command line
    git remote add origin
    git branch -M main
    git push -u origin main
$ git clone

Tue Sep 21 2021 10:42:30 GMT+0000 (UTC)

#setting #git

Thu Sep 09 2021 07:28:12 GMT+0000 (UTC)

#git #github

Sun Aug 01 2021 13:53:18 GMT+0000 (UTC)


Wed Jul 28 2021 04:56:58 GMT+0000 (UTC)

#git #clone #branch

Sat Jul 24 2021 03:10:17 GMT+0000 (UTC)

#git #clone

Mon May 10 2021 11:54:02 GMT+0000 (UTC)


Thu Apr 01 2021 14:38:08 GMT+0000 (UTC)


Mon Oct 26 2020 07:36:25 GMT+0000 (UTC)

#git #help

Mon Oct 26 2020 04:28:26 GMT+0000 (UTC)


Mon Oct 05 2020 13:23:12 GMT+0000 (UTC)


Wed Dec 25 2019 18:55:34 GMT+0000 (UTC)

#commandline #git #github #howto

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension