markdown 将现有本地上传到远程

Posted

tags:

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

Create Repository at GitHub or GitLab and copy the https address of the repo.

---

Open Git Command or Bash.

First get to the existing directory
```
> cd my/folder/
```
or Hold SHIFT, right click the folder you're in, then select Open command window here.
  
Now start a new git repository
```
> git init
```
---
  
Identify if the current elements on the directory are needed 
or not and add them to the **.gitignore** file.
  1. Create the text file gitignore.txt
  2. Open it in a text editor and add your rules, then save and close
  3. Hold SHIFT, right click the folder you're in, then select Open command window here
  4. Then rename the file in the command line, with `ren gitignore.txt .gitignore`
  
---

When ready create the first commit on the server  
```
> git add .
> git commit -m "my first commit"
```

---

if the remote repo was just created, it probably has no branch to push to  
in this case; goto Github.com and create dummy.txt file which triggers the creation of the master branch.  
you can delete the dummy.txt file once after the branch is created.

---

Now add the address the local repo to remote address
```config
[remote "origin"]
	url = https://github.com/sarpay/NetCoreMVCStarter.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
```

---

Now push the files to the remote repo
```
> git push -u origin master
```

If you get cannot merge due to unrelated histories do;
```
> git pull --allow-unrelated-histories
```

以上是关于markdown 将现有本地上传到远程的主要内容,如果未能解决你的问题,请参考以下文章

markdown 将远程git仓库添加到现有本地项目

将本地现有目录连接到现有 Git 远程存储库

markdown 如何将文件从远程服务器复制到本地计算机?

将本地项目上传到远程仓库的步骤

markdown 将远程源/主服务器合并到新的本地存储库中

本地Markdown上传图片