Skip to content

Instantly share code, notes, and snippets.

@githubfoam
Last active July 7, 2023 07:59
Show Gist options
  • Save githubfoam/3bd08c2aeaf1c76985294f8d75c0bfad to your computer and use it in GitHub Desktop.
Save githubfoam/3bd08c2aeaf1c76985294f8d75c0bfad to your computer and use it in GitHub Desktop.
git command cheat sheet
---------------------------------------------------------------------------------------------------
#vscode 1.63.2
#remove deleted branches on github that still exist on vscode
Vscode-File-Preferences-Settings-Git-Git:Prune On Fetch #make VS Code run git fetch --prune when fetching remote refs
Vscode-Terminal
git fetch --prune #update/delete remote branch references
git fetch -p #update/delete remote branch references
git branch <branch-name> -D #delete the local branch (-D to force)
Vscode-View-Command Palette-Git Fetch(Prune)
git branch -r | grep -v "master" | xargs git branch -D #remove all the local branches (except master)
---------------------------------------------------------------------------------------------------
# how to contribute a github project, ATOM editor
fork github project on the website
Packages - Command Palette - Toggle - GitHub:Clone
create new branch
make changes
commit changes
proceed with "compare-pull request" on forked github website.
----------------------------------------------------------------------------------------------------
# Update a Local Fork at the Terminal, already forked github project
git remote -v
git remote add upstream https://github.com/OriginalOwner/OriginalProject.git #Specify a remote upstream repo to sync with your fork:
git remote -v
git fetch upstream #Fetch branches and commits from the upstream repo
git checkout master #Checkout your fork’s local master
git merge upstream/master # merge changes from upstream into master
-------------------------------------------------------------------------------------------------
git config --global -l
git config --local -l
git remote -v
~/.gitconfig -> global settings
git config --global user.name "Your Name Here"
git config --global user.email [email protected]
root of repo -> configure an individual repo to use a specific user / email address which overrides the global configuration.
git config user.name "Your Name Here"
git config user.email [email protected]
git config --global http.sslcapath "D:\fortigate\Fortinet_CA_SSL.crt"
git config --global http.sslcainnfo "D:\Fortinet_CA_SSL.crt"
git config --global --get http.sslverify # check if this configuration is set
#check the configuration file for Git
#The configuration file is located at ~/.gitconfig on Unix-like systems
#and %USERPROFILE%\.gitconfig on Windows systems
git config --global --list #view the contents of the global Git configuration file
git config --list -f .gitconfig # specify a different path to the .gitconfig file
git config --global http.sslverify "false"
============================================================================
git checkout master -> Checkout the branch where you want to create tag
git tag v1.0 -> Create tag name
git show v1.0 -> Show tag details
git tag -l -> List tags
git tag -d v1.0 -> Delete tag
git push origin v1.0 -> Push tags to remote
git checkout -b branchname tagname -> Create a branch from a tag and checkout the branch
git checkout -b master v1.0
git tag tagname commitreference -> Create a tag from a past commit , "git log"
git clone https://github.com/greenbone/gvm-libs.git && cd gvm-libs
git tag -l
git tag | sort -V | tail -1
git checkout tags/v21.4.3 (Releases/Tags)
============================================================================
git clone https://github.com/greenbone/gvm-libs.git directoryName #clone into a directory
============================================================================
#behind master?
102 git pull origin kernelupgrade
103 git merge origin kernelupgrade
105 git push -u origin kernelupgrade
#SSH
#existing empty repository on github.com
git clone git://github.com/username/test2
cd test2
touch READMEtest.md
git add README.md
git commit -S -m 'add README extra'
git push -u origin master
git log-- list commits
git branch --list
git branch --all
============================================================================
git clone -b develop [email protected]:user/myproject.git #clone a specific branch
#git branch -a shows all branches
git clone -b feature https://github.com/Repository/Project.git
#--single-branch flag to prevent fetching details of other branches,git branch -a shows current single branch
git clone --single-branch --branch master https://github.com/career-karma-tutorials/ck-git #only the master branch
git clone https://github.com/micronucleus/micronucleus.git
cd micronucleus
git checkout main
============================================================================
# selective merge, cherry pick commit
# You are in the branch you want to merge to
git checkout <branch_you_want_to_merge_from> <file_paths...>
git status
git commit -m "Merge changes on '[branch]' to [file]"
============================================================================
# selective merge, cherry pick commit
# checkout main branch where you'll be applying matches
git checkout -b main
# Apply your patches dev to main
git checkout --patch dev path/to/file
============================================================================
# selective merge, cherry pick commit
# apply changes from twitter_integration branch to master branch
$ git branch
* master
twitter_integration
$ git checkout twitter_integration app/models/avatar.rb db/migrate/20090223104419_create_avatars.rb
$ git status
# On branch master
# Changes to be committed:
============================================================================
# selective merge, cherry pick commit
#vscode View - Terminal
# go to main branch you want to merge test branch into
> git checkout main
# verify you are on the main branch
> git branch
* main
test
#cherrypick file you want to merge from test branch into main branch
> git checkout test .github/workflows/macos-build-cpp-wf.yml
Updated 1 path from e6eda2a
============================================================================
# selective merge, cherry pick commit
# Make a new branch (this will be temporary)
git checkout -b newbranch
# Grab the changes
git merge --no-commit featurebranch
# Unstage those changes
git reset HEAD
(You can now see the files from the merge are unstaged)
# Now you can chose which files are to be merged.
git add -p
# Remember to "git add" any new files you wish to keep
git commit
============================================================================
============================================================================
gists
============================================================================
https://api.github.com/users/githubfoam/gists
`html_url` list gists
============================================================================
#type in search box
https://gist.github.com/discover
NOT .bash_profile #Excludes all results containing your search term
user:githubfoam
extension:yml #gists with a .yml extension
language:html #gists with HTML files
filename:.bash_profile #gists with HTML files
stars:>78 #gists with greater than 78 stars
anon:true #anonymous gists
fork:only #forked gists
workshop fork:only
topic:pentest
jquery in:name #matches repositories with "jquery" in the repository name
jquery in:name,description #matches repositories with "jquery" in the repository name or description
jquery in:readme #matches repositories mentioning "jquery" in the repository's README file
============================================================================
https://docs.github.com/en/github/searching-for-information-on-github/searching-for-repositories#search-by-when-a-repository-was-created-or-last-updated
============================================================================
#Update all Git repositories on a directory
for i in */.git; do cd $(dirname $i); git pull; cd ..; done
============================================================================
#ChatGPT
The error message "fatal: unable to access 'https://github.com/danielmiessler/SecList/': server certificate verification failed. CAfile: none CRLfile: none" typically occurs when Git is unable to verify the SSL certificate of the remote repository. This can happen if the SSL certificate is invalid or if Git is unable to locate the necessary certificate files. To fix this error, you can follow these steps:
Verify the internet connection: Ensure that your server or computer has a stable internet connection. The error can occur if there are connectivity issues.
Update Git: Make sure you have the latest version of Git installed. Older versions may have issues with SSL certificate verification. You can update Git using the appropriate package manager for your operating system.
Configure Git to use a certificate authority: Git needs access to certificate authority (CA) certificates to verify SSL connections. If you don't have CA certificates installed on your system, you can download the appropriate certificate bundle from a trusted source or use the certificate bundle provided by your operating system.
Option 1: Use the certificate bundle provided by your operating system:
On Debian/Ubuntu: Install the ca-certificates package using the command sudo apt-get install ca-certificates.
On CentOS/RHEL: Install the ca-certificates package using the command sudo yum install ca-certificates.
On macOS: Update your system software to ensure you have the latest CA certificates.
Option 2: Manually download and configure CA certificates:
Download the CA certificates from a trusted source and save them on your system.
Configure Git to use the downloaded CA certificates by running the following command:
css
git config --global http.sslCAInfo /path/to/certificate-bundle.crt
Replace /path/to/certificate-bundle.crt with the actual path to the downloaded certificate bundle.
Retry the Git operation: After configuring Git to use CA certificates, try the Git operation again, such as cloning the repository or pulling changes.
bash
git clone https://github.com/danielmiessler/SecList.git
If the SSL certificate issue was the cause of the error, it should now be resolved.
By following these steps and ensuring that Git can verify SSL certificates using the appropriate CA certificates, you should be able to fix the "server certificate verification failed" error and successfully clone or interact with the remote repository.
============================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment