-
Notifications
You must be signed in to change notification settings - Fork 36
Git Cheat Sheet
Andy Berry edited this page Dec 3, 2013
·
5 revisions
-
clone the repo to your local machine
git clone <URL>
- The URL for the repo is found on the GitHub page
-
change to the develop branch
git checkout develop
-
set up submodules
git submodule init
git submodule update
- when changing branches you might need to run
git submodule update
again if submodules have changed
-
make some changes to files
-
check the status
git status
- This should point out there are untracked files, or that some files have changed and need to be staged
-
use diff to check your staging what you want
-
git diff file1
orgit diff
to show all changes
-
-
stage the files
git add file1
git add file2
- This can also be done on a directory level, or add all with git add -A
-
check the status again
- You should see the files are now ready for a commit
-
commit
git commit -m “i made some awesome changes”
-
rinse and repeat
-
push changes
git push origin develop
- clone the repo and switch to the develop branch
- create your branch
git branch featureX
- No need for the ‘-t’ here since we’re branching from a remote branch
-
push the new branch so other people can see it/make changes
git push origin featureX
- make some commits and push every so often
-
merge from develop to the feature branch
git merge develop
- Use a pull-request to merge the feature back in to develop
- This should all be do-able through the GitHub interface via a pull-request
- The resulting commit should be tagged to set the version
- View your remotes (external locations)
git remote -v
- In general you will only have 1
- Its best to keep GitHub as ‘origin’
- View the branches, including remote ones
git branch -a
- Remove all untracked files (files created and not in source control)
git clean -d -f
- View a log of commits
git log
- The number one command
-
git help
orgit help <something>
-
- Online book - definately worth a read: http://git-scm.com/book/en/
- Git Cheat Sheet: http://byte.kde.org/~zrusin/git/git-cheat-sheet.svg
- Git for ages 4 and up: https://www.youtube.com/watch?v=1ffBJ4sVUb4