简体   繁体   中英

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.

So I create a github repo. (On github) Click "clone" to get the URL for later.

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. After, 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM