markdown [昨天我学会了......]继续学习#general

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown [昨天我学会了......]继续学习#general相关的知识,希望对你有一定的参考价值。

# How to create an empty stand-alone branch in GIT
----------
I’m trying to refactor a web app over to Laravel. Initially, I checked out the code from GIT, created a branch, and started making my changes. When I realized how drastic the changes were, I decided that it would be better to start with a blank slate.

I deleted everything in the branch and started from scratch, but the obvious problem is that the branch shares commit history with the master branch.

After doing some research, I came across a git command to create an “orphan” branch that doesn’t share any commit history with ‘master’. Perfect for maintaining different projects in the same repository without mixing up their commit histories. Here’s how to do it:

Before starting, upgrade to the latest version of GIT. To make sure you’re running the latest version, run

```
which git
```
If it spits out an old version, you may need to augment your PATH with the folder containing the version you just installed. 

Ok, we’re ready. After doing a cd into the folder containing your git checkout, create an orphan branch. For this example, I’ll name the branch “mybranch.”
```
git checkout --orphan mybranch
```
Delete everything in the orphan branch
```
git rm -rf .
```
Make some changes
```
vi README.txt
```
Add and commit the changes
```
git add README.txt
git commit -m "Adding readme file"
```
That’s it. If you run
```
git log
```
you’ll notice that the commit history starts from scratch. To switch back to your master branch, just run
```
git checkout master
```
. You can return to the orphan branch by running
```
git checkout mybranch
#git
```
# Git Tips and tricks
--------
### Git cli guides
```sh
thieryl@thieryl[12:42:19]: $ git help -g 
The common Git guides are:

   attributes   Defining attributes per path
   everyday     Everyday Git With 20 Commands Or So
   glossary     A Git glossary
   ignore       Specifies intentionally untracked files to ignore
   modules      Defining submodule properties
   revisions    Specifying revisions and ranges for Git
   tutorial     A tutorial introduction to Git (for version 1.5.1 or newer)
   workflows    An overview of recommended workflows with Git

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
```

### Git Aliases
```sh
git config --global alias.<handle> <command> 
git config --global alias.st status
```

### list you git configuration
```bash 
thieryl@thieryl[09:52:44]: $ git config --list 
user.email=thiery.louison@redboxdigital.com
user.name=thiery louison
alias.aa=add --all
alias.bv=branch -vv
alias.ba=branch -ra
alias.bd=branch -d
alias.ca=commit --amend
alias.cb=checkout -b
alias.cm=commit -a --amend -C HEAD
alias.cam=commit -am
alias.ci=commit -a -v
alias.co=checkout
alias.di=diff
alias.ll=log --pretty=format:%C(yellow)%h%Cred%d\ %Creset%s%Cblue\ [%cn] --decorate --numstat
alias.ld=log --pretty=format:%C(yellow)%h\ %C(green)%ad%Cred%d\ %Creset%s%Cblue\ [%cn] --decorate --date=short --graph
alias.ls=log --pretty=format:%C(green)%h\ %C(yellow)[%ad]%Cred%d\ %Creset%s%Cblue\ [%cn] --decorate --date=relative
alias.mm=merge --no-ff
alias.st=status --short --branch
alias.tg=tag -a
alias.pu=push --tags
alias.un=reset --hard HEAD
alias.uh=reset --hard HEAD^
color.ui=auto
```
### Get git bash completion
```sh
curl http://git.io/vfhol > ~/.git-completion.bash && echo '[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash' >> ~/.bashrc

```

### List of the remote branches
To see all the branches, try the following command:

```sh
thieryl@thieryl[09:50:31]: $ git branch -a 
  master
* my_newfeature
  remotes/origin/master
  remotes/tlo/master
[~/.dotfiles]
```

### Tracking remote branch and creating local branch with the same name.
```sh
git checkout -t origin/{{branch_name}}
```

### Remember the branch structure after a local merge
```sh
git merge --no-ff some-branch-name
```

### Modify previous commit without modifying the commit message
```sh
git add --all && git commit --amend --no-edit
```

### Add a local branch tracking the remote branch.
```bash
$ git branch --track style origin/style
Branch style set up to track remote branch style from origin.
$ git branch -a
  style
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/style
  remotes/origin/master
$ git hist --max-count=2
* 2faa4ea 2011-03-09 | Changed README in original repo (HEAD, origin/master, origin/HEAD, master) [Thiery Louison]
* 6e6c76a 2011-03-09 | Updated index.html (origin/style, style) [Thiery Louison]
```

### Map a local branch tracking to a remote branch
```bash 
thieryl@thieryl[09:47:38]: $ git checkout -b my_newfeature -t tlo/master
thieryl@thieryl[09:50:23]: $ git status -v 
On branch my_newfeature
Your branch is up to date with 'tlo/master'.

nothing to commit, working tree clean
[~/.dotfiles]
thieryl@thieryl[09:50:31]: $ 

thieryl@thieryl[09:48:43]: $ git ld
* e5480c7 2018-07-19 (HEAD -> my_newfeature, tlo/master, origin/master, master) Add new git alias [thiery louison]
* 508b1b4 2018-07-19 Add .gitconfig file to repo [thiery louison]
* 33ac493 2018-07-04 Add new functions [thiery louison]
* c0026b1 2018-07-02 Add new aliases and new variables [thiery louison]
*   210c4ed 2018-06-08 Merge branch 'master' of github.com:thieryl/dotfiles [thiery louison]
|\  
| * 9598e8c 2018-05-23 Delete .bashrc_old [GitHub]
| * ab974f7 2018-05-23 Update .bashrc_old [GitHub]
* | d832d62 2018-06-08 Add new aliases [thiery louison]
|/  
* 8a2acd3 2018-05-23 Add .bash_promt [thiery louison]
* c4fc360 2018-05-23 Add new alias [thiery louison]
* 2d1d74c 2017-09-25 Modified some functionality [thiery louison]
* 9ba5d65 2017-09-12 Add the password generator pgen to the .bash_aliases file [thiery louison]
* 1cf2a81 2017-08-31 Add new alias for git [thiery louison]
* 8033abc 2017-08-31 Add new alias and new functions [thiery louison]
* 43ba75d 2017-08-31 Initial commit [thiery louison]

```

以上是关于markdown [昨天我学会了......]继续学习#general的主要内容,如果未能解决你的问题,请参考以下文章

认识和学会使用markdwn

学会等待作文

Markdown 插入图片

1分钟学会Markdown语法

10分钟学会使用Markdown绘制UML时序图

站立会议07