PCSX2 Documentation/Git Survival Guide: Difference between revisions
(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 |
||
(15 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
There | There are a lot of guides/docs on the internet but they are too big and confusing. You will find here a mini guide to use git with a minimal number of commands and parameters. You won't find any details or explications of git's internal mechanisms here. | ||
==Git Guide== | |||
===Remote Transfer or how to communicate with the world=== | |||
* Get a fresh repository: git clone | * 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 | * 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 | * Send your new commit to the remote: <code>git push <remote> <branch></code> | ||
===Commit or how to communicate with your local repository=== | |||
* staged your change with dynamic selection: git add/rm -p | * 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 -- | * discard your change **forever** with dynamic selection: <code>git checkout -p -- <file></code> | ||
===Stash or how to save your precious work=== | |||
Stash is very useful. For example, | Stash is very useful. For example, you 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 | * view content of your stash: <code>git stash show -p stash@\{0\}</code> | ||
===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. | |||
* 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 | * 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=== | |||
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: <code>git branch -v</code> | ||
* Switch to another branch: git checkout | * Switch to another branch: <code>git checkout <branch></code> | ||
* Creates: git branch | * Creates: git branch <code><branch></code> | ||
* Delete branches: git branch -d | * Delete branches: <code>git branch -d <branch></code> | ||
* Set the base reference of the branch (for rebase): git branch --set-upstream-to= | * Set the base reference of the branch (for rebase): <code>git branch --set-upstream-to=<remote><branch_name></code> | ||
==Git use case example== | |||
===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: <code>git checkout topic-v1</code> | ||
* Create a new one: git branch topic-v2 | * Create a new one: <code>git branch topic-v2</code> | ||
* Go into the new branch: git checkout topic-v2 | * Go into the new branch: <code>git checkout topic-v2</code> | ||
* Set the reference: git branch --set-upstream-to=origin/master topic-v2 | * Set the reference: <code>git branch --set-upstream-to=origin/master topic-v2</code> | ||
* Rebase: git rebase -i | * Rebase: <code>git rebase -i</code> | ||
* ... | * ... | ||
===Split commit=== | |||
* copy your repository if you're not confident with this kind of operation: cp -a | * copy your repository if you're not confident with this kind of operation: <code>cp -a <repository><repository backup></code> | ||
* do a rebase: git rebase -i | * do a rebase: <code>git rebase -i</code> | ||
* Use edit on the commit that you want to split | * Use edit on the commit that you want to split | ||
... rebase on-going... | ... rebase on-going... | ||
* Uncommit: git reset --soft HEAD~1 | * Uncommit: <code>git reset --soft HEAD~1</code> | ||
* Unstage: git reset HEAD -- | * Unstage: <code>git reset HEAD --</code> | ||
At this stage of operation, you | '''At this stage of operation, you have all your changes in the local file but nothing is ready to be committed.''' | ||
Repeat the 2 next commands for each new commit that you want to create | |||
* staged your change with dynamic selection: git add/rm -p | * 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> | ||
Once you have finished to split your commit: | Once you have finished to split your commit: | ||
* finish the rebase: git rebase --continue | * finish the rebase: <code>git rebase --continue</code> | ||
{{PCSX2 Documentation Navbox}} |
Latest revision as of 17:06, 19 July 2015
There are a lot of guides/docs on the internet but they are too big and confusing. You will find here a mini guide to use git with a minimal number of commands and parameters. You won't find any details or explications of git's internal mechanisms here.
Git Guide
Remote Transfer or how to communicate with the world
- Get a fresh repository:
git clone <remote path>
- Update current repository to latest:
git fetch -v
- Update current repository with commit from a fork:
git fetch -v <remote path> <branch>
- Send your new commit to the remote:
git push <remote> <branch>
Commit or how to communicate with your local repository
- staged your change with dynamic selection:
git add/rm -p <file>
- commit your change:
git commit
- uncommit previous commit:
git reset --soft HEAD~1
- unstage your change:
git reset HEAD --
- discard your change **forever** with dynamic selection:
git checkout -p -- <file>
Stash or how to save your precious work
Stash is very useful. For example, you will use it before/after (push/pop) merge/rebase action
- Push pending update on the stack:
git stash
- Get back your update:
git stash pop
- view content of your stash:
git stash show -p stash@\{0\}
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.
- The rebase command:
git rebase -i
- Cancel it :
git rebase --abort
- Resolve conflict:
git mergetool<file>
- Continue rebase:
git rebase --continue
Branch or how to separate your work by feature
Please note that master is actually the default branch
- List branches:
git branch -v
- Switch to another branch:
git checkout <branch>
- Creates: git branch
<branch>
- Delete branches:
git branch -d <branch>
- Set the base reference of the branch (for rebase):
git branch --set-upstream-to=<remote><branch_name>
Git use case example
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.
- Go to current branch:
git checkout topic-v1
- Create a new one:
git branch topic-v2
- Go into the new branch:
git checkout topic-v2
- Set the reference:
git branch --set-upstream-to=origin/master topic-v2
- Rebase:
git rebase -i
- ...
Split commit
- copy your repository if you're not confident with this kind of operation:
cp -a <repository><repository backup>
- do a rebase:
git rebase -i
- Use edit on the commit that you want to split
... rebase on-going...
- Uncommit:
git reset --soft HEAD~1
- Unstage:
git reset HEAD --
At this stage of operation, you have all your changes in the local file but nothing is ready to be committed.
Repeat the 2 next commands for each new commit that you want to create
- staged your change with dynamic selection:
git add/rm -p <file>
- commit your change:
git commit
Once you have finished to split your commit:
- finish the rebase:
git rebase --continue
|