From 92117ee22ed241011abca320f1f9e062a0e857e4 Mon Sep 17 00:00:00 2001 From: Margen67 Date: Sat, 8 May 2021 00:04:40 -1000 Subject: [PATCH] Formatting --- Git-survival-guide.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Git-survival-guide.md b/Git-survival-guide.md index 4c53c00..8dc1771 100644 --- a/Git-survival-guide.md +++ b/Git-survival-guide.md @@ -3,12 +3,14 @@ There are lots of guides and documents on the internet, but there are too many a # Git guide ### Remote Transfer or how to communicate with the world + * Get a fresh repository: git clone `` -* Update current repository to latest: git fetch -v +* Update current repository to latest: git fetch -v * Update current repository with commit from a fork: git fetch -v `` `` * Send your new commit to the remote: git push `` `` ### Commit or how to communicate with your local repository + * stage your change with dynamic selection: git add/rm -p `` * commit your change: git commit * uncommit previous commit: git reset --soft HEAD~1 @@ -16,12 +18,14 @@ There are lots of guides and documents on the internet, but there are too many a * discard your change **forever** with dynamic selection: git checkout -p -- `` ### 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 * 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 @@ -29,6 +33,7 @@ Stash is very useful. For example, your will use it before/after (push/pop) merg * 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 `` @@ -37,12 +42,14 @@ Please note that master is actually the default branch * Set the base reference of the branch (for rebase): git branch --set-upstream-to=`` `` ### House keeping + * Deletes all stale remote-tracking branches under ``: git remote prune `` * List merged branch (safe to delete): git branch --merged # Git use case example ### Branch management + Let's say you want to rebase your current branch topic-v1 to topic-v2 with new additions. Note: topic-v1 could also be master too. * Go to current branch: git checkout topic-v1 * Create a new one: git branch topic-v2 @@ -52,6 +59,7 @@ Let's say you want to rebase your current branch topic-v1 to topic-v2 with new a * ... ### Split commit + * Copy your repository if you're not confident with this kind of operation: cp -a `` `` * Do a rebase: git rebase -i * Use edit on the commit that you want to split @@ -66,4 +74,4 @@ Repeat the 2 next commands for each new commits that you want to create * Commit your change: git commit Once you have finished to split your commit: -* Finish the rebase: git rebase --continue \ No newline at end of file +* Finish the rebase: git rebase --continue