kaka
kaka

Reputation: 7915

git push is not pushing the changes to the repository

I am new to git and trying to understand what its commands do, So for this i installed git in my windows system.

I made one of my folder as git repository, by running the command "git init". This created ".git" directory in that folder.

cd git-repo
git init

After that i tried to clone that repository, so for this i made a seperate folder and went inside that and ran the "git clone ../git-repo" command. This cloned the git-repo.

Now i did some changes in this cloned folder, and tried to commit it to the git-repo by using the commands :

git add .
git commit -m "test commit"
git push origin branch1

But the problem is that the pushed changes is not visible in the git-repo. Please help me with this.

Thanks

Upvotes: 0

Views: 462

Answers (3)

ThanksForAllTheFish
ThanksForAllTheFish

Reputation: 7241

You just missed one option when you created the "remote" repository. Try the following

  • move to the folder you want to use as remote git repository and issue the command: git init --bare. The --bare initialize the repository as a remote one, in which you can later push
  • move to any folder you want to use as working (or local) repository and do the clone: git clone /remote-repository
  • now you should be able to push and pull. Simply, git push should work.

My personal suggestion is to work with custom remote, since when you clone a repository git will always create a remote called origin associated with the branch master and this may become confusing when you work on more repository.

Upvotes: 1

mnagel
mnagel

Reputation: 6854

you are pushing to a none-bare repo. depending on your git version this (still) works, but with newer gits it will no longer work.

you should be pushing to a bare repo (that can function similar to a server in centralized version control) and then pull from there, i.e. make the transfer indirect.

read more about bare repos: http://gitolite.com/concepts/bare.html

Upvotes: 1

manojlds
manojlds

Reputation: 301037

What is branch1? Maybe the original repo has master or someother branch checked out. You will have to git checkout branch1 in the original repo to see those changes.

Upvotes: 0

Related Questions