Git snippets
Mar 3, 2017 · 2 分钟阅读

Working with forks

Clone your fork to your local machine

$ git clone git@github.com:USERNAME/FORKED-PROJECT.git

Add ‘upstream’ repo to list of remotes

$ git remote add upstream https://github.com/UPSTREAM-USER/ORIGINAL-PROJECT.git

Fetch from upstream remote

$ git fetch upstream

Check out your fork's local master branch

$ git checkout master

Merge the changes from upstream/master into your local master branch

$ git merge upstream/master

Working with branches

Pushing to a remote

$ git push <REMOTENAME> <BRANCHNAME>
$ git push <REMOTENAME> HEAD:<BRANCHNAME>

Renaming branches

$ git push <REMOTENAME> <LOCALBRANCHNAME>:<REMOTEBRANCHNAME>

Deleting a remote branch

$ git push <REMOTENAME> :<BRANCHNAME>

Checkout a remote branch

$ git checkout -b <LOCALBRANCHNAME> <REMOTENAME>/<REMOTEBRANCHNAME>

Adding an existing project to GitHub

Initialize the local directory as a Git repository

$ git init

Add the files in your new local repository. This stages them for the first commit

$ git add .

Commit the files that you've staged in your local repository

$ git commit -m "First commit"

In Terminal, add the URL for the remote repository where your local repository will be pushed

$ git remote add origin remoteRepositoryURL

Push the changes in your local repository to GitHub

$ git push -u origin master

Delete commit history

Create orphan branch

$ git checkout --orphan temp_branch

Add files to branch

$ git add -A
$ git commit -m "First commit"

Delete master branch

$ git branch -D master

Rename current branch

$ git branch -m master

Push changes

$ git push -f origin master

see more: github help, GitHub-Forking

← Previous Post Next Post →

Ryun的博客
与其感慨路难行,不如马上出发。

atom css design git html javascript jekyll laravel life mac mobile optimization sublime tool vscode vue
mac

About

你好,❤朋友

这里是 Ryun 的博客 📝

📝记录了我学习 🔎的过程

作为一名前端攻城狮 🦁

希望能和大家一起 🔎

共同进步 🏃

🦁的特长:

  • HTML5
  • CSS3
  • JavaScript
  • Vue.js
  • 微信小程序
  • 熟练配合 Node.js、PHP 和 Laravel
  • 熟练使用各种开发和设计工具

🦁喜欢 🆒🆒的东西

对提升效率和美感的事物有兴趣 😋

欢迎 👏交流


see this hugo-theme-dream-ink