Snippets Collections
git remote add origin ssh://git@git.domain.tld/repository.git 

git remote -v
occ -c widget/element

configs

edit configs file

occ -p /relative-path
git commit --amend --author="Author Name <email@address.com>" --no-edit
 git config --global alias.ci "commit"
 git config --global alias.st "status"
 git config --global alias.co "checkout"
git config –global user.name “[name]”  
git config –global user.email “[email address]”  
git init [repository name]
git clone [url] 
git add [file] 
git add *  
git commit -m “[ Type in the commit message]” 
git commit -a  
git rm [file]
git branch
git branch [branch name]
git checkout [branch name]
git checkout -b [branch name]
git merge [branch name]  
git remote add [variable name] [Remote Server Link]  
git push [variable name] master  
git pull [Repository Link]  

git rm -rf .git
git config --global alias.glg 'log --oneline --decorate --all --graph'
git config --global alias.amend 'commit --amend --reuse-message=HEAD'
git add -p
git commit 
git add -p
git amend 

git config --global alias.changelog "log origin..HEAD --format='* %s%n%w(,4,4)%+b'"
git config --global alias.workon '!f(){ git fetch && git checkout -b "$1" $(git symbolic-ref refs/remotes/origin/HEAD | sed "s@^refs/remotes/@@"); };f'
git config --global alias.cleanup-merged "!f(){ git fetch && git branch --merged | grep -v '* ' | xargs git branch --delete; };f"


- name: setup git aliases
  community.general.git_config:
    scope: global
    state: present
    name: "alias.{{ item.alias }}"
    value: "{{ item.value }}"
  with_items:
    - alias: changelog
      value: log origin..HEAD --format='* %s%n%w(,4,4)%+b'
    - alias: glg
      value: log --oneline --decorate --all --graph
    - alias: amend
      value: commit --amend --reuse-message=HEAD
    - alias: workon
      value: '!f(){ git fetch && git checkout -b "$1" $(git symbolic-ref refs/remotes/origin/HEAD | sed "s@^refs/remotes/@@"); };f'
    - alias: refresh
      value: '!f(){ git fetch && git stash && git rebase $(git symbolic-ref refs/remotes/origin/HEAD | sed "s@^refs/remotes/@@") && git stash pop; };f'
    - alias: cleanup-merged
      value: "!f(){ git fetch && git branch --merged | grep -v '* ' | xargs git branch --delete; };f"
82FCD54A-74bf-2CE93-41d6-A4389de1bd2
#!/bin/bash

wget https://release.gitkraken.com/linux/gitkraken-amd64.deb
sudo dpkg -i ./gitkraken-amd64.deb
sudo apt-get install -f
gitkraken
# configuration file for git-cliff

[changelog]
header = """
# Changelog
*All notable changes to this project will be documented in this file.*\n
"""
body = """
{% if version %}\
    ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
    ## [Unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
    ### {{ group | upper_first }}
    {% for commit in commits %}
        - {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
    {% endfor %}
{% endfor %}\n
"""
trim = true
footer = """
***
*Changelog generated by [git-cliff](https://github.com/orhun/git-cliff).*
"""
[git]
conventional_commits = true
filter_unconventional = true
commit_parsers = [
    { message = "^feat", group = "Features"},
    { message = "^fix", group = "Bug Fixes"},
    { message = "^bug", group = "Bug Fixes"},
    { message = "^doc", group = "Documentation"},
    { message = "^perf", group = "Performance"},
    { message = "^app", group = "Shiny App"},
    { message = "^api", group = "API"},
    { message = "^data", group = "Data"},
    { message = "^db", group = "Database"},
    { message = "^refactor", group = "Refactor"},
    { message = "^style", group = "Styling"},
    { message = "^test", group = "Testing"},
    { message = "^chore\\(release\\): prepare for", skip = true},
    { message = "^chore", group = "Miscellaneous Tasks"},
    { body = ".*security", group = "Security"},
]
filter_commits = false
tag_pattern = "v[0-9]*"
skip_tags = "v0.1.0-beta.1"
ignore_tags = ""
topo_order = false
sort_commits = "oldest"
# Initialise local repo
git init         

# Stage files to index
git add <file>

# Check status of working tree
git status       

# Commit changes in index
git commit

# Push to remote repository
git push

# Pull latest from remote repository
git pull

# Clone repository into a new directory
git clone

###########
# Configure
###########

# Setup
git config --global user.name '<name>'
git config --global user.email '<email>'
git config --global init.defaultBranch main

# Protocol
git config --global default.protocol ssh

# Long path support
git config --global core.longpaths true

# GPG signatures
git config --global gpg.program '<path to gpg>'
git config --global user.signingKey '<GPG signature>'
git config --global commit.gpgSign true
git config --global tab.forceSignAnnotated true

# Globals
git config --global core.excludesFile = '<path to global .gitignore>'
git config --global core.attributesFile = '<path to global .gitattributes'

# Color
git config --global color.ui true

#################
# Staging Process
#################

# Stage file
git add <file name>   

# Un-Stage File
git rm <file name>

# Add all *.py files
git add *.py

# Add Everything that has changed
git add .
# or
git add *

#################
# Commit Process
#################

# Commit staging area to your local repository
git commit -m "<commit message>"


#############
# Branching
#############

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
 
####################
# Remote Repository
####################

# list all remote repositories
git remote

# add origin (HTTPS)
git remote add origin 'https://github.com/<user>/<repo>.git

# add origin (SSH)
git remote add origin 'git@github.com:<user>/<repo>.git'

# initialize origin in first push
git push -u origin main # or master
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch .env" HEAD
 
git push --force
git log --all --graph --decorate
git reset --hard
git pull
for repo in $(curl -s --header "PRIVATE-TOKEN: your_private_token" "https://<your-host>/api/v4/groups/<group_id>" | jq ".projects[].ssh_url_to_repo" | tr -d '"'); do git clone $repo; done;
#!/usr/bin/env sh

__git_ps1() {
    git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'
}
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch .env" HEAD

git push --force
git config \
  --global alias.clrdiff \
  "difftool --extcmd 'icdiff --highlight --line-numbers --numlines=3 --tabsize=2 --cols=135'"
git checkout <old_name>
git branch -m <new_name>
git push origin -u <new_name>
git push origin --delete <old_name>
To untrack a single file that has already been added/initialized to your repository, i.e., stop tracking the file but not delete it from your system use: git rm --cached filename

To untrack every file that is now in your .gitignore:

First commit any outstanding code changes, and then, run this command:

$ git rm -r --cached .

This removes any changed files from the index(staging area), then just run:

$ git add .

Commit it:

$ git commit -m ".gitignore is now working"

*Note :- Be sure to merge your branches back to master or move your pointer otherwise you might lose your branch 
git log --all --graph --decorate
$ npx @wordpress/create-block [options] [slug]
$ git reset --hard HEAD~1

HEAD is now at 90f8bb1 Second commit
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 user.name 'Ian Horne'
- git config --global user.email 'ian@ihorne.com'
##-----------------------------------------------------------------------------
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 - https://www.atlassian.com/git/tutorials/using-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 https://github.com/Ianhorne73/WageReport.git
- 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 README.md
    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 https://github.com/ramdaniAli/backupApp.git
    git branch -M main
    git push -u origin main
$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
star

Mon Apr 04 2022 11:21:06 GMT+0000 (UTC) https://www.digitalocean.com/community/tutorials/how-to-use-git-effectively

#git
star

Wed Mar 16 2022 13:15:11 GMT+0000 (UTC)

#git
star

Tue Mar 15 2022 22:57:58 GMT+0000 (UTC)

#git
star

Tue Mar 08 2022 11:36:41 GMT+0000 (UTC) https://learntutorials.net/es/git/topic/337/alias

#git #alias
star

Fri Mar 04 2022 06:04:51 GMT+0000 (UTC)

#git
star

Sun Feb 27 2022 04:50:49 GMT+0000 (UTC) https://www.lazy-electron.com/2021/07/29/git-aliases.html

#git #tool #work
star

Mon Feb 14 2022 13:26:23 GMT+0000 (UTC)

#bash #git
star

Wed Feb 02 2022 22:09:23 GMT+0000 (UTC) https://github.com/jimbrig/dotfiles-wsl/blob/main/scripts/dev/scripts/install-gitkraken.sh

#installation #linux #bash #wsl #git
star

Wed Feb 02 2022 21:56:04 GMT+0000 (UTC)

#git
star

Wed Feb 02 2022 21:43:42 GMT+0000 (UTC) https://h.daily-dev-tips.com/removing-a-env-file-from-git-history

#git
star

Wed Feb 02 2022 21:42:51 GMT+0000 (UTC)

#git
star

Wed Feb 02 2022 21:41:34 GMT+0000 (UTC) https://stackoverflow.com/questions/4157189/how-to-git-pull-while-ignoring-local-changes

#git
star

Sat Jan 29 2022 18:10:32 GMT+0000 (UTC) https://opensource.com/article/21/4/git-stash

#git
star

Fri Jan 14 2022 07:36:23 GMT+0000 (UTC) https://stackoverflow.com/questions/29099456/how-to-clone-all-projects-of-a-group-at-once-in-gitlab

#sh #git
star

Sat Jan 08 2022 06:27:13 GMT+0000 (UTC) https://gist.github.com/juliyvchirkov/883a050c34e23f4b4fba6ecaeb050c3b

#sh #git #ps1 #shell
star

Tue Dec 21 2021 14:38:32 GMT+0000 (UTC) https://stackoverflow.com/questions/4157189/how-to-git-pull-while-ignoring-local-changes

#bash #git
star

Thu Dec 16 2021 03:15:20 GMT+0000 (UTC) https://h.daily-dev-tips.com/removing-a-env-file-from-git-history

#git
star

Thu Dec 02 2021 19:15:03 GMT+0000 (UTC)

#git
star

Thu Dec 02 2021 19:13:18 GMT+0000 (UTC)

#git
star

Thu Nov 18 2021 05:05:21 GMT+0000 (UTC)

#git #github #issue
star

Wed Nov 17 2021 14:07:48 GMT+0000 (UTC)

#git
star

Mon Oct 25 2021 05:16:11 GMT+0000 (UTC) https://www.npmjs.com/package/@wordpress/create-block

#wordpress #gutenberg #git #npm
star

Thu Oct 21 2021 05:12:26 GMT+0000 (UTC) https://devconnected.com/how-to-undo-last-git-commit/

#java #git
star

Tue Sep 21 2021 10:42:30 GMT+0000 (UTC) https://stackoverflow.com/questions/10312521/how-to-fetch-all-git-branches#10312587

#setting #git
star

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

#git #github
star

Sun Aug 01 2021 13:53:18 GMT+0000 (UTC) https://stackoverflow.com/questions/28429819/rejected-master-master-fetch-first

#git
star

Wed Jul 28 2021 04:56:58 GMT+0000 (UTC) https://www.freecodecamp.org/news/git-clone-branch-how-to-clone-a-specific-branch/

#git #clone #branch
star

Sat Jul 24 2021 03:10:17 GMT+0000 (UTC) https://www.freecodecamp.org/news/git-clone-branch-how-to-clone-a-specific-branch/

#git #clone
star

Mon May 10 2021 11:54:02 GMT+0000 (UTC) https://stackoverflow.com/questions/53051630/git-list-remote-branches-with-their-author-names

#git
star

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

#git
star

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

#git #help
star

Mon Oct 26 2020 04:28:26 GMT+0000 (UTC) https://www.youtube.com/watch?v=SWYqp7iY_Tc

#git
star

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

#git
star

Wed Dec 25 2019 18:55:34 GMT+0000 (UTC) https://help.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository

#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