Git and KDevelop - c++

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.

Related

Automatic scheduled git pulls on a GCP server running a flask website

I had a few questions about automatic git pulls on a remote server. I am aware there are several questions like this, but I wasn't sure what steps to take exactly, and I don't want to mess up my current setup with a mistake :/
To wit, the environment is on a Google Cloud VM. I am running a flask-based website that renders each page with the render_template() function.
The website resides inside its git folder, i.e. I never set up a bare repo and copied stuff. When I set it up a couple years ago, I just did git clone repo-url, then inside the repo directory, did flask run. Then I set up nginx to connect to the site's socket created with uwsgi inside the repo directory.
--
It has been working fine. I make changes locally to the content, push to github, then log in to the VM, and perform a git pull.
I want to do this automatically. I tried adding a cron job to do this, where the job basically ran a script, and the script did the git pull. Script content was:
cd /repo
git pull
Running the script in the server worked, but cron never managed to do the pull.
--
I have been reading about web hooks, and there is a bunch of stuff about post-receive hooks, post-update hooks, and making bare repos. At this point, I am embarrassed to say I have no idea what I should be doing.
Any help is greatly appreciated.
Another option would be to consider a GitHub Action, which, from GitHub, could interract with your Google cloud VM.
For example, actions-hub/gcloud.
- uses: actions-hub/gcloud#master
env:
PROJECT_ID: test
APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
with:
args: cp your-file.txt gs://your-bucket/
cli: gsutil

GitHub repository created but unable to upload VS solution

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

Qt Creator and Git: No configured push destination

I keep trying to push a local repo to a remote repo and I keep getting "No configured push destination."
I couldn't fix the problem using Qt creator so I ended up realizing that I wasn't committing a certain branch.
git push reponame master
did the trick

How can I build my local git repo on external server?

In our company we have really powerful linux based build servers (double Xeon with 40 core) and not so powerful win7 laptops. We building our product in C/C++ language for an esoteric CPU. The compiler only exist in Linux. I can edit my git repo with Qt Creator. It is working and quite fast and everything. But I can't build the source on our Laptop. We have a main git repo and I can clone the same repo to my laptop and to our build server. I want to achieve that when I press the build button my code magically building on build server. I did a proof of concept solution where my build script do a git diff on my repo and scp it to the build server than it ssh to build server apply that diff on the server repo than start and wait the compilation. But that solution is not so fool proof. I think a better approaching/method is exist. So how can I build my git repo on external server?
If you can push to a bare repo on the build server, then you can associate to that bare repo a post-receive hook (.git/hooks/post-receive) which will:
checkout the code
#!/bin/sh
git --work-tree=/var/www/domain.com --git-dir=/var/repo/site.git checkout -f
trigger the compilation.
That way, you don't have to handle the diff yourself.
You only have to associate to the build button the action to push your branch to the bare repo of the build server, and the post-receive hook will do the rest.
You could switch to a forking Workflow, where each developer in the company has a personal public bare repo, which is a fork of the official central repository.
Then, when you want to build your changes, you push them to (a branch or the master of) your own personal public repo.
The build server not only clones the official central repository, but also your public repo. So when you push to your personal public repo, the build server merges the changes and does a personal build for you. Just like it probably already does for the official central repository?
Note that this is not too different from #VonC s answer, just focusses a bit more on the workflow. The personal public repo may well be on the build server, like #VonC suggests. Or it could be somewhere else. As long as it's some place public enough that the build server and you and your colleagues can find it.
Consider integrating http://jenkins-ci.org/ to your workflow, to take care of the build process, using a "git post-receive hook" to trigger the build as (suggested by #VonC).
If you want to use the "Forking Workflow" as suggested by #flup, you can take a look to http://gitlab.com which provides an easy way to manage pull/merge requests, fork repositories and to add hooks.

How to deploy branch specific code using GIT?

I am using separate servers for dev, test and production environments. I have git installed on my local machine and have separate branches for each environment. How can I deploy the code from each branch to its respective server using GIT?
FYI: GIT is not installed on server.
Thanks in advance.
Simrat
You should have git installed on server,
use the following command to push you code to your remote repository
git push remote_repository_url branch_name
use the following commands to fetch or deploy the code from remote repository to your corresponding machine .
git pull remote_repository_url branch_name
or
git fetch remote_repository_url branch_name
Use fetch command to avoid the merging
Even you can use git clone command to clone the specific branch from your remote_repository(assembla) to your corresponding server >
git clone --branch branch_name remote_repository_url