Git cheet sheet Setting up a new repo https://www.atlassian.com/git from within the folder you want to make a repo
Create a new repository on the command line¶
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:alexpchin/<reponame>.git
git push -u origin master
Push an existing repository from the command line¶
git remote add origin git@github.com:alexpchin/<reponame>.git
git push -u origin master
git status
Workflow¶
- checkout with branch name/what you are doing
- branch name can be a short description of what is being worked on
- without the -b git looks for an existing
git checkout -b 'branch name'
-
Make changes to my file
- git status will make file text red in git status - not ready to commit
-
Verify the files I want to push to github with "git status" from within file
git status
- git add 'path where the files live'
- git status will turn text green - ready to commit
git add 'filename'
- git status will turn text green - ready to commit
- git commit -m 'comment on the commit' for short messages
- git commit - alone will give you an editor for more verbose messges
- This will clear the working tree
git commit -m "updated README"
- git log will show commits before pushing
git log
- Push changes to Github
- will generate a link in shell to GitHub
- this will push the change to github
- enter notes and click create pull request
git push -u origin HEAD
- check 'files changed' tab to view changes before merging PR
- click Merge pull request
- click Confirm Merge
- Checkout the master branch
git checkout master
- git pull to the latest master branch from GitHub
git pull