Not c++ but hope someone can help with git

I am sorry that this is not a c++ question, but I hate to ask on stackoverflow, feels like everyones task there is to make you sound stupid, and here everyone seem pretty chill. So hoping for some help.

I am learning git and having a few problems with some key words, such as remote. I think because I am just starting a lot of the explanations sound like they are going against each other. Is remote on my pc or is it like what is hosted on github.
I see git push origin master . What is origin and what is master. Master sounds like it would be github but not sure if that is correct. But also origin sounds like what would be on github since its the origin of the project?? :/

I have also been practising with a project and using git add, git status etc. One time i got the message back "Your branch is ahead of 'origin/master' by 1 commit. Is that origin/master the same one I asked about above, why is it given together now, as in origin/master. If one is meant to be my pc and one is meant to be github why are they together, and what on earth branch am I on thats now different. Sorry if this is a bit of a ramble, I am really confused with all this. Any help would be great.
often the commands sound backwards on code repo tools.


remote is a machine you need to use networking to access. git lets you make an alias to these that hides the url for handy command syntax, so remote can mean one of these alias OR the actual remote machine based off context.

push sends from your machine to the repo. you are the origin, the repo is the master, typically. its only screwy if you are both, eg the repo is on your machine. Even then its changed code to repo, its just weirdly worded in that case.

I am not sure about that message. I think it is simply telling you that your copy has changes not in the repo yet. Repo people are like the folks that write compiler errors. Its like a foreign language, until you learn it the messages are sort of strange. I have not learned it fully, using another brand of repo where I am, and before that, we had git but it was behind an interface.

VS code has a solid easy to use git interface built into it. Once you are happy with the command line, find something like this if you want a gui. Or set up some better worded batch/shell programs that do what you need with less thinking about it.
Last edited on
Thanks for the answer, still struggling a bit, but think I am understanding it a bit more.

So git push origin master is basically saying push origin which is what I have on my computer, to the master which is what is stored on github?
Right.
SO is full of self-important jerks. Sorry about that.

There are actually a couple of tutorials all about using github that, while slow and boring, actually take you through everything fairly well. It is worth your time to work your way through them at least once to get used to it.

One thing to remember for all CMS systems is that you are always the remote object. The server maintaining your repo is the host. Remote connects to the host. This is true even if you are running your own git server on your own machine -- you still need to connect to it to do anything.

Hope this helps.
> you are the origin, the repo is the master
>> origin which is what I have on my computer, to the master which is what is stored on github?
no, that's backwards

$ git remote --verbose
origin  https://github.com/ne555/foo.git (fetch)
origin  https://github.com/ne555/foo.git (push)

the remote refers to another repository that you want to track its changes (fetch) and upload your changes to (push)
remote is outside, far far away, not local (this may help you when you'll need to resolve a merge conflict)
`origin' is just a name, an alias for the address

> I see git push origin master. What is origin and what is master.
push: upload the changes
origin: the remote repository
master: the branch you want to upload.

`master' refers to a commit (state of your code) in your local machine.
It tends to be used with a `main' or `publish' meaning (this code works)

You may also do `git push origin feature_foo` for the team to see the changes that are not quite done yet to be on master

(additional read https://www.atlassian.com/git/tutorials/comparing-workflows )

> One time i got the message back "Your branch is ahead of 'origin/master' by 1 commit.
as I said before, remote is another repository and as such it may also contain branches
when you do `git push origin master` you are saying «update the master branch of the origin repository with the contents of my master branch»
The message is simply saying that your local and remote repos don't have the exact same code, that you have committed some change since the last fetch/push


> VS code has a solid easy to use git interface built into it. Once you are
> happy with the command line, find something like this if you want a gui.
I don't know if you should wait to use a «friendly» interface, but these are some things that you should be able to do with ease in whatever tool you chose:
- know what changes are yet to be committed/discarded
- navigate through the history (¿what this commit did?)
- compare your code to another state in the history (or another branch, or against a remote)
- revert your code to a previous state
- resolve merge conflicts


By the way, apart from learning the tools, it's important to learn to write good commit messages and adopt a good workflow for your team.
Last edited on
sorry if I got something backwards, as I said, we used high level tools with it, and now using SVN, so a bit rusty on some of the details.

Revert is the one thing I use most, I agree with that list 100%.
jonnin wrote:
a bit rusty on some of the details

I.e., don't trust anything jonnin says as he seems to be lying about his so-called "experience". :-)
I haven't seen anyone here make any claim about experience. We mostly help where we can.
I'm in about one github project, no branches, so I've:
1
2
3
4
git pull
edit files
git commit
git push

I kind of knew that you can specify something here and there, but have not had need for it.
Thank you all for the answers. I believe I now understand most of my questions. So the origin is the repo on github etc, and origin is just an alias for the URL of the repo. The master is the master branch that I am working on on my pc. So I am pushing the master on my pc, to the origin which is github?
@MyOnlinePersona

the word origin means configured remote that is your own repository on GiHub.

remote, you can have multiple different remotes, but each one has to be named differently, the word origin is the default name assigned to your remote, which you can change.

master is branch name, your repository may have multiple branches and just like remote each one has to have name, the "master" is the default name assigned to you main branch.

remote is just a "web address" of your repository on github.

git push origin master therefore means push your commits to configured remote on github named "origin" to branch named "master".

Is that origin/master the same one I asked about above, why is it given together now, as in origin/master.


It's like specifying a path on your computer,

syntax is: remote\branch
using default remote name and default branch name, this turns out to be origin\master.
Last edited on
@MyOnlinePersona

You have read the man git-push? https://git-scm.com/docs/git-push
Topic archived. No new replies allowed.