diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..e96f702 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at hemanth.hm@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/README.md b/README.md index 0e69629..757ef31 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ## git-tips > Collection of `git-tips`, want to add your tips? Checkout [contributing.md](./contributing.md) -[English](http://git.io/git-tips) | [中文](https://github.com/521xueweihan/git-tips) | [Русский](https://github.com/Imangazaliev/git-tips) | [한국어](https://github.com/mingrammer/git-tips) | [Tiếng Việt](https://github.com/hprobotic/git-tips) | [日本語](https://github.com/isotai/git-tips) | [नेपाली](https://github.com/amarduwal/git-tips) +[English](http://git.io/git-tips) | [中文](https://github.com/521xueweihan/git-tips) | [Русский](https://github.com/Imangazaliev/git-tips) | [한국어](https://github.com/mingrammer/git-tips) | [Tiếng Việt](https://github.com/hprobotic/git-tips) | [日本語](https://github.com/isotai/git-tips) | [नेपाली](https://github.com/amarduwal/git-tips) | [Polski](https://github.com/mbiesiad/tips) | [فارسی](https://github.com/javadnikbakht/git-tips) ### __Tools:__ @@ -32,6 +32,7 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`. * [Track upstream branch](#track-upstream-branch) * [Delete local branch](#delete-local-branch) * [Delete remote branch](#delete-remote-branch) +* [Create local tag](#create-local-tag) * [Delete local tag](#delete-local-tag) * [Delete remote tag](#delete-remote-tag) * [Undo local changes with the last content in head](#undo-local-changes-with-the-last-content-in-head) @@ -58,6 +59,7 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`. * [Saving current state with message](#saving-current-state-with-message) * [Saving current state of all files (ignored, untracked, and tracked)](#saving-current-state-of-all-files-ignored-untracked-and-tracked) * [Show list of all saved stashes](#show-list-of-all-saved-stashes) +* [Show the contents of any stash in patch form](#show-the-contents-of-any-stash-in-patch-form) * [Apply any stash without deleting from the stashed list](#apply-any-stash-without-deleting-from-the-stashed-list) * [Apply last stashed state and delete it from stashed list](#apply-last-stashed-state-and-delete-it-from-stashed-list) * [Delete all stored stashes](#delete-all-stored-stashes) @@ -77,7 +79,8 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`. * [Rebases 'feature' to 'master' and merges it in to master ](#rebases-feature-to-master-and-merges-it-in-to-master) * [Archive the `master` branch](#archive-the-master-branch) * [Modify previous commit without modifying the commit message](#modify-previous-commit-without-modifying-the-commit-message) -* [Prunes references to remote branches that have been deleted in the remote.](#prunes-references-to-remote-branches-that-have-been-deleted-in-the-remote) +* [Prunes references to remove branches that have been deleted in the remote.](#prunes-references-to-remove-branches-that-have-been-deleted-in-the-remote) +* [Delete local branches that has been squash and merged in the remote.](#delete-local-branches-that-has-been-squash-and-merged-in-the-remote) * [Retrieve the commit hash of the initial revision.](#retrieve-the-commit-hash-of-the-initial-revision) * [Visualize the version tree.](#visualize-the-version-tree) * [Visualize the tree including commits that are only referenced from reflogs](#visualize-the-tree-including-commits-that-are-only-referenced-from-reflogs) @@ -169,6 +172,7 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`. * [List all git aliases](#list-all-git-aliases) * [Show git status short](#show-git-status-short) * [Checkout a commit prior to a day ago](#checkout-a-commit-prior-to-a-day-ago) +* [Push the current branch to the same name on the remote repository](#push-the-current-branch-to-the-same-name-on-the-remote-repository) * [Push a new local branch to remote repository and track](#push-a-new-local-branch-to-remote-repository-and-track) * [Change a branch base](#change-a-branch-base) * [Use SSH instead of HTTPs for remotes](#use-ssh-instead-of-https-for-remotes) @@ -315,6 +319,11 @@ git push origin : git branch -dr ``` +## Create local tag +```sh +git tag +``` + ## Delete local tag ```sh git tag -d @@ -325,7 +334,7 @@ git tag -d git push origin :refs/tags/ ``` -## Undo local changes with the last content in head +## Undo local changes with the content in index(staging) ```sh git checkout -- ``` @@ -442,7 +451,7 @@ git stash __Alternatives:__ ```sh -git stash save +git stash push ``` ## Saving current state of unstaged changes to tracked files @@ -458,7 +467,7 @@ git stash --keep-index ```sh -git stash save --keep-index +git stash push --keep-index ``` ## Saving current state including untracked files @@ -469,17 +478,23 @@ git stash -u __Alternatives:__ ```sh -git stash save -u +git stash push -u ``` ```sh -git stash save --include-untracked +git stash push --include-untracked ``` ## Saving current state with message ```sh -git stash save +git stash push -m +``` + + +__Alternatives:__ +```sh +git stash push --message ``` ## Saving current state of all files (ignored, untracked, and tracked) @@ -495,7 +510,7 @@ git stash --all ```sh -git stash save --all +git stash push --all ``` ## Show list of all saved stashes @@ -503,6 +518,11 @@ git stash save --all git stash list ``` +## Show the contents of any stash in patch form +```sh +git stash show -p +``` + ## Apply any stash without deleting from the stashed list ```sh git stash apply @@ -645,7 +665,7 @@ git archive master --format=zip --output=master.zip git add --all && git commit --amend --no-edit ``` -## Prunes references to remote branches that have been deleted in the remote. +## Prunes references to remove branches that have been deleted in the remote. ```sh git fetch -p ``` @@ -656,6 +676,11 @@ __Alternatives:__ git remote prune origin ``` +## Delete local branches that has been squash and merged in the remote. +```sh +git branch -vv | grep ': gone]' | awk '{print }' | xargs git branch -D +``` + ## Retrieve the commit hash of the initial revision. ```sh git rev-list --reverse HEAD | head -1 @@ -781,7 +806,7 @@ git clean -X -f ## Restore deleted file. ```sh -git checkout ^ -- +git checkout -- ``` ## Restore file to a specific commit-hash @@ -974,6 +999,10 @@ __Alternatives:__ git branch && git checkout ``` +```sh +git switch -c +``` + ## Ignore file mode changes on commits ```sh git config core.fileMode false @@ -1201,6 +1230,11 @@ git status --short --branch git checkout master@{yesterday} ``` +## Push the current branch to the same name on the remote repository +```sh +git push origin HEAD +``` + ## Push a new local branch to remote repository and track ```sh git push -u origin diff --git a/package-lock.json b/package-lock.json index 2ca1e1c..ec93f7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -215,9 +215,9 @@ } }, "husky": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/husky/-/husky-0.8.1.tgz", - "integrity": "sha1-7MeXuMTGiToz9IcDvJeppeUNhg8=", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/husky/-/husky-5.2.0.tgz", + "integrity": "sha512-AM8T/auHXRBxlrfPVLKP6jt49GCM2Zz47m8G3FOMsLmTv8Dj/fKVWE0Rh2d4Qrvmy131xEsdQnb3OXRib67PGg==", "dev": true }, "keypather": { diff --git a/package.json b/package.json index 6d1b215..75efa09 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,6 @@ "doxie.inject": "^0.1.1", "doxie.output": "^0.3.0", "doxie.render": "^0.3.0", - "husky": "^0.8.1" + "husky": "^5.0.9" } } diff --git a/tips.json b/tips.json index 3400539..7cf20b2 100644 --- a/tips.json +++ b/tips.json @@ -65,6 +65,9 @@ "title": "Delete remote branch", "tip": "git push origin --delete ", "alternatives": ["git push origin :", "git branch -dr "] + }, { + "title": "Create local tag", + "tip": "git tag " }, { "title": "Delete local tag", "tip": "git tag -d " @@ -72,7 +75,7 @@ "title": "Delete remote tag", "tip": "git push origin :refs/tags/" }, { - "title": "Undo local changes with the last content in head", + "title": "Undo local changes with the content in index(staging)", "tip": "git checkout -- " }, { "title": "Revert: Undo a commit by creating a new commit", @@ -129,28 +132,32 @@ "title": "Git Aliases", "tip": "git config --global alias. \ngit config --global alias.st status" }, { - "title": "Saving current state of tracked files without commiting", + "title": "Saving current state of tracked files without committing", "tip": "git stash", - "alternatives": ["git stash save"] + "alternatives": ["git stash push"] }, { "title": "Saving current state of unstaged changes to tracked files", "tip": "git stash -k", - "alternatives": ["git stash --keep-index", "git stash save --keep-index"] + "alternatives": ["git stash --keep-index", "git stash push --keep-index"] }, { "title": "Saving current state including untracked files", "tip": "git stash -u", - "alternatives": ["git stash save -u", "git stash save --include-untracked"] + "alternatives": ["git stash push -u", "git stash push --include-untracked"] }, { "title": "Saving current state with message", - "tip": "git stash save " + "tip": "git stash push -m ", + "alternatives": ["git stash push --message "] }, { "title": "Saving current state of all files (ignored, untracked, and tracked)", "tip": "git stash -a", - "alternatives": ["git stash --all", "git stash save --all"] + "alternatives": ["git stash --all", "git stash push --all"] }, { "title": "Show list of all saved stashes", "tip": "git stash list" }, { + "title": "Show the contents of any stash in patch form", + "tip": "git stash show -p " + }, { "title": "Apply any stash without deleting from the stashed list", "tip": "git stash apply " }, { @@ -215,9 +222,12 @@ "title": "Modify previous commit without modifying the commit message", "tip": "git add --all && git commit --amend --no-edit" }, { - "title": "Prunes references to remote branches that have been deleted in the remote.", + "title": "Prunes references to remove branches that have been deleted in the remote.", "tip": "git fetch -p", "alternatives": ["git remote prune origin"] + }, { + "title": "Delete local branches that has been squash and merged in the remote.", + "tip": "git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D" }, { "title": "Retrieve the commit hash of the initial revision.", "tip": " git rev-list --reverse HEAD | head -1", @@ -278,7 +288,7 @@ "tip": "git clean -X -f" }, { "title": "Restore deleted file.", - "tip": "git checkout ^ -- " + "tip": "git checkout -- " }, { "title": "Restore file to a specific commit-hash", "tip": "git checkout -- " @@ -380,7 +390,7 @@ }, { "title": "Create and switch new branch", "tip": "git checkout -b ", - "alternatives": ["git branch && git checkout "] + "alternatives": ["git branch && git checkout ", "git switch -c "] }, { "title": "Ignore file mode changes on commits", "tip": "git config core.fileMode false" @@ -504,6 +514,9 @@ "title": "Checkout a commit prior to a day ago", "tip": "git checkout master@{yesterday}" }, { + "title": "Push the current branch to the same name on the remote repository", + "tip": "git push origin HEAD" + }, { "title": "Push a new local branch to remote repository and track", "tip": "git push -u origin " }, {