[英]GIT: Synchronize local files to new github repository
I frequently want to do this, but can never remember how. 我经常想这样做,但永远不记得怎么做。
First I create a file on my computer, some source code, and now I want to push it to a github repo. 首先,我在计算机上创建了一个文件,提供了一些源代码,现在我想将其推送到github存储库中。
So I create a github repo. 所以我创建了一个github仓库。 (On github) Click "clone" to get the URL for later.
(在github上)单击“克隆”以获取URL供以后使用。
Now I run the following commands on my local machine. 现在,我在本地计算机上运行以下命令。
git init // make a repo, local
git add * // add files to repo
git commit -a -m "initial commit" // commit files to repo and add msg
git remote add origin (...url...) // tell git where to push
git push --set-upstream origin master // no idea what this does
git config --global user.name "...name..." // set my name so github knows what my username is
git push // does not work error:
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
Still can't "push". 仍然不能“推动”。 What am I doing wrong?
我究竟做错了什么?
Try cloning, then cd
into the repo. 尝试克隆,然后将其放入回购
cd
。 After, add *
. 之后,
add *
。 Then run your desired commit and push. 然后运行所需的提交并推送。 This should work.
这应该工作。 If i were to do this without making any branches, it would look like this:
如果我不做任何分支就做这个,它看起来像这样:
> git clone 'repoName'
> cd repoName
> git add *
> git commit -m "first commit"
> git push
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.