Last active
March 19, 2021 12:37
-
-
Save iamtodor/aeac47187be372564b457c97319d4e9d to your computer and use it in GitHub Desktop.
git notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Отменить с ветки много пушей! | |
git reset --hard HEAD~1 | |
git push origin HEAD --force | |
------------------------------------------------------------------------------- | |
This will remove all local untracked files, so only git tracked files remain: | |
git clean -fdx | |
------------------------------------------------------------------------------- | |
git checkout master | |
git merge --squash bugfix | |
git commit | |
------------------------------------------------------------------------------- | |
If you use SourceTree and the default setting it will ignore all DLLs by default... | |
Tools=>Options=>Git then "Edit File"... add a "#" before .dll => "#.dll" ... save and close. | |
------------------------------------------------------------------------------- | |
После ребейсинга | |
git add . -убрасть с анстейджа после ребейса | |
------------------------------------------------------------------------------- | |
VCS - Git - Rebase | |
Feature Branch | |
| | |
| | |
\|/ | |
onto | |
Develop | |
------------------------------------------------------------------------------- | |
https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project | |
------------------------------------------------------------------------------- | |
feature/signature_sync | |
------------------------------------------------------------------------------- | |
https://help.github.com/articles/generating-ssh-keys/ | |
ssh-keygen -t rsa -C "[email protected]" | |
------------------------------------------------------------------------------- | |
git remote add origin https://github.com/YvgenTroshchiy/test_actionbarsherlock.git | |
------------------------------------------------------------------------------- | |
git remote -v // Show remote repositories | |
------------------------------------------------------------------------------- | |
Go to Team > Remote > Push… from the menu. Select your repository, and click Next. | |
Under Remote ref to delete… select your branch and click Add spec. Then click Finish. | |
This should delete the remote branch. | |
------------------------------------------------------------------------------- | |
git clone --recursive <git link> // Clone with submodule | |
------------------------------------------------------------------------------- | |
Remove file | |
git rm --cached file1.txt | |
(use --cached to keep the file, or -f to force removal) | |
git commit -m "remove file1.txt" | |
------------------------------------------------------------------------------- | |
!!! | |
git merge --no-ff myfeature | |
The --no-ff flag causes the merge to always create a new commit object, | |
even if the merge could be performed with a fast-forward. | |
This avoids losing information about the historical existence of a feature branch | |
and groups together all commits that together added the feature. | |
Merge all changes from another branch as a single commit | |
git merge --squash <feature branch> | |
------------------------------------------------------------------------------- | |
//delete remote folder | |
git rm -r --cached some-directory | |
git commit -m "Remove duplicated directory" | |
git push origin master | |
------------------------------------------------------------------------------- | |
git show remote origin // Determine the URL git remote repository | |
git reset --soft HEAD^ // Undo last commit, put changes into staging | |
HEAD~1 | |
git reset --hard HEAD^ delete // Undo last commit and all changes | |
git reset --hard HEAD^^ // Undo 2 last commit and all changes | |
git push origin --delete <branchName> // Delete remote Branch | |
git push -f origin HEAD^:develop // Undo push | |
git push -f origin <sha_of_previous_commit>:master | |
------------------------------------------------------------------------------- | |
Before you can start working locally on a remote branch, you need to fetch it as called out in answers below. | |
fetch (or Sync) | |
git fetch origin | |
This will fetch all of the remote branches for you. With the remote branches in hand, you now need to check out the branch | |
you are interested in, giving you a local working copy: | |
git checkout -b test origin/test | |
------------------------------------------------------------------------------- | |
git push <REMOTENAME> <LOCALBRANCHNAME>:<REMOTEBRANCHNAME> | |
git branch // Show branches | |
git branch -r // Show remote branch | |
git remote update --prune // Update information about branch | |
------------------------------------------------------------------------------- | |
// creating patch | |
git format-patch -M hash-commit-1 | |
//applying patch | |
git am --signoff < patch_name.patch (--3way) | |
------------------------------------------------------------------------------- | |
// undo a git add - remove files staged for a git commit | |
git reset filename.txt | |
------------------------------------------------------------------------------- | |
Remove directory from git and local | |
git rm -r one-of-the-directories | |
git commit -m "Remove duplicated directory" | |
git push origin <your-git-branch> (typically 'master', but not always) | |
------------------------------------------------------------------------------- | |
Remove directory from git but NOT local | |
git rm -r --cached myFolder | |
------------------------------------------------------------------------------- | |
Remove remote branch | |
git push <remote_name> --delete <branch_name> | |
------------------------------------------------------------------------------- | |
Save login and password while using https | |
git config credential.helper store | |
------------------------------------------------------------------------------- | |
reset a Git branch to a remote repository | |
git commit -a -m "Backup." | |
git branch my-backup | |
git fetch origin | |
git reset --hard origin/master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment