Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

Amber Hoddinott
Amber Hoddinott
6,494 Points

confused about how to push my project to my online github repository? please help me by answering a few questions :)

Hey :D I have a few questions, im trying to use git hub and I’m a little confused by somethings. How do you push your changes using my the git command line, from my project file on my computer to my github online repository? (im using a mac computer by the way)…

Whats is the commond, im under the understandment its….

git push origin master 

…. this i guess is ment to push my changes from the master branch, but i have created a branch called “home_page” which I’m working on. How do i push the changes from the home page, and as i do this will it automaticlly update my master branch? im guess not if its done correctly as i would need to merge my home_page branch with my master branch for the master branch to be updated right?

i hope this all makes sense and that ive explained myself well enough. lol its not something thats easy to explain in a message… but ive watch so many video and now im just so confused i though id ask on here :D Happy new years everyone and happy coding :D Amber x

7 Answers

Hi Amber,

Yes, you're correct. To push your local master branch to the remote origin branch, you use git push origin master.

If you've created a new branch and want that to be remote too, try git push remote_branch local_branch. Let me try it on one of my projects now. I'll try in this repo that I created for another student.

I'll be right back!

Steve.

Right - done.

Create the branch: git checkout -b 'Ambers_Branch'

Push the branch to the remote: git push origin 'Ambers_Branch'

We now have a branch on the remote as well as locally. You can see that here

I hope that helps!

Steve.

To merge back, switch to master (make sure you've committed everything): git checkout master

Then merge: git merge 'Ambers_Branch'

Then push: git push

So, now, in the master branch in the remote repo, you can see the changes I made in the branch in the master code here - I added a new variable: private String ambersString = "Github test";

Amber this is something I have struggled with myself.. Here is a short story that helped me.. I hope you find it helpful too.

In order to get more comfortable with Git, let’s walk through a fictional workflow. You are now a worker at 123 Web Design, where you’re building a new website for Jimmy’s Ice Cream Shop along with a few of your coworkers.

You were a little nervous when your boss told you that you’d be participating in the Jimmy’s Ice Cream Shop webpage redesign project. After all, you’re not a programmer; you’re a graphic designer. But your boss assured you that anyone can use Git.

You’ve created a new illustrations of an ice cream sundae, and it’s time to add it to the project. You’ve saved them in a folder on your computer that is also called “icecream” to prevent yourself from getting confused.

Open up the Command Line and change directory until you’re inside the icecream folder, where your designs are stored.

cd ~/icecream

Next, initialize Git so you can start using Git commands inside the folder. The folder is now a Git repository.

git init

Wait, this is the right folder, right? Here’s how you check and make sure this is where you stored your design:

git status

And this is what Git will tell you in reply:

Untracked files:

(use "git add ..." to include in what will be committed)

chocolate.jpeg

There they are! Add them to your local Git repository so they’ll be tracked by Git.

git add chocolate.jpeg

Now, take a “snapshot” of the repository as it stands now with the commit command:

git commit -m “Add chocolate.jpeg.”

Great! But your co-workers, hard at work in their own local repositories, can’t see your fantastic new design. That’s because the main project is stored in the company GitHub account (username: 123WebDesign) in the repository called “icecream.”

Since you haven’t connected to the GitHub repo yet, your computer doesn’t even know this exists. So tell your local repository about it:

git remote add origin https://github.com/123WebDesign/icecream.git

And double check to make sure it knows:

git remote -v

Finally, it’s the moment you’ve been waiting for. Upload that delicious looking sundae up to the project:

git push

Ta da! With all of these tool at hand, it's clear that Git and the GitHub service aren't just for programmers.

The full story can be read here

Amber Hoddinott
Amber Hoddinott
6,494 Points

Hi thank you so much to both of you first for taking the time to reply and help me. :D

I have dont as you send "git push origin home_page"

and i get this ...

Switched to branch 'home_page' Ambers-Air:web_development_portfolio1 Ambermaria$ git push origin home_page To https://github.com/ambermaria88/web_development_portfolio1.git ! [rejected] home_page -> home_page (non-fast-forward) error: failed to push some refs to 'https://github.com/ambermaria88/web_development_portfolio1.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. Ambers-Air:web_development_portfolio1 Ambermaria$

sounds like you need to make a pull request before updating it.

Amber Hoddinott
Amber Hoddinott
6,494 Points

i dont really understand why i had to do a pull request, but i can do it now so thank you!!! x

Hi Amber,

I just want to make sure that your question about local and remotes branches on Github has been clarified; are you OK with that now? If not, please just shout.

Steve.

Amber Hoddinott
Amber Hoddinott
6,494 Points

Hi steve, Sorry I've only just seen this. Yes thank you i think im alot clearer on it now :D Thank you for checking in. :)

No problem - glad you got it sorted.

Steve.

Amber Hoddinott
Amber Hoddinott
6,494 Points

Ive just posted a question in css if your interested in helping me again :)

I'm not great at CSS, I'm afraid. However, the pseudo elements ::before and ::after`, I thought, we positioning rules such that you could do something like:

h1::before {
  content: "dog.jpg";
}

which would position an image before the h1 element. Your question mentions visited links etc. I think that's a different pseudo element, :visited and others like :hover.

Again, I'm not great with CSS but those are my thoughts.

Steve.

Yeah - I messed about with your code:

h1::before{
    content: "Steve";   
    width: 50%;
    height: 1px;
    bottom: 0;
    left: 25%;
    border-bottom: 1px solid red;
}

This inserts "Steve" in front of the h1 element. I removed the position: absolute; rule first, though.

Steve.

Not a problem. :-)