简体   繁体   中英

Updating a github Repo

I've read a bunch of tutorials and they all stop just short of what I want to do next. I've set up git on OS X and pushed all the files up to github. My git status says:

On branch master
nothing to commit, working directory clean

Now I want to update one of the files on github. Do I just update and commit on git locally and then push it up to github or do I have to pull it first? I'm the only person working on this repo. I'm sure there must there must be some documentation somewhere. Everything I've seen is for branching, merging, etc.

Answer

The accepted answer by floor below appears to be what you would do with new files. I've found that the last two steps are all I need to update an existing file:

git commit -m "Reason for change"
git push origin master

I would guess that, if the destination file on github was out of sync with your local copy, you would get an error and would have to do a merge. As stated above, this process assumes you have pushed your repository up to github for the first time and now want to make changes.

You should pull first if your repo isn't up to date locally but since you are he only one working on it, it is highly unlikely your repo won't be up to date.You need to tell git what files to upload and which files to ignore and have a commit message.

git add -A   <-- Adds all files
git commit -m "Message"
git push origin master <--- assuming you have that setup'

You can create a file call gitignore and it holds a list of files to ignore when pushing to git. Also there is a git hub app that runs with command line and makes a gui for it. It works well. github app for mac

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