- Initializing repository:
git init. - Linking with Github:
git remote add origin https://github.com/<user>/<repo>. - First pull from a certain branch (e.g.
master):git pull origin <branch>.
- Make changes wherever and whenever you want.
- If you create a file and you want to be tracked by git, add it:
git add <file>. If you're lazy, thengit add -A(all files). - Commit your change:
git commit -m <message>orgit commit(probably aviwindow will appear). You will always have to write a message, so if you're lazy just write 'A'. That's not a good idea, though. - Finally, sync with Github:
git push. The first time, you will have to choose where to push:git push --set-upstream origin <branch>
- If you expect to use a new branch, create it on Github.
- Just type
git checkout -b <branch>(if new) or and update your Github source:git pull origin <branch>andgit push --set-upstream origin <branch>.
- Switch to the branch:
git checkout <branch>.
- Probably changes will be performed by others, so you will have to merge them before pushing. Before pushing, check if there are changes by
git pull; git will automatically try to merge your changes with others'. If there is a problem, local files will be modified and you will have to decide what to do, change the file and commit and push again. - Your last option to restore the repo from Github and erase your local files is
git fetch --allandgit reset --hard origin/<branch>.