alfa_80
alfa_80

Reputation: 427

How not to affect the original cloned git repository

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   

Upvotes: 0

Views: 2531

Answers (2)

jeremyjjbrown
jeremyjjbrown

Reputation: 8009

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?

Upvotes: 4

pampasman
pampasman

Reputation: 318

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>

Upvotes: 1

Related Questions