Skip to content

Instantly share code, notes, and snippets.

@emrahoruc
Last active March 26, 2024 17:42
Show Gist options
  • Save emrahoruc/af3eb994c5e12bf8903c9004bf6e05a3 to your computer and use it in GitHub Desktop.
Save emrahoruc/af3eb994c5e12bf8903c9004bf6e05a3 to your computer and use it in GitHub Desktop.
Git Commands
git diff --name-only SHA1 SHA2 | xargs tar -zcf update.tar.gz
cp -pv --parents `git ls-tree -r --name-only COMMIT_SHA_OR_BRANCH_NAME` ../output-folder
# export changed files between two commits
cp -pv --parents `git diff --name-only COMMIT_SHA_1 COMMIT_SHA_2` ../output-folder
# diff list
git diff --numstat COMMIT_SHA_1 COMMIT_SHA_2
# unzip archive
unzip DemoApp.zip -d ../output-folder
chown -R owner:group ../output-folder
# Steps
git clone -b branchname remote-repo-url .
git fetch
git checkout -b remote_branch origin/remote_branch
git pull origin branch_name
# Show changes
git diff # Show changes between commits, commit and working tree, etc
git diff path/filename.txt # Show changes of file
git diff --name-only # Show only names of changed files
# Reset changes
git checkout -- filename.txt # Reset file
# Export stash
git stash list
git stash show "stash@{0}" -p --binary > changes.patch
git apply changes.patch
# Safely storing git credentials
## Using store. It will actually create a plain text file ~/.git-credentials with the password. UNSECURE!!!
git config credential.helper store
## Using libsecret.
cd /usr/share/doc/git/contrib/credential/libsecret
sudo make
git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
## Reset the settings
git config --unset credential.helper
# Temporarily adding password to configuration
In project .git/config add :password after username
https://username:password@bitbucket.org/repo.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment