Here’s a post to remind me of simple Git procedures. Maybe other people with find this helpful. After using CVS for a decade, it’s a bit hard to wrap my head around git, but I’m making that journey.
I’m using github as my repository.
START A NEW PROJECT
mkdir MYPROJECT cd MYPROJECT git init touch README git add README git commit -m "first" git remote add origin firstname.lastname@example.org:/GITHUB_USERNAME/MYPROJECT.git git push origin master
A git repository URL looks something like this:
WORK ON AN EXISTING PROJECT
git clone [GITPROJECTURL]
ADD FILES TO LOCAL REPOSITORY
git add [FILE] git commit -m "My comment about the files I added"
You can also add all the files in your project at once:
git commit -a -m "All files, including tilde files, have been added"
UPDATE REMOTE MASTER WITH LOCAL SANDBOX
git commit -m "Final checkin" git push origin master
UPDATE LOCAL SANDBOX WITH REMOTE MASTER
git fetch origin git merge origin master
REVERT LOCAL SANDBOX TO REMOTE MASTER
git reset --hard
This will restore deleted files and overwrite uncommitted changes.
Although you can also delete a local file and check it out from the local repository again:
rm [FILE] git checkout [FILE]
Also see the github book.