Skip to content

Commit 135bd3c

Browse files
authored
Merge pull request #174 from angelskieglazki/feature/update-submodule-to-latest-commit
tips.json: submodule to latest commit
2 parents a6e02cc + ebde7ca commit 135bd3c

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`.
1414
* [Everyday Git in twenty commands or so](#everyday-git-in-twenty-commands-or-so)
1515
* [Show helpful guides that come with Git](#show-helpful-guides-that-come-with-git)
1616
* [Search change by content](#search-change-by-content)
17+
* [Show changes over time for specific file](#show-changes-over-time-for-specific-file)
1718
* [Remove sensitive data from history, after a push](#remove-sensitive-data-from-history-after-a-push)
1819
* [Sync with remote, overwrite local changes](#sync-with-remote-overwrite-local-changes)
1920
* [List of all files till a commit](#list-of-all-files-till-a-commit)
2021
* [Git reset first commit](#git-reset-first-commit)
22+
* [Reset: preserve uncommitted local changes](#reset-preserve-uncommitted-local-changes)
2123
* [List all the conflicted files](#list-all-the-conflicted-files)
2224
* [List of all files changed in a commit](#list-of-all-files-changed-in-a-commit)
2325
* [Unstaged changes since last commit](#unstaged-changes-since-last-commit)
@@ -139,6 +141,7 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`.
139141
* [Unstaging Staged file](#unstaging-staged-file)
140142
* [Force push to Remote Repository](#force-push-to-remote-repository)
141143
* [Adding Remote name](#adding-remote-name)
144+
* [List all currently configured remotes](#list-all-currently-configured-remotes)
142145
* [Show the author, time and last revision made to each line of a given file](#show-the-author-time-and-last-revision-made-to-each-line-of-a-given-file)
143146
* [Group commits by authors and title](#group-commits-by-authors-and-title)
144147
* [Forced push but still ensure you don't overwrite other's work](#forced-push-but-still-ensure-you-dont-overwrite-others-work)
@@ -169,6 +172,7 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`.
169172
* [Push a new local branch to remote repository and track](#push-a-new-local-branch-to-remote-repository-and-track)
170173
* [Change a branch base](#change-a-branch-base)
171174
* [Use SSH instead of HTTPs for remotes](#use-ssh-instead-of-https-for-remotes)
175+
* [Update a submodule to the latest commit](#update-a-submodule-to-the-latest-commit)
172176

173177
<!-- Don’t remove or change the comment below – that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
174178
<!-- @doxie.inject end toc -->
@@ -191,6 +195,11 @@ git help -g
191195
git log -S'<a term in the source>'
192196
```
193197

198+
## Show changes over time for specific file
199+
```sh
200+
git log -p <file_name>
201+
```
202+
194203
## Remove sensitive data from history, after a push
195204
```sh
196205
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch <path-to-your-file>' --prune-empty --tag-name-filter cat -- --all && git push origin --force --all
@@ -211,6 +220,11 @@ git ls-tree --name-only -r <commit-ish>
211220
git update-ref -d HEAD
212221
```
213222

223+
## Reset: preserve uncommitted local changes
224+
```sh
225+
git reset --keep <commit>
226+
```
227+
214228
## List all the conflicted files
215229
```sh
216230
git diff --name-only --diff-filter=U
@@ -295,6 +309,11 @@ __Alternatives:__
295309
git push origin :<remote_branchname>
296310
```
297311

312+
313+
```sh
314+
git branch -dr <remote/branch>
315+
```
316+
298317
## Delete local tag
299318
```sh
300319
git tag -d <tag-name>
@@ -1015,6 +1034,11 @@ git push -f <remote-name> <branch-name>
10151034
git remote add <remote-nickname> <remote-url>
10161035
```
10171036

1037+
## List all currently configured remotes
1038+
```sh
1039+
git remote -v
1040+
```
1041+
10181042
## Show the author, time and last revision made to each line of a given file
10191043
```sh
10201044
git blame <file-name>
@@ -1191,5 +1215,14 @@ git rebase --onto <new_base> <old_base>
11911215
git config --global url.'git@github.com:'.insteadOf 'https://github.com/'
11921216
```
11931217
1218+
## Update a submodule to the latest commit
1219+
```sh
1220+
cd <path-to-submodule>
1221+
git pull origin <branch>
1222+
cd <root-of-your-main-project>
1223+
git add <path-to-submodule>
1224+
git commit -m "submodule updated"
1225+
```
1226+
11941227
<!-- Don’t remove or change the comment below – that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
11951228
<!-- @doxie.inject end -->

tips.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,5 +512,8 @@
512512
}, {
513513
"title": "Use SSH instead of HTTPs for remotes",
514514
"tip": "git config --global url.'git@github.com:'.insteadOf 'https://github.com/'"
515-
}
515+
}, {
516+
"title": "Update a submodule to the latest commit",
517+
"tip": "cd <path-to-submodule>\ngit pull origin <branch>\ncd <root-of-your-main-project>\ngit add <path-to-submodule>\ngit commit -m \"submodule updated\""
518+
}
516519
]

0 commit comments

Comments
 (0)