Skip to content

Instantly share code, notes, and snippets.

View yzgyyang's full-sized avatar

Guangyuan Yang yzgyyang

View GitHub Profile
@yzgyyang
yzgyyang / Git_create_a_new_repo_based_on_existing_ones.md
Created June 28, 2017 21:55
Git create a new repo based on existing ones

cd to local repo containing old_branch and:

git push https://github.com/accountname/new_repo.git +old_branch:master
@yzgyyang
yzgyyang / FreeBSD_mount_img_files.md
Created June 28, 2017 20:46
FreeBSD mount img files

Determine the file system by using the file-utility.

file image.img

Use mdconfig to link the IMG image to a virtual device.

mdconfig -a -t vnode -f /path/to/image.img -u 0
@yzgyyang
yzgyyang / FreeBSD_backup_filesystem.md
Created June 20, 2017 15:15
FreeBSD backup filesystem

To dump a filesystem into /mnt (a filesystem mounted on a seperate disk)…

cd /mnt
dump -L -0 -f- /path/to/origin | restore -r -f-

For remote operations, pipe the restore command via ssh:

dump -L -0 -f- /path/to/origin | ssh -2 -C -l remoteuser 192.168.0.2 restore -r -f-
@yzgyyang
yzgyyang / Skip_sudo_password.md
Last active June 20, 2017 15:07
Skip sudo password

Edit the sudoers file:

sudo visudo

Find this line:

%sudo ALL=(ALL) ALL
@yzgyyang
yzgyyang / Git_discard_unstaged_changes.md
Last active June 12, 2017 13:55
Git discard unstaged changes

To remove all untracked files:

git clean -df

For a specific file use:

git checkout path/to/file/to/revert
@yzgyyang
yzgyyang / Git_remember_Github_login_credentials.md
Last active June 20, 2017 15:05
Git remember Github login credentials

Set git to use the credential memory cache:

git config --global credential.helper cache

To change the default password cache timeout, enter the following:

git config --global credential.helper 'cache --timeout=3600'
# (setting is in seconds)