---
# System prepended metadata

title: Git Tips
tags: [git]

---

---
tags: git
---
> [name=Yunrou Gong]
> [time=Fri, May 31, 2019 5:54 PM]
> [color=#12cc8e]
> [TOC]
> 
# Git Tips

## Simple Git Workflow

This workflow assumes you are working on your local repo and have a remote repo to which you will push changes. It can be GitHub, but it will work the same with other remote repos. It assumes you’ve already cloned the repo.

1. `git status` – Make sure your current area is clean.
2. `git pull` – Get the latest version from the remote. This saves merging issues later.
4. Edit your files and make your changes. Remember to run your linter and do **unit tests**!:disappointed: :eyes: 
5. `git status` – Find all files that are changed. Make sure to watch untracked files too!
6. `git add [files]` – Add the changed files to the staging area.
7. `git commit -m "message"` – Make your new commit.
8. `git push origin [branch-name]`– Push your changes up to the remote.


## Clean Up Merged Branch --local and remote
### List local/ remote branches 
`git branch -a ` - list all the local and remote branch 
`git branch -r `- list all the remote branch

### Prune/Cleanup the local references to remote branch
`git remote prune origin --dry-run`- list branches that can be deleted/pruned on your local. An option `--dry-run` is needed.

`git remote prune origin` -- prune the remote branch 

### Delete local branch
`git branch -d branch_name` - delete local branch
`git branch -D branch_name`- force to delete local branch

Ref: http://www.fizerkhan.com/blog/posts/Clean-up-your-local-branches-after-merge-and-delete-in-GitHub.html

## Exclude personlised settings for git ( do not let git to track)

`cd /Users/uername/project_name/.git/info`

`cat exclude`

```bash
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
### VisualStudioCode ###
.vscode/
### VisualStudioCode Patch ###
## Ignore all local history of files
.history
```

```python=
import os 

if a : 
    print ('it is yunrou')
else:
    print ('not yunrou')
    
```
