GitHub repository created but unable to upload VS solution - c++

I tried uploading a C++ project from Visual Studio 2019 onto my GitHub account.
The repository gets created when I do this however, none of my codes gets uploaded onto the repository.
Only the files ".gitattributes" and ".gitignore" appear in my repository.
Please could I have any suggestions on what I could do to fix this.

Close VS
Go to your local repository folder (the solution folder)
This will add all the files and commit them
git add .
git commit -m 'added files'
alternatively you can use "git add ___" to add one file at a time
Make sure you commit the changes and then do
"git push"
Re-open VS and everything should be setup now.
Here are some other instructions I wrote down recently which you may find helpful:
How to create a git repo from an ungitted local project already in development:
Create a empty repo on your repo hosting site
Go to your local project folder in git command line
git init
git add .
git commit -m 'message'
git remote add origin https://yourreposite.com/username/repo
git push -u origin master
Now you can open it in Visual Studio and everything is all setup

Related

Hugo site starts locally, only displays 404 on hosted GH page

My Hugo site starts locally, but only returns a 404.html page when hit on GitHub Pages.
I've tried re-instantiating the repo, rebuilding the site with different commands, pushing and deploying with the Hugo deploy script, and rm -rf the public folder and re-adding it.
Repository: https://github.com/jschalz/jschalz.github.io
When following the tutorial, running git submodule add -b master git#github.com:jschalz/jschalz.github.io.git public:
'public' already exists in the index
Currently hosted at https://jschalz.github.io.
I'd expect the site to come up with my pages (and I definitely have non-draft pages on there), but it's only returning 404.html. It's possible it's because I renamed the repo at one point, but I'm not sure. Troubleshooting ideas are very appreciated.
UPDATE: The issue was that I didn't have an index.html, index.xml, or README.md in my repo. Fixed.
2022: A different approach uses now GitHub Actions, since those are the default to build GitHub pages, since Aug. 2022.
Hence the new section "Build Hugo With GitHub Action" and the GitHub actions/hugo-setup.
Original answer 2019:
The issue was that I didn't have an index.html, index.xml, or README.md in my repo. Fixed.
Not exactly fixed.
The point of the tutorial was:
git submodule add -b master git#github.com:<USERNAME>/<USERNAME>.github.io.git public
This creates a git submodule.
Now when you run the hugo command to build your site to public, the created public directory will have a different remote origin (i.e. hosted GitHub repository).
Meaning what you should be pushing if, from your public subfolder, only what Hugo has generated.
You should not push your Hugo project (config.toml, themes, and so on): those should be pushed in a separate GitHub repository for safekeeping and versionning.

Can I clone a single git branch in Visual Studio?

I have a TFS git repository which takes a long time to clone. Is there a way to only clone a single branch in Visual Studio?
If you are using Git CLI, you should use (in a CMD or PowerShell instance or any other terminal-like client of your preference):
git clone -b branch_name --single-branch 'repo_url'
branch_name: is the name of your branch.
repo_url is the link of your remote repository.
This will import a specific branch from your remote repository.
According to this, you need to know that Visual Studio just read your .git (and other Git dependencies such as gitignore, gitmodules, etc) configuration.
Considerations:
This works only with git 1.7.10 version and above.
References:
Visual Studio 2017 Branching MSDN documentation
Similar question

VSTS: Store zip files from build for usage across builds

I am working on a series of builds. There are intermediate files created from few builds and other builds use those files in their build process. The build processes are scripted in PowerShell scripts. We are using private agents as there are custom dependencies.
Currently, we are using a folder on the private agent to store the intermediate outcomes that we refer to in the dependent builds.
We wish to keep it on VSTS (might be as a zip file) and download and unzip to a folder when we build the dependent component.
We see nuget etc. to be not fitting to the requirement.
Is there any available option for it?
If you want to store files in VSTS instead of the local agent machine, you can store the files into a separate repo hosted in VSTS.
Such as to store a zip file ($(Build.SourcesDirectory)\my.zip) into VSTS git repo (https://account.visualstudio.com/project/_git/filestore), you can execute below PowerShell script during build:
git clone https://Personal%20Access%20Token:PAT#account.visualstudio.com/project/_git/filestore
Copy-Item $(Build.SourcesDirectory)\my.zip $(Build.SourcesDirectory)\filestore
cd filestore
git add .
git commit -m 'add zip file'
git push oirgin master
After executing the build, the zip file my.zip stores in the VSTS git repo.
I finally published the outcome from the first build as part of the build artefact and then used in other (dependent) builds. It was nice to do.
Also, found it equivalent to having it on NuGet. Plan to move to Nuget later.

Visual Studio 2017 and Git Clone

This is driving me crazy. We are using a local installation of gitlab and I'm trying to create a new remote repository from Visual Studio, for a new solution.
If I try creating the solution first, then Git clone, it complains the folder is not empty.
If I empty the folder and clone the repository, works, but then I cannot create the solution because it complains the folder is not empty.
So how the heck I am supposed to create a new clone for a new solution?! The remote repository has only readme.md file in it.
I had the same issue, and I found the same workaround (git clone empty repository, copy .git folder to my app folder, then sync).
Lately, I found that it's much simpler:
open your solution in VS
select "add to source control" (bottom right corner), then select "git"
a local .git folder is created, VS also populates .gitignore and .gitattributes, and commits.
now, you can notice that Team Explorer page shows a "Publish Git Repo" button, press it
enter an URL pointing to a non-existent git repo, e.g. "https://gitlab.com/full/path/to/myproject.git"
press "Publish" button
that's all.
Obviously, you must have installed GitLab extension for visual studio, before.
HTH.

Git and KDevelop

I'm starting programming with KDevelop and Git.
I'm creating a project in C++ with KDevelop 4.4.1 and actually I've a Git account in Assembla.
I'm able to create an "internal git repository", doing commits with KDevelop.
I was researching about how I can PUSH my project into my account, but I didn't found enough information. How I can push my project to my repo in Assembla?
Pushing generally is done like this:
Before the first push you should add a remote:
git remote add origin pathToRepositoryInAssembla
Now for the first push (I'm assuming your default branch is master)
git push -u origin master
This will push your changes and git will no assign the origin/master to your local master. After this by using
git push
It will automatically push all “assigned” branches that contain changes.
For more information on how to use git refer to the official handbook. For more information on remotes refer to Working with remotes.