markdown Git Daily Tricks

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Git Daily Tricks相关的知识,希望对你有一定的参考价值。

## Github Resources

- [GitHub Cheat Sheet](https://github.com/tiimgreen/github-cheat-sheet): A collection of cool hidden and not so hidden features of Git and GitHub. 
- [Awesome Github](https://github.com/AntBranch/awesome-github): A curated list of awesome GitHub guides, articles, sites, tools, projects and resources. 
- [Awesome Git Addons](https://github.com/stevemao/awesome-git-addons): A curated list of add-ons that extend/enhance the git CLI.

## Git Daily Tricks

### Create New Repo and Push

### Git setup
```shell
git config user.name  "user_name"
git config user.email "user_email"
```
### Create a new repository
```shell
git clone <remote-repo>
cd <remote-repo>
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
```
### Existing folder or Git repository
```shell
cd <local-repo>
git init
git remote add origin <remote-repo.git>
git add .
git commit
git push -u origin master
```

### Sort branches by commit order [¶](https://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit)

```shell
# Simple
git for-each-ref --sort=-committerdate refs/heads/
# Advance
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
```

### How to remove local (untracked) files from the current Git working tree? [¶](https://stackoverflow.com/questions/61212/how-to-remove-local-untracked-files-from-the-current-git-working-tree)

```shell
# delete file
git clean -f
# delete directory
git clean -f -d
```

以上是关于markdown Git Daily Tricks的主要内容,如果未能解决你的问题,请参考以下文章

markdown 工具:终端:Git:Git

markdown git #git

markdown Git笔记#git #tutorial

markdown [Git常用命令] #git

markdown git命令#git #commands

markdown [Git命令]一个基本的git命令#git #commands