# Common Git commands
:::info
All commands below should be performed when in the project directory except for `clone`.
Click [here](https://chris.beams.io/posts/git-commit/) to learn how to write good commit messages.
:::
## clone
```shell
git clone http://github.com/adeline/Project.git
```
"Downloading" the remote repository as a directory.
## init
```shell
git init
```
Set up a local directory and make it a git repository.
## add
```shell
git add olaf.md
```
Add a file to the local repository.
## remote add
```shell
git remote add origin http://github.com/adeline/Project.git
```
Conenct the local repository to a remote repository if it is not already linked to a remote repository.
## fetch
```shell
git fetch -a
```
Enable access to all branches on the local repository. `-a` or `--all` means to `fetch` all branches.
## checkout
```shell
git checkout branch-0405
```
Switch to a different branch of the remote repository. The local directory will be syncronized accordingly.
## branch
```shell
git branch
```
Show all branches. The current branch name will be highlighted in green and preceded by a `*` sign.
## commit
```shell
git commit -m"Added olaf.md"
```
Commit changes to the current branch.
## push
```shell
git push origin branch-0405
```
Push all commits from the local repository to the designated branch of the remote repository.
## merge
```shell
git merge branch-0405
```
Merge the designated branch **into** the current branch; that is, **the current branch is the one being modified.** Consider it as a special type of `commit`, which means **a `push` command is required for the remote repository to be updated**.
## pull
```shell
git pull origin branch-0405
```
"Merge" the designated branch into the local repository.
## stash
```shell
git stash
```
Cover the local repository with the current branch of the remote repository. Be careful when performing a `stash` because **all local progress that are not pushed will be lost.**