Assuming as an example that the remote upstream
has been added and you need to send code from the local branch develop
to the remote branch dev-master
, to be able to execute this operation just execute the command below:
git push upstream develop:dev-master
git push github develop:master --no-verify
{% hint style="info" %}
When you want to ignore files but want to keep a directory you can add a .gitignore
file within the desired directory with the following content
{% endhint %}
*
!.gitignore
git branch --show-current
{% hint style="info" %} To clear your entire Git cache, use the “git rm” command with the “-r” option for recursive {% endhint %}
git rm -r --cached .
{% hint style="info" %} When all files are removed from the index, you can add the regular files back (the one you did not want to ignore) {% endhint %}
git add .
$ git commit -am 'Removed files from the index (now ignored)'
git config credential.helper store
git config --global credential.helper 'cache --timeout 7200'
git stash --include-untracked
git stash push path/to/file
git checkout 3df73866bef5d560ef2e5s59b6deaa18001 -- wp-content/uploads/2011 wp-content/uploads/2012
git revert --no-commit 0766c053..HEAD
When you accidentally modify the permissions of versioned files, it is possible to return to the initial permission state using the command below
git diff -p -R --no-ext-diff --no-color \
| grep -E "^(diff|(old|new) mode)" --color=never \
| git apply
If you want to use globally, you can do it that way:
git config --global --add alias.permission-reset '!git diff -p -R --no-ext-diff --no-color | grep -E "^(diff|(old|new) mode)" --color=never | git apply'
git permission-reset
git reset --hard master@{"300 minutes ago"}
git reset --soft HEAD~1
git branch -m new-name
If you are on a different branch:
git branch -m old-name new-name
- Delete the old-name remote branch and push the new-name local branch.
git push origin :old-name new-name
- Reset the upstream branch for the new-name local branch.
Switch to the branch and then:
git push origin -u new-name
To find files that have been versioned, regardless of whether they were removed from versioning or not.
git log --all --full-history -- "**/thefile.*"
# Only commits by Vinicius
git log --author="Vinicius"
# Use "--all" to search all branches
git log --author="Vinicius" --all
# Many Authors
git log --author="\(Vinicius\)\|\(Jose\)"
git log --author='^(?!Vinicius|Jose).*$' --perl-regexp
# Globally
git config --global add remote.{remote_name} proxy
# Locally
git config --local --add remote.{remote_name}.proxy ""
git rebase -i HEAD~4
git push origin --delete branchName
git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
git pull upstream master
The easiest way to use prune is to provide it as an option when fetching:
$ git fetch --prune origin
In cases where you'd like to only perform a prune and not fetch remote data, you can use it with the git remote
command:
$ git remote prune origin
If you want to have prune executed with every fetch operation, you can configure Git accordingly:
$ git config --global fetch.prune true
git tag -a 0.0.0 -m "initial Changelog"