Git: Difference between revisions
Jump to navigation
Jump to search
Line 138: | Line 138: | ||
==References== | ==References== | ||
{| | {| | ||
| | |- | ||
| | |||
* [[Execute bash script from URL]] | * [[Execute bash script from URL]] | ||
* [[Bash/SQLPlus/Input/Redirect|Bash/SQLPlus Input Redirect]] | * [[Bash/SQLPlus/Input/Redirect|Bash/SQLPlus Input Redirect]] | ||
Line 150: | Line 151: | ||
* [[Bash/Port]] | * [[Bash/Port]] | ||
| | |||
* [[Develop GitHub Pages Site Locally by Jekyll]] | * [[Develop GitHub Pages Site Locally by Jekyll]] | ||
* [https://stackoverflow.com/questions/21676150/ Setup Git Bash in Intellij Terminal] | * [https://stackoverflow.com/questions/21676150/ Setup Git Bash in Intellij Terminal] | ||
Line 162: | Line 163: | ||
* [[GitLab]] | * [[GitLab]] | ||
| | |||
* [https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks Git Hooks To Automate Development and Deployment] | * [https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks Git Hooks To Automate Development and Deployment] | ||
* [https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa Automated Git Deployment using Git Hooks] | * [https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa Automated Git Deployment using Git Hooks] | ||
Line 173: | Line 174: | ||
* [https://git-scm.com/book/en/v2/Distributed-Git-Maintaining-a-Project Git Maintaining a Project] | * [https://git-scm.com/book/en/v2/Distributed-Git-Maintaining-a-Project Git Maintaining a Project] | ||
* [https://stackoverflow.com/questions/21414725/ Git tags sort order] | * [https://stackoverflow.com/questions/21414725/ Git tags sort order] | ||
|- | |||
| | |||
* [https://stackoverflow.com/questions/6372044/ Git merge a specific commit from one branch into another] | |||
| | |||
| | |||
|} | |} |
Revision as of 09:01, 14 September 2021
git config --global user.name "Full Name" git config --global user.email "[email protected]" undo or redo assume unchanged git update-index --no-assume-unchanged src/main/resources/application.properties git update-index --assume-unchanged src/main/resources/application.properties list of assume unchanged files git ls-files -v|grep '^h'
Git Ignore
out/ *.iml *.ipr *.iws .idea/* cmake-build-*/ .idea_modules/ fabric.properties crashlytics.properties atlassian-ide-plugin.xml crashlytics-build.properties com_crashlytics_export_strings.xml
clear metadata rm -rf */out */*.iml */*.ipr */*.iws */.idea */cmake-build-* */.idea_modules
Git Stash
git stash apply stash@{index} git stash drop stash@{index} git stash pop stash@{index} git stash clear git stash list |
git apply --3way ~/.chorke/tmp/academia/patch/v1.0.00.patch git apply ~/.chorke/tmp/academia/patch/v1.0.00.patch git diff > ~/.chorke/tmp/academia/patch/v1.0.00.patch git stash apply stash^{/stash_v1.0.00} git stash push -m stash_v1.0.00 |
Git Tag
annotated tag git tag -a v1.5_initial_setup -m 'initial setup' git tag -a v1.5_initial_setup
lightweight tag git tag v1.5_initial_setup
By default git sort order is ascending, for descending order we need to add -
sign before the value of --sort
parameter
git tag --sort=taggerdate
git tag -l --sort=taggerdate
git tag -l --format='%(taggerdate) %(refname)'
git tag -l --format='%(taggerdate) %(refname)' --sort=taggerdate
# ascending order
git tag -l --format='%(taggerdate)%09%(refname)' --sort=taggerdate
git tag -l --format='%(creatordate)%09%(refname)' --sort=creatordate
# descending order
git tag -l --format='%(taggerdate)%09%(refname)' --sort=-taggerdate
git tag -l --format='%(creatordate)%09%(refname)' --sort=-creatordate
git tag --format='%(creatordate:short)%09%(refname:strip=2)'
git tag --format='%(creatordate:short)%09%(refname:strip=2)' --sort=creatordate
git tag --format='%(taggerdate:short)%09%(refname:strip=2)'
git tag --format='%(taggerdate:short)%09%(refname:strip=2)' --sort=taggerdate
git log --tags --simplify-by-decoration --pretty='format:%ai %d'
git log --tags --simplify-by-decoration --pretty='format:%ai %h %d' --date-order --graph
Git Branch
create and checkout a new branch git checkout -b new_branch_name base_branch_name git checkout -b new_branch_name
renaming and delete branch git branch -m old_branch_name new_branch_name git branch -D branch_to_delete_without_merge_status git branch -d branch_to_delete git push -d origin branch_to_delete git push origin --delete branch_to_delete
Git Commit
delete latest commit git reset --hard HEAD~1 rollback to the commit id git reset --hard <sha1-commit-id> delete commit from remote branch git push origin HEAD --force
Git Warning
Pulling without specifying how to reconcile divergent branches is discouraged. You can squelch this message by running one of the following commands sometime before your next pull:
git config pull.rebase false # merge (the default strategy)
git config pull.rebase true # rebase
git config pull.ff only # fast-forward only
Knowledge
discard changes git checkout master -f
delete and recreate git branch -d staging git branch -D staging
git merge develop git fetch origin staging git checkout -b staging origin/staging git stashing git stash; git checkout -b new_branch; git stash pop git add .; git commit -m "new feature added"; git push
git remote -v;mv src/main/resources/application.properties ..;cd .. mv ../application.properties src/main/resources/ rebase vs merge git rebase master #all the updated commits of master will be available in the feature branch git merge --squash feature #all the feature commits replaced by a new commit in the master git commit -m 'feature merged with master branch'