()
31 | private lateinit var jsonFileObject: JSONObject
32 | private var usage = ""
33 | private var note = ""
34 |
35 | @SuppressLint("ClickableViewAccessibility")
36 | override fun onCreate(savedInstanceState: Bundle?) {
37 | super.onCreate(savedInstanceState)
38 | dataBind = DataBindingUtil.setContentView(this, R.layout.activity_main)
39 | dataBind.textGitCommand.text =
40 | Html.fromHtml(resources.getString(R.string.git_command_explorer))
41 | jsonFileObject = JSONObject(loadJSONFromAsset())
42 | getPrimaryOptions()
43 | dataBind.inputFirstField.setOnTouchListener { p0, p1 ->
44 | dataBind.inputFirstField.showDropDown()
45 | false
46 | }
47 | dataBind.inputSecondField.setOnTouchListener { p0, p1 ->
48 | dataBind.inputSecondField.showDropDown()
49 | false
50 | }
51 | dataBind.inputFirstField.setOnItemClickListener { adapterView, view, pos, l ->
52 | primaryOptionsValue = primaryOptions.find {
53 | it.label == dataBind.inputFirstField.text.toString()
54 | }?.value!!
55 | dismissKeyboard(dataBind.inputFirstField)
56 | dataBind.cardViewSecondField.visibility = View.VISIBLE
57 | dataBind.textNote.visibility = View.GONE
58 | dataBind.cardViewNote.visibility = View.GONE
59 | dataBind.inputSecondField.text.clear()
60 | dataBind.textDisplayGitCommand.text = ""
61 | dataBind.textDisplayNote.text = ""
62 | getSecondaryOptions()
63 | }
64 | dataBind.inputSecondField.setOnItemClickListener { adapterView, view, i, l ->
65 | dismissKeyboard(dataBind.inputFirstField)
66 | usage = secondaryOptions.find {
67 | it.label == dataBind.inputSecondField.text.toString()
68 | }?.usage!!
69 | note = secondaryOptions.find {
70 | it.label == dataBind.inputSecondField.text.toString()
71 | }?.nb!!
72 | dataBind.textNote.visibility = if (note == "") View.GONE else View.VISIBLE
73 | dataBind.cardViewNote.visibility = if (note == "") View.GONE else View.VISIBLE
74 | dataBind.textDisplayGitCommand.text = usage
75 | dataBind.textDisplayNote.text = note
76 |
77 | }
78 | }
79 |
80 |
81 | private fun getPrimaryOptions() {
82 | val jsonPrimaryOptionsArray = jsonFileObject.getJSONArray(PRIMARY_OPTIONS)
83 | for (i in 0 until jsonPrimaryOptionsArray.length()) {
84 | val jsonObject = jsonPrimaryOptionsArray.getJSONObject(i)
85 | val primary = PrimaryOptions()
86 | primary.value = jsonObject.getString(VALUE)
87 | primary.label = jsonObject.getString(LABEL)
88 | primaryOptions.add(primary)
89 | }
90 | val adapter = ArrayAdapter(
91 | this,
92 | android.R.layout.simple_list_item_1, primaryOptions.map {
93 | it.label
94 | }
95 | )
96 | dataBind.inputFirstField.setAdapter(adapter)
97 | }
98 |
99 | private fun getSecondaryOptions() {
100 | secondaryOptions.clear()
101 | val jsonSecondaryOptionsObject = jsonFileObject.getJSONObject(SECONDARY_OPTIONS)
102 | val jsonArray = jsonSecondaryOptionsObject.getJSONArray(primaryOptionsValue)
103 | for (i in 0 until jsonArray.length()) {
104 | val jsonObject = jsonArray.getJSONObject(i)
105 | val secondary = SecondaryOptions()
106 | secondary.value = jsonObject.getString(VALUE)
107 | secondary.label = jsonObject.getString(LABEL)
108 | if (jsonObject.has("usage"))
109 | secondary.usage = jsonObject.getString(USAGE)
110 | if (jsonObject.has("nb"))
111 | secondary.nb = jsonObject.getString(NB)
112 | secondaryOptions.add(secondary)
113 | }
114 | val adapter = ArrayAdapter(
115 | this,
116 | android.R.layout.simple_list_item_1, secondaryOptions.map {
117 | it.label
118 | }
119 | )
120 | dataBind.inputSecondField.setAdapter(adapter)
121 | }
122 |
123 | private fun Context.dismissKeyboard(view: View?) {
124 | view?.let {
125 | val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
126 | imm.hideSoftInputFromWindow(it.windowToken, 0)
127 | }
128 | }
129 |
130 | private fun loadJSONFromAsset(): String {
131 | return assets.open(FILENAME).bufferedReader().use {
132 | it.readText()
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Git Explorer
2 |
3 | 
4 | 
5 | 
6 | 
7 | 
8 |
9 |     [](Shashank02051997/GitExplorer-Android)
10 |
11 | [](LICENSE)
12 | [](https://www.android.com)
13 | [](https://android-arsenal.com/api?level=23)
14 |
15 |
16 |
17 |
18 | **Git Explorer** is a simple android application to search git command on one click. Dedicated to all Software Developers with ❤️.
19 |
20 | ***You can Install and test latest app from below 👇***
21 |
22 | [](https://github.com/Shashank02051997/GitExplorer-Android/tree/master/apk)
23 |
24 | ## About
25 | The app in itself is a simple git commands searching app. Selecting command from the dropdown list gives you the usage and short description of that command.
26 |
27 |
28 | ## Sailent Features:
29 | - Search the git commands.
30 | - View the usage of the git command.
31 | - View the short description of that git command.
32 |
33 | ## 📸 Screenshots
34 |
35 | **Please click the image below to enlarge.**
36 |
37 | 
38 |
39 | 
40 |
41 | ## Prerequisites 📝
42 | - IntelliJ IDEA (any edition) or Android Studio(IDE) to run this project
43 |
44 | ## Inspiration
45 |
46 | This project is inspired from GitExplorer ~ Thanks to them.
47 |
48 | [GitExplorer](https://github.com/summitech/gitexplorer)
49 |
50 | ## Contributing
51 |
52 | Please fork this repository and contribute back using
53 | [pull requests](https://github.com/Shashank02051997/GitExplorer-Android/pulls).
54 |
55 | Any contributions, large or small, major features, bug fixes, are welcomed and appreciated
56 | but will be thoroughly reviewed .
57 |
58 | ### Contact - Let's become friend
59 | - [Twitter](https://twitter.com/shashank020597)
60 | - [Github](https://github.com/Shashank02051997)
61 | - [Linkedin](https://www.linkedin.com/in/shashank-singhal-a87729b5/)
62 | - [Facebook](https://www.facebook.com/shashanksinghal02)
63 |
64 |
65 | Don't forget to star ⭐ the repo it motivates me to share more open source
66 |
67 |
68 | ## Donation
69 | If this project help you reduce time to develop, you can give me a cup of coffee :)
70 |
71 |
72 |
73 | ## 💬 Discuss
74 |
75 | Have any questions, doubts or want to present your opinions, views? You're always welcome. You can [start discussions](https://github.com/Shashank02051997/GitExplorer-Android/discussions).
76 |
77 | ## License
78 |
79 | ```
80 | MIT License
81 |
82 | Copyright (c) 2023 Shashank Singhal
83 |
84 | Permission is hereby granted, free of charge, to any person obtaining a copy
85 | of this software and associated documentation files (the "Software"), to deal
86 | in the Software without restriction, including without limitation the rights
87 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
88 | copies of the Software, and to permit persons to whom the Software is
89 | furnished to do so, subject to the following conditions:
90 |
91 | The above copyright notice and this permission notice shall be included in all
92 | copies or substantial portions of the Software.
93 |
94 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
95 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
96 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
97 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
98 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
99 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
100 | SOFTWARE.
101 |
102 | ```
103 |
104 |
105 | ## Visitors Count
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Use "xargs" to parse quoted args.
209 | #
210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211 | #
212 | # In Bash we could simply go:
213 | #
214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215 | # set -- "${ARGS[@]}" "$@"
216 | #
217 | # but POSIX shell has neither arrays nor command substitution, so instead we
218 | # post-process each arg (as a line of input to sed) to backslash-escape any
219 | # character that might be a shell metacharacter, then use eval to reverse
220 | # that process (while maintaining the separation between arguments), and wrap
221 | # the whole thing up as a single "set" statement.
222 | #
223 | # This will of course break if any of these variables contains a newline or
224 | # an unmatched quote.
225 | #
226 |
227 | eval "set -- $(
228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229 | xargs -n1 |
230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231 | tr '\n' ' '
232 | )" '"$@"'
233 |
234 | exec "$JAVACMD" "$@"
235 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
9 |
10 |
15 |
16 |
27 |
28 |
41 |
42 |
54 |
55 |
65 |
66 |
82 |
83 |
84 |
85 |
96 |
97 |
113 |
114 |
115 |
116 |
128 |
129 |
140 |
141 |
145 |
146 |
151 |
152 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
184 |
185 |
197 |
198 |
202 |
203 |
208 |
209 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
--------------------------------------------------------------------------------
/app/src/main/assets/git_command_explorer.json:
--------------------------------------------------------------------------------
1 | {
2 | "primary_options": [
3 | {
4 | "value": "add",
5 | "label": "add"
6 | },
7 | {
8 | "value": "commit",
9 | "label": "commit"
10 | },
11 | {
12 | "value": "revert",
13 | "label": "revert/reset"
14 | },
15 | {
16 | "value": "initialize",
17 | "label": "initialize"
18 | },
19 | {
20 | "value": "modify",
21 | "label": "modify"
22 | },
23 | {
24 | "value": "show",
25 | "label": "show/view"
26 | },
27 | {
28 | "value": "delete",
29 | "label": "delete/remove"
30 | },
31 | {
32 | "value": "compareCommits",
33 | "label": "compare two commits"
34 | },
35 | {
36 | "value": "configure",
37 | "label": "configure"
38 | },
39 | {
40 | "value": "clone",
41 | "label": "clone"
42 | },
43 | {
44 | "value": "ignore",
45 | "label": "ignore"
46 | },
47 | {
48 | "value": "rename",
49 | "label": "rename"
50 | },
51 | {
52 | "value": "merge",
53 | "label": "merge"
54 | },
55 | {
56 | "value": "squash",
57 | "label": "squash"
58 | },
59 | {
60 | "value": "stash",
61 | "label": "stash"
62 | },
63 | {
64 | "value": "debug",
65 | "label": "debug"
66 | },
67 | {
68 | "value": "recover",
69 | "label": "recover"
70 | },
71 | {
72 | "value": "synchronize",
73 | "label": "synchronize"
74 | },
75 | {
76 | "value": "rebase",
77 | "label": "rebase"
78 | }
79 | ],
80 | "secondary_options": {
81 | "commit": [
82 | {
83 | "value": "local-changes",
84 | "label": "commit all local changes in tracked files",
85 | "usage": "git commit -a"
86 | },
87 | {
88 | "value": "staged-changes",
89 | "label": "commit all staged changes",
90 | "usage": "git commit -m ",
91 | "nb": "Replace with your commit message."
92 | }
93 | ],
94 | "configure": [
95 | {
96 | "value": "email-name",
97 | "label": "name and email address",
98 | "usage": "git config --global user.name \"username\" \n\ngit config --global user.email \"email address\"",
99 | "nb": "Your username and email address should be the same as the one used with your git hosting provider i.e. github, bitbucket, gitlab etc"
100 | },
101 | {
102 | "value": "editor",
103 | "label": "default editor",
104 | "usage": "git config --global core.editor \"vim\"",
105 | "nb": "Change default editor to vim."
106 | },
107 | {
108 | "value": "diff-tool",
109 | "label": "external diff tool",
110 | "usage": "git config --global diff.external \"meld\"",
111 | "nb": "Set external diff tool to meld."
112 | },
113 | {
114 | "value": "merge-tool",
115 | "label": "default merge tool",
116 | "usage": "git config --global merge.tool \"meld\"",
117 | "nb": "Set default merge tool to meld."
118 | },
119 | {
120 | "value": "color",
121 | "label": "color",
122 | "usage": "git config --global color.ui auto",
123 | "nb": "Enables helpful colorization of command line output"
124 | },
125 | {
126 | "value": "signingkey",
127 | "label": "add the GPG key",
128 | "usage": "git config --global user.signingkey ",
129 | "nb": "Git is cryptographically secure, but it’s not foolproof. If you’re taking work from others on the internet and want to verify that commits are actually from a trusted source, Git has a few ways to sign and verify work using GPG."
130 | }
131 | ],
132 | "revert": [
133 | {
134 | "value": "specific-commit",
135 | "label": "a specific commit",
136 | "usage": "git revert ",
137 | "nb": "Use git log to see the hash of each commit"
138 | },
139 | {
140 | "value": "to-last-commit",
141 | "label": "to last commit",
142 | "usage": "git reset --hard"
143 | },
144 | {
145 | "value": "to-last-commit-from-remote",
146 | "label": "to last commit on remote branch",
147 | "usage": "git reset --hard /"
148 | }
149 | ],
150 | "initialize": [
151 | {
152 | "value": "new-repo",
153 | "label": "a new repository",
154 | "nb": "Make sure you are in the right directory",
155 | "usage": "git init"
156 | }
157 | ],
158 | "modify": [
159 | {
160 | "value": "commit-message",
161 | "label": "my last/latest commit message",
162 | "usage": "git commit --amend"
163 | },
164 | {
165 | "value": "commit",
166 | "label": "my last commit but leave the commit message as is",
167 | "usage": "git add . \ngit commit --amend --no-edit"
168 | },
169 | {
170 | "value": "remoteUrl",
171 | "label": "repo's remote url",
172 | "usage": "git remote set-url ",
173 | "nb": " is your remote name e.g origin"
174 | }
175 | ],
176 | "show": [
177 | {
178 | "value": "repo-status",
179 | "label": "status of project including staged, unstaged and untracked files",
180 | "usage": "git status"
181 | },
182 | {
183 | "value": "logs",
184 | "label": "commit logs/history"
185 | },
186 | {
187 | "value": "uncommittedChanges",
188 | "label": "uncommitted changes",
189 | "usage": "git diff"
190 | },
191 | {
192 | "value": "committedChanges",
193 | "label": "committed/staged changes",
194 | "usage": "git diff --staged"
195 | },
196 | {
197 | "value": "remoteUrl",
198 | "label": "repo's remote url",
199 | "usage": "git remote -v"
200 | },
201 | {
202 | "value": "stash",
203 | "label": "stash",
204 | "usage": "git stash list"
205 | },
206 | {
207 | "value": "branch",
208 | "label": "branches",
209 | "usage": "git branch",
210 | "nb": "The active branch is prefixed with *"
211 | },
212 | {
213 | "value": "tags",
214 | "label": "tags",
215 | "usage": "git tag"
216 | }
217 | ],
218 | "delete": [
219 | {
220 | "value": "branch",
221 | "label": "a branch",
222 | "usage": "git branch -D "
223 | },
224 | {
225 | "value": "delete-multiple-branches",
226 | "label": "multiple branches"
227 | },
228 | {
229 | "value": "tag",
230 | "label": "a tag",
231 | "usage": "git tag -d v"
232 | },
233 | {
234 | "value": "remote",
235 | "label": "remote",
236 | "usage": "git remote rm "
237 | },
238 | {
239 | "value": "untracked-files",
240 | "label": "untracked files",
241 | "usage": "git clean -",
242 | "nb": "replace - with:\n -i for interactive command\n -n to preview what will be removed\n -f to remove forcefully\n -d to remove directories\n -X to remove ignored files\n -x to remove ignored and non-ignored files"
243 | },
244 | {
245 | "value": "files-from-index",
246 | "label": "files from index",
247 | "usage": "git rm --cached ",
248 | "nb": "Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone."
249 | },
250 | {
251 | "value": "local-branches-not-on-remote",
252 | "label": "local branches that don't exist at remote",
253 | "usage": "git remote prune ",
254 | "nb": "Use the --dry-run option to report what branches will be pruned, but do not actually prune them"
255 | },
256 | {
257 | "value": "files-from-old-commit",
258 | "label": "files from old commits",
259 | "usage": "git filter-branch --index-filter \n'git rm --cached --ignore-unmatch path/to/mylarge_file' \n--tag-name-filter cat -- --all\n\nfilter-branch keeps backups too, so the size of the repo won't decrease immediately unless you expire the reflogs and garbage collect:\n\nrm -Rf .git/refs/original # careful\ngit gc --aggressive --prune=now # danger",
260 | "nb": "Like the rebasing option described before, filter-branch is rewriting operation. If you have published history, you'll have to --force push the new refs."
261 | }
262 | ],
263 | "compareCommits": [
264 | {
265 | "value": "terminal",
266 | "label": "and output result in the terminal",
267 | "usage": "git diff | less",
268 | "nb": "sha1 and sha2 are the sha hash of the commits you want to compare."
269 | },
270 | {
271 | "value": "file",
272 | "label": "and output result to a file",
273 | "usage": "git diff > diff.txt",
274 | "nb": "sha1 and sha2 are the sha of the commits you want to compare. \n\ndiff.txt is the file you want to store the contents of the diff"
275 | }
276 | ],
277 | "clone": [
278 | {
279 | "value": "clone-repo-into-a-new-dir",
280 | "label": "existing repo into a new directory",
281 | "usage": "git clone ",
282 | "nb": "The repo is cloned into the specified directory\n\nReplace \"directory\" with the directory you want"
283 | },
284 | {
285 | "value": "clone-repo-into-a-current-dir",
286 | "label": "existing repo into the current directory",
287 | "usage": "git clone .",
288 | "nb": "The repo is cloned into the current directory\n\nThe current directory is represented with a \".\" (period)"
289 | },
290 | {
291 | "value": "clone-repo-with-submodule-into-a-current-dir",
292 | "label": "existing repo along with submodules into the current directory",
293 | "usage": "git clone --recurse-submodules .",
294 | "nb": "If git version is under 2.13, use --recursive option instead."
295 | },
296 | {
297 | "value": "clone-submodule-after",
298 | "label": "submodules after cloning existing repo",
299 | "usage": "git submodule update --init --recursive"
300 | }
301 | ],
302 | "ignore": [
303 | {
304 | "value": "ignore-files-in-a-dir",
305 | "label": "all files in a directory",
306 | "usage": "/*",
307 | "nb": "This must be added to .gitignore file\n\nReplace \"dir name\" with name of directory whose files you want git to ignore"
308 | },
309 | {
310 | "value": "ignore-all-files-of-a-specific-type",
311 | "label": "all files of a specific type",
312 | "usage": "*.",
313 | "nb": "This must be added to .gitignore file\n\nReplace \"filename extension\" with the extension of the files you want git to ignore\n\nFor example *.py tells git to ignore all python files in the repository"
314 | }
315 | ],
316 | "help": [
317 | {
318 | "value": "command-help",
319 | "label": "about a command",
320 | "usage": "append --help to the command",
321 | "nb": "e.g. git merge --help\n\nType q to quite terminal"
322 | }
323 | ],
324 | "add": [
325 | {
326 | "value": "new-changes",
327 | "label": "new changes",
328 | "usage": "git add ",
329 | "nb": "To add all the files in the current directory, use \"git add .\"\n\nTo add a directory use \"git add \""
330 | },
331 | {
332 | "value": "add-new-branch",
333 | "label": "a new branch",
334 | "usage": "git branch "
335 | },
336 | {
337 | "value": "add-repo",
338 | "label": "new remote repo",
339 | "usage": "git remote add "
340 | },
341 | {
342 | "value": "add-alias",
343 | "label": "alias",
344 | "usage": "git config --global alias. ",
345 | "nb": "e.g. git config --global alias.st status. Typing git st in the terminal now does the same thing as git status"
346 | },
347 | {
348 | "value": "add-annotated-tag",
349 | "label": "annotated tag",
350 | "usage": "git tag -a v1.4 -m \"my version 1.4\"\n\ngit push --tags"
351 | },
352 | {
353 | "value": "add-annotated-tag-for-old-commit",
354 | "label": "annotated tag for old commit",
355 | "usage": "git tag -a v1.2 -m 'version 1.2' \n\ngit push --tags"
356 | }
357 | ],
358 | "push": [
359 | {
360 | "value": "new-remote-branch",
361 | "label": "non-existent remote branch",
362 | "usage": "git push -u origin "
363 | }
364 | ],
365 | "rename": [
366 | {
367 | "value": "branch",
368 | "label": "branch"
369 | },
370 | {
371 | "value": "file",
372 | "label": "file",
373 | "usage": "git mv file_from file_to"
374 | },
375 | {
376 | "value": "remoteUrl",
377 | "label": "remote",
378 | "usage": "git remote rename "
379 | }
380 | ],
381 | "merge": [
382 | {
383 | "value": "branch",
384 | "label": "another branch to current branch",
385 | "usage": "git merge "
386 | },
387 | {
388 | "value": "single-file",
389 | "label": "merge a single file from one branch to another.",
390 | "usage": "git checkout --patch"
391 | }
392 | ],
393 | "squash": [
394 | {
395 | "value": "pr",
396 | "label": "commits in pull request into single commit",
397 | "usage": "git rebase -i ",
398 | "nb": "Make sure that latest commits are fetched from upstream.\n\nFor example (assuming you have a remote named upstream):\n\ngit fetch upstream\ngit rebase -i upstream/master\n\nChange \"pick\" to \"squash\" for the commits you wish to squash and save.\n\ngit push origin --force-with-lease"
399 | },
400 | {
401 | "value": "commits",
402 | "label": "last n number of commit into one",
403 | "usage": "git reset --soft HEAD~N\ngit add .\ngit commit -m ",
404 | "nb": "Replace N with the number of commits you want to squash and with your commit message. You can use the command \"git log\" to view your commit history"
405 | }
406 | ],
407 | "debug": [
408 | {
409 | "value": "bisect",
410 | "label": "binary search",
411 | "usage": "git bisect start\ngit bisect bad # Current version is bad\ngit bisect good v2.13 # v6.12 is known to be good",
412 | "nb": "Once you have specified at least one bad and one good commit, git bisect selects a commit in the middle of that range of history, checks it out, and outputs something similar to the following:\nBisecting: 675 revisions left to test after this (roughly 10 steps)\nYou should now compile the checked-out version and test it. If that version works correctly, type\n\ngit bisect good\n\nIf that version is broken, type\n\ngit bisect bad\n\nThen git bisect will respond with something like\n\nBisecting: 337 revisions left to test after this (roughly 9 steps)\n\nKeep repeating the process: compile the tree, test it, and depending on whether it is good or bad run git bisect good or git bisect bad to ask for the next commit that needs testing.\nEventually there will be no more revisions left to inspect, and the command will print out a description of the first bad commit. The reference refs/bisect/bad will be left pointing at that commit.\nAfter a bisect session, to clean up the bisection state and return to the original HEAD, issue the following command:\n\ngit bisect reset"
413 | },
414 | {
415 | "value": "blame",
416 | "label": "who modified each lines",
417 | "usage": "git blame -L , ",
418 | "nb": "The -L option will restrict the output to the requested line range\n"
419 | },
420 | {
421 | "value": "grep",
422 | "label": "search in files",
423 | "usage": "git grep -n ",
424 | "nb": "Print lines matching a pattern.\nOption -n to display the numbering of lines in which there are matches"
425 | }
426 | ],
427 | "recover": [
428 | {
429 | "value": "dropped-commit",
430 | "label": "show hashes dangling commits after hard reset to previous commit",
431 | "usage": "git reflog",
432 | "nb": "alternative: git log -g. For recovery use\ngit checkout -b "
433 | },
434 | {
435 | "value": "deleted-branch",
436 | "label": "show hashes removed branch or other git objects",
437 | "usage": "git fsck --full",
438 | "nb": "show hashes all dangling git objects. For recovery use\ngit checkout -b "
439 | }
440 | ],
441 | "rebase": [
442 | {
443 | "value": "origin-branch",
444 | "label": "an origin branch into my working branch",
445 | "usage": "git pull --rebase origin ",
446 | "nb": "Rebase an origin branch into working branch. Replace with the branch you are pulling"
447 | },
448 | {
449 | "value": "local-branch",
450 | "label": "a local branch into my working branch",
451 | "usage": "git pull --rebase ",
452 | "nb": "Rebase another local branch into working branch. Replace with the branch you are pulling"
453 | },
454 | {
455 | "value": "skip",
456 | "label": "and skip a commit",
457 | "usage": "git rebase --skip",
458 | "nb": "During rebase, git might not be able to automatically apply commits due to conflicts. You can use this command to discard of your own changes in the current commit and apply the changes from an incoming branch"
459 | },
460 | {
461 | "value": "continue",
462 | "label": "and continue after resolving conflicts",
463 | "usage": "git rebase --continue",
464 | "nb": "During rebase, git might not be able to automatically apply commits due to conflicts. You can resolve this conflicts manually and use this command to continue your rebase operation"
465 | }
466 | ],
467 | "synchronize": [
468 | {
469 | "value": "branch-from-fork",
470 | "label": "a branch in a fork",
471 | "usage": "git fetch \n\ngit checkout \n\ngit merge /",
472 | "nb": "You need to add a remote repo for your fork first."
473 | }
474 | ],
475 | "stash": [
476 | {
477 | "value": "save-stash",
478 | "label": "(un)tracked files",
479 | "usage": "git stash",
480 | "nb": "To stash with a customized message use git stash save \n\nTo stash untracked files git stash save -u"
481 | },
482 | {
483 | "value": "list-stash",
484 | "label": "view list of stashed changes",
485 | "usage": "git stash list"
486 | },
487 | {
488 | "value": "apply-stash",
489 | "label": "apply"
490 | },
491 | {
492 | "value": "show",
493 | "label": "view the contents of a stash",
494 | "usage": "git stash show -p ",
495 | "nb": "You can leave out the stash id if you want the contents of the latest stash"
496 | },
497 | {
498 | "value": "delete-stash",
499 | "label": "delete"
500 | },
501 | {
502 | "value": "create-branch",
503 | "label": "create a new branch and apply stash",
504 | "usage": "git stash branch "
505 | }
506 | ]
507 | }
508 | }
--------------------------------------------------------------------------------