How can I push to specific folder in the remote repository? I have the following structure on my local C drive:
myfolder/
.git
folder1
folder2
folder3
folder4
.gitignore
I executed git init
command in this folder. After that I did git add .
and then git commit -m "My first commit"
Now I would like to push it to the VSTS remote repository that contains similar structure:
https://helloworld.visualstudio.com/VSTS_folder/_git/VSTS_folder
VSTS_folder/
greenFolder
redFolder
blueFolder
blackFolder
yellowFolder
.gitignore
README.md
where VSTS_folder is the name of the repository. greenFolder, redFolder and yellowFolder have some code in there already. What I would like to do is to push my local stuff to blackFolder remote folder which is empty. I'm trying to avoid messing with the repo and pushing my stuff to the root. I was using git remote add origin https://helloworld.visualstudio.com/VSTS_folder/_git/VSTS_folder/blackFolder
but that didn't work. What's the appropriate git command for achieving this? Thanks.
Open Git Bash in that particular folder that you want to push. Type git remote add origin PASTE_SSH_KEY_OF_CREATED_REPO. Then type git push origin master –force (type 'main' in place of the 'master' if your default branch is master).
On your computer, move the file you'd like to upload to GitHub into the local directory that was created when you cloned the repository. Open Terminal . Change the current working directory to your local repository. Stage the file for commit to your local repository.
That's not how Git works. You have one repository called VSTS_folder
. Whoever created that repo didn't understand what a Git repository is.
You need to clone the repository, which will give you a copy of the entire repo. Then you can add additional code to it.
If all of these folders contain totally independent projects that share nothing between them, then you should consider splitting them into separate repos.
You would also hugely benefit for sitting down and reading a Git tutorial to get a better understanding of these concepts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With