'git on Linux uploading files from another repository too
I have 2 git repositories, one with 3 files and another one with the same 3 files but similar content. (Like README.md, index.html, etc.)
I used "git add" to add the files and created 2 remotes named "view" and "music". I added the 3 first files in the first folder with "git add" and commited+pushed them to the view repository. Then I went to the other folder, added those 3 files with "git add" too and commit+pushed them too, but i suddenly have the other 3 files pushed too. (The repository "music" has the files from "view" too)
TL;DR: How can I seperate git repositories on Linux
Running CentOS 7 and the newest git update available via yum. I already tried making 2 different folders and writing "git init" before using the "git add" and other commands to commit + push. They still returned an error instead of posting duplicates.
The following was used in both folders, but errors happened on the second folder
echo "# testing" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin [email protected]/reponame.git
git push -u origin master
I expected that git would somehow distinguish between multiple repositories, and that I can simply have 2 folders with 2 repositories. I thought after a git push / commit the "git add array" of files would be empty again and I could add new files for another git commit / push. How can I commit/push to multiple repositories via the Linux Command Line and push different files to different repositores without them getting mixed up.
EDIT:
The folder structure is as follows:
[usr@servr~]$ ls music/
index.html README.md songs
[usr@servr~]$ ls view/
index.html README.md pics
The exact steps I did:
cd music
git init; git add README.md; git add index.html; git add songs
git commit -m "Initial Commit"; git remote add origin <link2music>; git push -u music master
cd ../view
git add README.md; git add index.html; git add songs; git commit -m "Initial Commit"; git remote add origin <link2view>; git push -u view master
Then the git repository of view suddenly had the README.md of the music repository, and the folder songs too (even though it shouldnt).
I deleted the view repository but kept the music repository on github. (No folder deleted on my Linux machine). I then tried to exactly enter the code from the first snippet (the github offical one) in both folders (with git init too in each folder) and now the music repository, which already existed, threw me the error "! [rejected] master -> master (fetch first)", even though i never deleted the music repository, neither from my machine nor from github. (files are the same on both)
Solution 1:[1]
I didn't go through all of the code but I can immediately see what can cause the problem you describe:
your entire logic happen under this if statement:
if(horInput != 0 || vertInput != 0)
So everything inside this logic block will happen only when you actively press a movement button.
You can remove it (or better yet, close the if block at the right spot.. I think it would be 2 lines down)
Solution 2:[2]
The answer of this question is:
if((horInput == 0 || vertInput == 0) || (horInput != 0 && vertInput != 0))
{
movement.x = horInput * moveSpeed;
movement.z = vertInput * moveSpeed;
if(horInput != 0 || vertInput != 0)
{
movement = Vector3.ClampMagnitude(movement, moveSpeed);
Quaternion tmp = target.rotation;
target.eulerAngles = new Vector3(0, target.eulerAngles.y, 0);
movement = target.TransformDirection(movement);
target.rotation = tmp;
Quaternion direction = Quaternion.LookRotation(movement);
transform.rotation = Quaternion.Lerp(transform.rotation,
direction, rotSpeed * Time.deltaTime);
}
Thanks Joe
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Joe |
| Solution 2 | Red Redovich |
