PCSX2 Documentation/Git Survival Guide: Difference between revisions

no edit summary
(Created page with "There is a lots of guide/docs on internet but there are too big and confusing. You will find here a mini guide to use git with a minimal number of command and parameters. You...")
 
No edit summary
Line 1: Line 1:
There is a lots of guide/docs on internet but there are too big and confusing. You will find here a mini guide to use git with a minimal number of command and parameters. You won't find any details or explication of git internal mechanism here.
There is a lots of guide/docs on internet but there are too big and confusing. You will find here a mini guide to use git with a minimal number of command and parameters. You won't find any details or explication of git internal mechanism here.


# Git guide
=Git guide=


### Remote Transfer or how to communicate with the world
==Remote Transfer or how to communicate with the world==
* Get a fresh repository: git clone `<remote path>`
* Get a fresh repository: <code>git clone <remote path></code>
* Update current repository to latest: git fetch -v  
* Update current repository to latest: <code>git fetch -v</code>
* Update current repository with commit from a fork: git fetch -v `<remote path>` `<branch>`
* Update current repository with commit from a fork: <code>git fetch -v <remote path> <branch></code>
* Send your new commit to the remote: git push `<remote>` `<branch>`
* Send your new commit to the remote: <code>git push <remote> <branch></code>


### Commit or how to communicate with your local repository
==Commit or how to communicate with your local repository==
* staged your change with dynamic selection: git add/rm -p `<file>`
* staged your change with dynamic selection: <code>git add/rm -p <file></code>
* commit your change: git commit
* commit your change: <code>git commit</code>
* uncommit previous commit: git reset --soft HEAD~1
* uncommit previous commit: <code>git reset --soft HEAD~1</code>
* unstage your change: git reset HEAD --
* unstage your change: <code>git reset HEAD --</code>
* discard your change **forever** with dynamic selection: git checkout -p -- `<file>`
* discard your change **forever** with dynamic selection: <code>git checkout -p -- <file></code>


### Stash or how to save your precious work
==Stash or how to save your precious work==
Stash is very useful. For example, your will use it before/after (push/pop) merge/rebase action  
Stash is very useful. For example, your will use it before/after (push/pop) merge/rebase action  
* Push pending update on the stack: git stash
* Push pending update on the stack: <code>git stash</code>
* Get back your update: git stash pop
* Get back your update: <code>git stash pop</code>
* view content of your stash: git stash show -p `stash@\{0\}`
* view content of your stash: <code>git stash show -p stash@\{0\}</code>


### Rebase or how to screw the history
==Rebase or how to screw the history==
**Never** rebase commits that were pushed remotely. Rebase can be used to improve your current patch set, or to fast-forward-merge after a fetch.
'''Never''' rebase commits that were pushed remotely. Rebase can be used to improve your current patch set, or to fast-forward-merge after a fetch.
* The rebase command: git rebase -i
* The rebase command: <code>git rebase -i</code>
* Cancel it : git rebase --abort
* Cancel it : <code>git rebase --abort</code>
* Resolve conflict: git mergetool `<file>`
* Resolve conflict: <code>git mergetool<file></code>
* Continue rebase: git rebase --continue
* Continue rebase: <code>git rebase --continue</code>


### Branch or how to separate your work by feature
==Branch or how to separate your work by feature==
Please note that master is actually the default branch
Please note that master is actually the default branch
* List branches: git branch -v
* List branches: git branch -v
Line 39: Line 39:
# Git use case example
# Git use case example


### Branch management
==Branch management==
Let's say you want to rebase your current branch topic-v1 to topic-v2 with new addition. Note topic-v1 could also be master too.
Let's say you want to rebase your current branch topic-v1 to topic-v2 with new addition. Note topic-v1 could also be master too.
* Go to current branch: git checkout topic-v1
* Go to current branch: git checkout topic-v1
Line 48: Line 48:
* ...
* ...


### Split commit
==Split commit==
* copy your repository if you're not confident with this kind of operation: cp -a `<repository>` `<repository backup>`
* copy your repository if you're not confident with this kind of operation: cp -a `<repository>` `<repository backup>`
* do a rebase: git rebase -i
* do a rebase: git rebase -i
ninja
782

edits