You can type "git status" at any time, and I use it a lot to find out what the state of things is. It tells me what files are staged to commit and whether I need to push things to my remote repository.
The following will put the changes into the local repository AND push them to the remote repository. You typically only do both when you reach a significant milestone and everything is tested and working.
git commit -a -m "fiddled with stuff" git push origin masterI usually don't put the "-m message" on the command line and let git prompt me for the commit message. I also leave the "-a" off and precede the "git commit" with "git add .". So my usual set of commands is:
git add . git status git commit git push origin masterDoing the status before the commit lets you see what the add has staged for commit and prevents you from commiting a bunch of binary files and the subsequent cursing and need to edit the .gitignore file and clean up the mess.
git diff git logThe "log" command gives you a history of what has been commited, which will be only as useful as the commit messages you gave when you did the commit. In a big collaborative project, there are often strict policies about making quality commit messages and how they should be formatted.
git pullOr this:
git fetch origin git merge origin/masterAt this stage, I always do "git pull", but there are fine points here that are important if you are doing more advanced things with git.
The fetch pulls all data that you do not yet have in your local repository. The command "git fetch origin" is what you use to keep a cloned project up to date. It only updates the local repository though, not your working files, you need to merge to do that. Git pull will try to fetch and merge both.
See this article:
I read an essay somewhere that said mean and nasty things about using git pull and said you should always fetch and merge. As near as I can tell, this is only important if are working with branches and changes have appeared that do not pertain to your branch. In such a case, the changes would not be automatically merged and you would be given more control about how things would be handled. For most of what I do, this is just needless hassle.
rm file.c (or better yet, mv file.c file_BAK.c) git checkout file.cNote that "git checkout" can be used at any time to pull a specific file out of the repository.
To get rid of a file (to make git stop wanting to track it, and to actually delete the working copy too). If you just delete the file, git will notice and complain and do its best to restore it for you. Nothing actually gets deleted till you commit though.
git rm file git commitTo rename a file, do this:
git mv old newGit is smart enough to notice if you just do a rename, so you can just do the rename and let git do clever things, but I feel better telling it.
git tag git tag -a v2.03 -m "My version 2.03" git show v2.03If you omit the -a and -m you get a lightweight tag.
Tags must get pushed explicitly to a remote server:
git push origin v2.03
Tom's Computer Info / [email protected]