简体   繁体   中英

How do I start using my repository locally and on Github?

So:

1) I have created my account on github and I've created a repository there.

2) I have the keys to access the repository from my dev machine to github, using SSH, so that my local repository is synchronized with the remote one hosted on github once I do, push or pull.

But, I'm not understanding how will all this start.

I have my local files on this dev computer and from there I do:

3) git init

then

4) git add

and then I 5) commit that project to my LOCAL repository.

Once this is done, then I will 6) push this to github repository.

Is this correct?

That's basically correct, yes. To explain what each thing is doing...

  1. git init basically says, "Hey, I want a repository here." You only will have to do this once per repository.
  2. After that, you will want to add a remote, which GitHub probably told you to do by using git remote add origin git@github.com:username/repository This allows you to push to a remote. You will only have to do this once as well.
  3. After that, use git add to add your changes, or "stage them". You can use git add -i for a bit of a more interactive experience.
  4. Use git commit -m 'message' to commit locally.
  5. Then use git push origin master This says, "Push all of the commits to the remote origin, under master.
  6. If you make changes from another machine, or someone else makes changes, you can use git pull to get them from the remote.

You might want to consider reading ProGit - it's free online and is a wealth of information. There you can learn more about features like branching, merging, etc.

You're missing one step: somewhere before the last step, you need to do a git remote add origin git@github.com:username/reponame so that Git knows where to push your repo when you say git push origin master . Otherwise, you've got it! You may want to check your work with git diff before you commit, though.

我认为您只需要执行以下操作即可: git push origin master您可以在此处找到详细信息: http : //programertools.blogspot.com/2014/04/how-to-use-github.html

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