Git Commands

This summarizes introductory Git commands and Github commands.

START
Initialize
git init projectName


GITHUB = online "remote" repository for code
Add

View

Remove

Rename
git remote add github https://github.com/user/repo.git

git remote -v

git remote rm currentName

git remote rename currentName newName


FILES = text documents that make up the software source code
Add

Commit

Push

View

Remove

Rename


Move
git add file

git commit -m "Message about new file"

git push github branch

git log

git rm file

git mv currentName newName
(view history) git log --follow ./path/to/file

git mv currentDir/file newDir


BRANCHES = copies of the code base
Add

View


Delete




Rename

Merge
git checkout -b newBranchName

git branch -v
(on github) git branch -r

git branch -D <local-branch-name>
(on github) git push origin :branchName

git push origin --delete <remote-branch-name>

git branch -m oldName newName

git merge fromBranchName toBranchName

VERSIONS = version numbers / tags for software releases
Add

View

Push

Revert
git tag -a v1.0 -m "version 1.0"

git tag

git push --tags

git checkout v0.1


NOTES
Delete = Remove

REFERENCES
CodeSchool Git Real