Skip to content

emrahdk/scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

Scripts and helpful commands

Git

Syncing

Push all branches to remote

git push --all

Push all tags to remote

git push --tags

Fetch and remove non-existing branches on remote

git fetch -p

Prune and fetch tags

git tag -l | xargs git tag -d && git fetch -t

Clean up repo

Dry run

git clean --dry-run

Force and remove directories

git clean -f -d

Branch

Delete local branch

git branch -d <branch-name>

Delete remote branch

git push origin :<remote-branch-name>

Rename local branch

git branch -m <new-name>

Create and checkout branch

git checkout -b <branch_name>

Commits

Reset to head

git reset --hard HEAD

Reset to commit

git reset --hard <commit sha>

Partially revert commit

git revert <bad-commit-sha> --no-commit
git reset
<edit/recover bad file(s)>
git add <bad-files>
git checkout .
git commit

Stage all changes and commit

git commit -a -m <message>

Remote

List remotes

git remote -v

Remove remote

git remote rm <REMOTE>

Save stash as patch and applying it

Saving

git stash show 1 --patch > example.patch

Applying

git apply --3way example.patch

Environment paths (on Windows)

Set environment variable for user

setx <key> <value>

Set environment variable system wide

setx <key> <value> /M

NuGet

Pack and build release with symbols

nuget pack <project>.csproj -Build -Symbols -Properties Configuration=<configuration>

Pack using dotnet

dotnet pack --include-symbols -c <configuration>

Update assembly redirects

In Package Manager Console

Get-Project -All | Add-BindingRedirect

WSL (Windows Subsystem Linux)

Setup with Windows Credentials Manager

git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-wincred.exe"

Fix file line breaks

dos2unix.exe -b <FILE>

Linux specific things

Enable ports on RHEL / CentOS

List currently open ports

firewall-cmd --list-ports

List zones

firewall-cmd --get-zones

List the zone containing eth0

firewall-cmd --get-zone-of-interface=eth0

Open TCP port

firewall-cmd --add-port <PORT>/tcp

Open TCP port permenantly

firewall-cmd --permanent --add-port 1191/tcp

Open a range of TCP ports

firewall-cmd --permanent --add-port 60000-61000/tcp

Restart the firewall

systemctl stop firewalld
systemctl start firewalld

BASH

Create multiple files at once

touch somefile.{js,css,txt}
touch product-{image,description,options}.js

Locate stuff

locate my.file

Transfer via SSH / SCP

General

scp /path/to/file.blob /path/to/destination/

With credentials

scp /path/to/file username@machine:/path/to/destination

Other direction

scp username@machine:/path/to/file /path/to/destination

Through a proxy (from Origin to Proxy to Destination)

scp -r -o 'ProxyCommand ssh user@proxy %h %p' path/at/origin/ user@destination:/path/at/destination/

Notes

Add -r for recursive and -p for preserving system metadata


SSH

Send commands through a proxy (from Origin to Proxy to Destination)

ssh -J user@proxy user@destination 'cd /home && ls -a'

Copy ID to remote server for quick authentication

ssh-copy-id <remote>

WCF / SOAP things

Use Developer Command Prompt for VS 2019 to get af hold of svcutil

svcutil http://example.service.dk/?wsdl=wsdl2 /out:MyService.cs /ct:System.Collections.Generic.List`1 /n:http://example.service.dk/Something/2020/10/,Some.Namespace.MyService

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages