From 1631ef988a55aef9546a0baa6be243ddab7f4958 Mon Sep 17 00:00:00 2001 From: Jim Date: Tue, 4 Feb 2014 08:22:34 +0800 Subject: [PATCH] modify post 14-02-03 --- _posts/2014/2014-02-03-Git-cook-book.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/_posts/2014/2014-02-03-Git-cook-book.md b/_posts/2014/2014-02-03-Git-cook-book.md index 2627558..708f9e1 100644 --- a/_posts/2014/2014-02-03-Git-cook-book.md +++ b/_posts/2014/2014-02-03-Git-cook-book.md @@ -135,9 +135,11 @@ git push origin --delete ### How to delete the merge orig file? ------------- Some automatically generated `*.orig` files will be left in your working folder after a successful merge. One quick way to delete them could be + ``` git clean -f ``` + **Beware** There's no going back. Use `-n` or `--dry-run` to preview the damage you'll do. `git-clean` Remove untracked files from the working tree If you want to also remove directories, run `git clean -f -d` @@ -148,10 +150,12 @@ Note the case difference on the X for the two latter commands. ### How to know the remote branch names? ------------- OK, you got a huge repository, maybe the first step is to know the remote branch names. + ``` git branch -r ``` ### How to rename a file? + ``` $ git mv README README.md $ git commit -m "renamed" @@ -162,11 +166,14 @@ $ git push origin master ------------- Before you can start working locally on a remote branch, you need to fetch it as called out in answers below. To fetch a branch, you simply need to: + ``` git fetch origin git branch -r ``` + This will fetch all of the remote branches for you. With the remote branches in hand, you now need to check out the branch you are interested in, giving you a local working copy: + ``` git checkout -b test origin/test ```