mirror of
https://github.com/k88hudson/git-flight-rules.git
synced 2025-03-10 12:48:43 -03:00
add 4 tips
This commit is contained in:
parent
9536d6987d
commit
36b4aadc11
41
README.md
41
README.md
@ -274,3 +274,44 @@ And finally, let's cherry-pick the commit for bug #14:
|
|||||||
```
|
```
|
||||||
(14)$ git cherry-pick 5ea5173
|
(14)$ git cherry-pick 5ea5173
|
||||||
```
|
```
|
||||||
|
## I want to discard local commits so my branch is the same as one on the server
|
||||||
|
|
||||||
|
Confirm that you haven't pushed your changes to the server.
|
||||||
|
|
||||||
|
`git status` should show how many commits you are ahead of origin:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ git status
|
||||||
|
# On branch bug123
|
||||||
|
# Your branch is ahead of 'origin/bug123' by 2 commits.
|
||||||
|
# (use "git push" to publish your local commits)
|
||||||
|
#
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
# one commit
|
||||||
|
git reset --hard HEAD^
|
||||||
|
# two commits
|
||||||
|
git reset --hard HEAD^^
|
||||||
|
# four commits
|
||||||
|
git reset --hard HEAD~4
|
||||||
|
```
|
||||||
|
|
||||||
|
## I want to discard my local, uncommitted changes
|
||||||
|
|
||||||
|
```
|
||||||
|
git reset --hard
|
||||||
|
# or
|
||||||
|
git checkout -f
|
||||||
|
```
|
||||||
|
|
||||||
|
## I want to add changes in one file to two different commits
|
||||||
|
|
||||||
|
`git add` will add the entire file to a commit. `git add -p` will allow to interactively select which changes you want to add.
|
||||||
|
|
||||||
|
## I want to remove a file from git but keep the file
|
||||||
|
|
||||||
|
```
|
||||||
|
git rm --cached log.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user