photon
photon

Reputation: 616

Why do git commits exist on my local clone/directory but not on GitHub?

I have committed and pushed several changes for a project using git on the command line, but when I log in to GitHub, the branches and commits I made are not shown on my account. Why?

I can review all commit history I have made using git on the command line.

Results of git remote -v command

origin  https://github.com/felixtan/guessing-game.git (fetch)
origin  https://github.com/felixtan/guessing-game.git (push)

Upvotes: 1

Views: 2474

Answers (1)

VonC
VonC

Reputation: 1324977

Once committed locally, you still need to push those commits to github:

git push

(since your remote is named origin, you don't need to specify its name: it pushes by default to 'origin')

This assumes you are the owner or one of the collaborators of the repo felixtan/guessing-game.

If it is the first time you push your current branch:

git push -u origin yourCurrentBranch

That establish a tracking relationship between your branch and 'origin/yourBranch', as detailed in "Why do I need to explicitly push a new branch?".

Once that first push is done, the subsequent pushes are simple 'git push'.


If you are not the owner/collaborator, you won't have the right to push to that repo.

You need to make a fork (See GitHub forking), and in your local cloned repo you are already working on:

git remote rename origin upstream
git remote add origin https://[email protected]/YourLogin/guessing-game.git

That way, you will push to your fork (that you own), and will make pull requests from there (See GitHub pull requests).

Upvotes: 4

Related Questions