-
Create a new Repo at https://github.com/repositories/new
-
Create the README file
mkdir ~/hello-world cd ~/hello-world git init touch README
-
Commit your README
git add README git commit -m 'first commit'
-
Push your commit
create a remote named 'origin' pointing at your github repo
git remote add origin [email protected]:<creator-name>/<project-name>.git
send your commits in the "master" branch to GitHub
git push origin master
(sometimes necessary, not sure when)
git pull origin master
list branches
git branch
Create a new branch
git branch experiment
git branch -b experiment (switches to it at the same time)
Switch to a branch
git checkout experiment
git checkout master
if you want to push the branch
git push origin experiment
Merging
git checkout master
git merge experiment
Merge conflict resolution (manual)
-
open up the file that failed
-
Correct it where there are normal merge conflict markers
-
run
git add
on the file to re-stage it, marking it as resolvedgit add lib/simplegit.rb
-
commit the merge
git commit
Deleting a branch
git branch -d experiment # won't allow you to lose changes
git branch -D experiment # will allow you to lose changes
Go to the appropriate github repository and copy and past the command, e.g...
git clone [email protected]:<creator-name>/<project-name>.git
-
via github, fork project to your account (click "fork" button)
-
normal clone from your own account
-
Configure remotes
When a repo is cloned, it has a default remote called origin that points to your fork on GitHub, not the original repo it was forked from. To keep track of the original repo, you need to add another remote named upstream:
Assign the original repo to a remote called "upstream"
git remote add upstream <URL-OF-ORIGINAL-GIT>
Pull in changes not present in your local repository, without modifying your files
git fetch upstream
-
Push commits
git push origin master
-
Pull in upstream changes
git fetch upstream git merge upstream/master
-
create a github repo
-
set your local git repo to view the url from step one as origin
git remote add origin <URL_FROM_STEP_1>
-
push
git push origin master
- Git Emmersion
- Learn Git Branching
- Generating SSH Keys (only to be used on your personal computer)
- StackOverflow: Git push existing repo to a new and different remote repo server?
- StackOverflow: Import existing source code to github