[EN] Basic recommendations for git commands using command line

# Options other than command line.
First, before we look into command line, lets see what other choices we have, if we decide not to use command line.

For people who do not use command lines, **`GitHub Desktop`** (https://desktop.github.com/) will be the main option you have.

GitHub Desktop is useful in many ways,
so lets see what it is, what is good / bad about this tool.

### What is GitHub Desktop?
GitHub Desktop, is a tool officially created by GitHub team.
Project using GitHub, can be managed easily by using this tool, without need of deep knowledge of Git / GitHub.
<img width="500" alt="ScreenCapture 2017-11-30 13.36.56.png" src="https://qiita-image-store.s3.amazonaws.com/0/85904/5727ccae-1dcd-ab0f-19e9-3db4aaebbafc.png">


### What is good about GitHub Desktop?
1. Simple.
    2. There is no need to learn about Git commands.
2. Can manage project in GitHub-Flow easily.
3. Can `add`, `commit`, `stash` your changes easily with clicking buttons.
    4. `Add` : Get your updated file ready to be managed using Git.
    5. `Commit` : Save your changes using Git.
    6. `Stash` : Delete your unsaved changes using Git.

### What is bad about GitHub Desktop?
1. Deploy branch is based on `master`, and need some techniques to work in flow using `develop` branch.
2. Cannot `rebase`, `reset` and some other commands.
    3. `Rebase` : Import changes using git.
    4. `Reset` : Delete changes using git.
5. Cannot manually use commands, and use options for each commands.

### Conclusion.
For people who is not used to coding, or non-engineers, GitHub Desktop would be the great tool to use.
But thinking about future, after you get used to using Git and GitHub, **I will strongly recommend learning and using Git commands**.


---


# Basics about using command line for GitHub.
### Tools to use.
There will be several tools you can select to use, when you work with command line for GitHub, but I will just jolt down my recommendation.

Windows : GitBash
Macintosh : Terminal

![ScreenCapture 2017-11-30 15.30.12.png](https://qiita-image-store.s3.amazonaws.com/0/85904/af06e243-0cac-1145-7a58-2b52bc728175.png)

### Basic commands to use.
When you work with Git, the basic commands you will always use everyday, would be something like followings.

1. `git add` : Add your changes to Git.
2. `git commit` : Save your changes to Git.
3. `git push` : Upload your saved contents to server.

Above are the most basic command everyone will use at least once.
And as some additional basic commands, there is something like followings.

1. `git stash` : Delete your unsaved changes.
2. `git stash pop` : Undo delete by `git stash`.
3. `git remote update` : Refresh and reload any updates from server.
4. `git checkout` : Get / move to new branch.
5. `git fetch` : Get copy from server.
6. `git merge` : Import changes. 
7. `git pull` : Do `git fetch` and `git merge` 

### Commands with options.
To use GitHub more wisely, commands are often used with **options**.
By using options, you can make more complexed changes, and Git will become lot more useful once you get used to it.

Here are some commands with options.
1. `git add .` or `git add *` : Add all changes to Git.
2. `git add *.cs` : Add all changes from files that ends with `.cs`.
3. `git pull --rebase` : Do `git pull` without new merge commit.
4. `git reset --soft HEAD^` : Undo last commit. Last commit content will be remain, and can re-commit if you need.
5. `git reset --hard HEAD^` : Undo last commit. Last commit content will be deleted.

---

# Recommended commands.
As last, I will just make a list of some commands I recommend, and use daily.
1. `git status` : Check updated status.
2. `git diff` : Check all changes within each files.
3. `git diff <file-path>` : Check all changes within specified file.
4. `git diff *.cs` : Check all changes within files that end with `.cs`.
5. `git reset HEAD` : Undo `git add` for all added files.
6. `git reset HEAD <file-path>` : Undo `git add` for specified added file.
7. `git log` : Check all commit log.
8. `git log --oneline` : Check all commit log in 1 line per commit.
9. `git branch` : Check all branch in local.
10. `git branch -r` : Check all branch in remote. 
11. `git checkout -b <branch-name>` : Create new branch from current branch.
12. `git branch -d <branch-name>` : Delete branch in local.
13. `git branch -D <branch-name>` : Force delete branch in local.
14. `git push <branch-name>` : Upload branch to server.
15. `git :push <branch-name>` : Delete branch in server.
16. `git commit --allow-empty` : Create empty commit with no change.
17. `git merge --no-ff <branch-name>` : Import branch with making merge commit.
18. `git remote update` : Refresh and reload data from server.

---

# Conclusion.
As seen above, there are many ways of using Git commands.
And there are lots more commands than above.

Depending on how you want to use Git and GitHub, you may not need most of commands.
But once you will need to use something complexed, it will be easier if you are already used to Git commands, than learning from scratch after being master of GitHub Desktop.

So by any chance, if you are interested in Git and GitHub, please have a try of using command line. :slight_smile: