0

I have cloned a repository and in it there is a .git directory. What I'm worried is that if I commit, it will also commit to the original repository and that I don't want it to happen. Is there a way that I can do about it, by which it will not affect the original repository that I've cloned from.

Thanks in advance.

EDIT: What I normally did to maintain my repository is as below:

cd /path/to/my/local_repo
git remote add origin my_repo_link
git push -u origin --all   
alfa_80
  • 427
  • 1
  • 5
  • 21

2 Answers2

4

You will only affect the original or remote repository if you use the push command.

Git is different from svn in that you have a complete local repo. You can commit to that repo all you want because it is a different repo. When you push you are asking your local repo to do an svn style commit of whatever you have changed in the local repo to the remote (original) repo.

If you want to clone from one repo and then push to a different remote repo you'll need to change the remote branch your local branch is pointed at.

How do I change the remote a git branch is tracking?

Community
  • 1
  • 1
jeremyjjbrown
  • 7,772
  • 5
  • 43
  • 55
  • I see..but I need to run the command push to maintain the git remotely(on the bitbucket, mine, not the original repo). – alfa_80 Feb 06 '14 at 03:46
  • Am I correct if I run the 'push' command after changing the remote repo as in "git branch --set-upstream branch_name your_new_remote/branch_name"? – alfa_80 Feb 06 '14 at 04:10
  • 1
    yes, I would try push a trivial edit like a comment as a test. – jeremyjjbrown Feb 06 '14 at 04:10
1

If also worry about messing your local repository you can create a local branch:

git branch <my new branch>
git checkout <my new branch>
... <make all your changes>
git commit -a .
... <if your want to go back to your previous state>
git branch <your initial branch>
... < if you want to clean up>
git branch -d <my new branch>
pampasman
  • 318
  • 2
  • 9