How i can overwrite changes on this file? - linux

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

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

git push hangs weird

When I want to push new contents to my Github, I used
git push
or
git pull
It's not working, like this but I used it successfully one hour before.
So I tried
git push origin master
Now it's success, magic.
But I don't know why about it, and how I need to do to go back that just needs input 2 words.
I tried
git config --global sendpack.sidehand false
Thanks in advance.
Add:
git push -u origin master
told me "Branch master set up to track remote branch master from origin"
I know that's right, but git push still can't work as expected
The configuration you mentioned is unrelated to your problem (you should probably undo that). If you want to set up the master branch on the origin remote repository as the default branch to push to from your current branch, run once
git push -u origin master
# or
git push --set-upstream origin master
and then use just git push afterwards.

Gitlab how to pull down current code on master to the local branch

How does one get the code from the master to the local branch called "mybranch" so the local branch has the latest code? Assume local branch did not have code changed since it was created from master and now it is few versions behind the master.
I've ran the following commands, which pulled the latest changes from master.
git checkout mybranch
git pull origin master
You can do that with
git fetch upstream
git merge upstream/master
Assuming that you are on your local branch.
source
checkout to your branch:
git checkout mybranch
then update master and rebase your branch.
git pull --rebase origin master
this is in case you don't mind rebasing and also updating master.
You could also not rebase (say, if mybranch is in the remote and you don't want to remove it to be able to push later) and just merge with
git pull origin master

git repo issue related puppet

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

'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