我是github的新手,想知道如何将本地项目推送或设置到远程环境?例如,我在C:\ project中有一个项目如何将其发送到github远程?使用git console时我一直都失败了。任何步骤?
答案 0 :(得分:3)
我使用的步骤:
create a local repository, if not yet,
commit local repository locally,
git add .
git commit -am "init"
create a repository on github with same name as local repo:
left it empty, no README or .gitignore file,
config remote:
git remote add origin https://github.com/[user]/[project_name].git
set remote url:
git config remote.origin.url https://[user]@github.com/[user]/[project_name]
initial push to github:
git push -u origin master
set tracking info - master:
git branch --set-upstream-to origin/master
tip:
before do this, the remote repo should at least contain 1 commit,
you can do this by push once, or create a file remotely (e.g. README.md).
check the project on github, to see is it ok.
如果你在本地拥有多个分支,并且你想跟github跟踪多个分支,而不仅仅是master。
steps - push another branch to github:
* make sure both local/remote have the same branch already,
if not yet, you can push a local branch to remote first,
format:
git push [remote] [branch]
* in local
switch to specific branch,
then set its upstream via:
git branch --set-upstream-to=<remote>/<remote_branch> <local_branch>
e.g.
git branch --set-upstream-to=origin/develop develop
*
学习git的地方
man git xxx
xxx是git的内部命令名称,例如添加
答案 1 :(得分:1)
以下网站将提示如何做。我认为这会有所帮助。 https://help.github.com/articles/pushing-to-a-remote/
1.首先重定向到你想要设置的git项目。
git init
git add *
git push
答案 2 :(得分:1)
如果您当前的工作文件夹尚未由Github初始化,请使用以下命令:
git init
git remote add origin <the http git address of your remote repository>
git add .
git commit -m "<some comments for this commit>"
git push origin master
如果您的工作副本已初始化,并且您希望将远程目标存储库更改为另一个。然后我相信以下命令会有所帮助:
git remote set-url origin <the address of your new repository>
git add .
git commit -m "<some comments>"
git push origin <the branch you want to push to>
希望这个答案很有用!