Git Notes
Just Enough to Get Started with Git and Github
Given a project started locally outside of Git. Move it to git and github:
Given a project started locally outside of Git. Move it to git and github:
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
Workflow:
git status
git add foo
git commit -m "fooooooooooo"
git push origin master
Next, a One-Person Workflow with Branching
#Start with a project in a happy, committed state
#Master is our main/production branch
#Create a branch to work on a new feature
#git checkout -b <new_branch> <start_point>
git checkout -b new-feature master
#The above is the same as
# git branch new-feature
# git checkout new-feature
#See all the branches
git branch
#Push the new branch to Github. After this, "git push" will update everything.
git push --set-upstream origin new-feature
<Do stuff & commit.>
#Store your commit safely on Github
git push
<Rinse and repeat>
#Merge your beautiful new work
git checkout master
git merge new-feature
git push
#Delete the feature branch
git branch -d feature-branch
#Not sure if this matters. The feature branch is still listed on Github
git push
Next, Work with Other Humans...
...
Workflow:
git status
git add foo
git commit -m "fooooooooooo"
git push origin master
Next, a One-Person Workflow with Branching
#Start with a project in a happy, committed state
#Master is our main/production branch
#Create a branch to work on a new feature
#git checkout -b <new_branch> <start_point>
git checkout -b new-feature master
#The above is the same as
# git branch new-feature
# git checkout new-feature
#See all the branches
git branch
#Push the new branch to Github. After this, "git push" will update everything.
git push --set-upstream origin new-feature
<Do stuff & commit.>
#Store your commit safely on Github
git push
<Rinse and repeat>
#Merge your beautiful new work
git checkout master
git merge new-feature
git push
#Delete the feature branch
git branch -d feature-branch
#Not sure if this matters. The feature branch is still listed on Github
git push
Next, Work with Other Humans...
...
Here is the workflow I have been using:
ReplyDeleteStart by creating a new repository on GitHub.
1. Create and initialize the local project and push to GitHub
echo "# [Project Name]" >> README.md
git init
git add README.md or git add . //to add all files
git commit -m "first commit"
git remote add origin https://github.com/[username]/[Project Name].git
git remote -v
git push -u origin master
2. Feature Branch Workflow
start with master branch
git checkout master
git fetch origin
git reset --hard origin/master
Create new Branch
git checkout -b new-feature master
3. Do some work
git status
git add
git commit
4. Initialize the upstream branch the -u only needs to be done once
git push -u origin new-feature
5. do some more work then add to the remote
git push
6. initiate a pull request at github
http://www.github.com/[UserName]/[Project Name]
7. once all changes have been approved, merge the branch.
git checkout master
git pull
git merge --no-ff new-feature
git push origin master
8. Start this process again for the next feature.
Thanks!
Delete