git repo issue related puppet - linux

I am new in git world and recently i have started deploying puppet. I am planing to put puppet in git version control. I am following cookbook of puppet and doing following
root#cookbook:/etc/puppet# git init
Initialized empty Git repository in /etc/puppet/.git/
root#cookbook:/etc/puppet# git add manifests/ modules/
root#cookbook:/etc/puppet# git commit -m "initial commit"
[master (root-commit) c7a24cf] initial commit
59 files changed, 1790 insertions(+), 0 deletions(-)
create mode 100644 manifests/site.pp
create mode 100644 manifests/utils.pp
When i am running following command i got this error. what is command going to do??
root#cookbook:/etc/puppet# git push -u origin master
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
how do i connect to git and checkout my repo on my client or somewhere else?

You have to tell git where the remote repository is located:
git remote add origin <url-of-remote>
Edit: origin is simply a conventional name of your main remote, much like master is for your main branch.

If you have done a git init in the /etc/puppet folder it is already 'origin' and you don't have to push.
I think you just wanted to add the files to the master branch. You already did this with your commit. Try git log

Related

Push from Azure repository to cpanel private repository

I'm trying to find a way to use a pipeline to push the Azure repository to another repository on my cpanel server. At the moment I'm just transfering the files over FTP but I need a proper push to activate autodeploy on cpanel repo.
Many thanks to anyone that can help.
This process would be the same the way to commit changes to a git repository.
Initialize a git repository add the data in the staging area commit changes to local git repository then push the changes to remote git repository. The process isn't different from the normal local machine one.
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin <azure repo url >
git push -u origin main

How i can overwrite changes on this file?

I am trying to deploy my Laravel project on my live server, but i have a problem with composer.json file
no#zz8807:/var/www/html$ sudo git pull origin master
Username for 'https://github.com': whiteG9291
Password for 'https://whiteG9291#github.com':
From https://github.com/aekraes/zuxweb
* branch master -> FETCH_HEAD
Updating b19275b..4127e3a
error: Your local changes to the following files would be overwritten
by merge:
composer.json
Please commit your changes or stash them before you merge.
Aborting
this is the error I get.
Notice: I have deployed this before and it worked successfully, but I have done some changes on composer.json permissions
You cannot take a pull with uncommitted changes, so to pull changes with some local uncommitted changes you have two option ->
Stash your changes
commit your changes
Stash changes
git stash
git pull origin master
If you pop your stashed changes now, you can merge with the pulled changes,
git stash apply
Commit changes
git add composer.json
git commit -m "updated composer"
git pull origin master
Now you will to merge the data which came from the origin with your local.
After merge in both cases commit your merged changes,
git add composer.json
git commit -m "merged"
git push origin master
If you want to keep your local changes then commit them to your git repo:
git add composer.json
git commit -m 'your message'
git push
If you don't want to keep your changes to composer.json, just stash them on the stack and never fetch them down, then you can pull from master
git stash
git pull origin master

Undo user delation and removal of his project

In our own Gitlab server, I accidentally removed the default admin, and the previous repo created by this default admin, is also gone.
How to recover the missing repo?
Following merlin2011's suggestion, I finally cloned my local copy to the gitlab server:
git remote -v // list all remote repo
git add repo 192.168.1.xxx //our local git server
git push -u repo master
git remote remove repo
git add origin 192.168.1.xxx

Uploading code in Gitorious

I created an account in Gitorious and I want to upload code from my computer, but I don't know how to do it. Searching in internet I realized that I can't watch the menu to upload code from the dashboard.
I created the public SSH Key and I created a project and a repository. How can I upload the code from my computer?
Thanks.
The answer :
add new project and new repo on gitorious
on your local disc in program directory :
git init
git add .
git commit -m " name "
git remote add origin git#gitorious.org:my-project-name/my-git-repo.git
git push origin master
If you will have error :
fatal: remote origin already exists.
then :
git remote rm origin
git remote add origin git#gitorious.org:my-project-name/my-git-repo.git
git push origin master
It is based on :
faq - How do I point my local Git repository at Gitorious?
Creating a new git repository in Gitorious by kosmas
Getting started with Git and Gitorious by sagarun

'Your branch is ahead of 'origin/master' by 1 commit.' after merge

I have done the following:
git add <filenames>
git commit
git push origin master:mybranch
From my origin server, I did the following:
git merge mybranch
All of my changes are now present on the origin server, however git (and myself) seems incredibly confused now. When I did a git status on the origin, two of the new files I added were present, but listed as untracked files. However, the modified files are not listed as modified.
When I do a git status on my remote server I receive the error Your branch is ahead of 'origin/master' by 1 commit.
When I do a git diff origin/master on my remote server all of my changes are listed as not present on the origin server.
What is going on here?
do a git pull in your master and then merge again
Which branch are you currently on?
usually this is how it goes:
git checkout somebranch
*make some changes
git add *any new files here*
git commit -am "commit message"
git checkout master
git pull origin master
git merge somebranch
git push
if the master-branch had any changes in it when you pulled you will need to merge those changes over to your working branch.
git checkout somebranch
git merge master
you have only pushed the mybranch to your remote. This is why after you merge it into master on the remote you get a "ahead by 1" message. This is not an error.
Do a git fetch and you will have the latest in sync.
Sounds like you don't understand how Git's history structure is built. Google for "git for computer scientists" to get a quick overview, or spend some time reading progit.org/book.

Resources