how to sync data from local code to heroku git - node.js

I build some website using nodeJS that host on heroku. I am using the heroku CLI git. When i want to upload the files i am using the git add . after that git commit -am "some text" and git push heroku master.
The client is update his site and upload new images and content, and when i make some changes in the code and git it again all the work he is done is deleted from server (not from DB).
Add the images folder to the .gitignore file
How can i sync files and code with my local version before i push new version to the heroku server

when you do "git add ." you are telling git to overwrite all your files from git with code on you local.
if you have made changes in only specific files You should always add only those files when doing git add .
you can follow this steps.
git status -> this will show you list of files which are changes and umerged. get hold of file which you changed and want to add in git
Suppose its abc.html (copy full path of file shown in git status)
git add abc.html
git commit -m "some message"
(optional) git pull remote_branch current_branch (this will pull latest code of remote branch to your local). Sometimes you may get conflicts so go ahead open that file and resolve conflicts.
If you are alone working on branch you may not get any conflicts
git push current_branch remote_branch

Related

Uploading a directory full of files in GitLab

I can't find this topic in the documentation. I'm trying to upload a folder of files to GitLab - i.e. the file containing the entire webpage, (HTML files, assets, JS, etc.) In other words, I want to upload my entire repo to GitLab.
But, I only see the option to upload a single file at a time:
How can I upload a folder of files?
Folder upload is not supported as far as I know.
You could clone the project locally (blue button) creating a local repository and move/cope the folder to your local git-repository.
Then you just git add, git commit and git push everything.
Step by step:
Stage everything in git repo:
git add -A The parameter "-A" stands for "all", it will add every file and folder (apart for empty folders) that are in the repository to the commit.
git commit -m 'your message' will commit all your files/changes locally.
git push will upload your commits so that you can see them on your GitLab page.

Can't push local project to gitlab

i'm trying to push a local project to a gitlab repository. I followed the usual commands provided with each new Project. Everything worked just fine until the last command; I acctually dicovered the local project is being pushed to a gitlab project that I actually deleted.
And each time I create a new project and try to push to it, the files are directed to the one I deleted but is somehow re-created with every push.
Any thoughts?
Try reading the following guide. Although is for github, is almost identical for gitlab. (understanding git is the key). I think you need to re-formulate your question better:
You have the following remote: origin with path https://<your-gitlab-project-repo-path>.git. Then locally, you run:
cd your-project
git init .
git remote add origin https://<your-gitlab-project-repo-path>.git
git add .
git commit -m "initial commit"
git push origin master
Done.

How can I upload changes to my Gitlab repository?

I uploaded my files to gitlab. Now I've updated them and I also want to send the changes to gitlab, but this does not work at all because git always says that there are no changes.
To publish your local changes follow the 3 simple steps below:
git add <filename> or git add * to add everything
git commit -m "Enter e message here"
git push

How to add a git repository to Ubuntu server

I have a node.js project local in my computer, right now, I want to push this project to remote Ubuntu server. I have create a project.git on Ubuntu server, and pushed to it. Right now, I want to run this project on the server, but how do I access this folder, it's just a git directory. The process I am following is like below:
Ubuntu server:
mkdir /home/git/project
cd /home/git/project
git init
Local computer:
git remote add origin root#someserver.com:/home/git/project
git add .
git commit -am "Initial Commit"
git push origin master
It push succeed. Right now, I want to execute this node.js project and run it on the server, but how to turn this git repository to a folder, so I can cd into it and then node app.js after?
If you want to see the code on the server side, you should init the repository without --bare option or clone it somewhere else on the server.
Bare repositories store only git specific files.
UPDATE:
If you create a repository without --bare option, you can't push anything to that branch where your server is staying. Better solution is if you create a bare repository and clone it somewhere else on the server. Notice that, you should use there git pull command if you want to see your fresh code.

Git - Syncing a Github repo with a local one?

First off, forgive me if this is a duplicate question. I don't know anything but the basic terminology, and it's difficult to find an answer just using laymen's terms.
I made a project, and I made a repository on Github. I've been able to work with that and upload stuff to it for some time, on Windows. The Github Windows application is nice, but I wish there was a GUI for the Linux git.
I want to be able to download the source for this project, and be able to edit it on my Linux machine, and be able to do git commit -m 'durrhurr' and have it upload it to the master repository.
Forgive me if you've already done most of this:
The first step is to set up your ssh keys if you are trying to go through ssh, if you are going through https you can skip this step. Detailed instructions are provided at https://help.github.com/articles/generating-ssh-keys
The next step is to make a local clone of the repository. Using the command line it will be git clone <url> The url you should be able to find on your github page.
After that you should be able to commit and push over the command line using git commit -am "commit message" and git push
You can use SmartGit for a GUI for git on Linux: http://www.syntevo.com/smartgit/index.html
But learning git first on the command line is generally a good idea:
Below are some basic examples assuming you are only working from the master branch:
Example for starting a local repo based on what you have from github:
git clone https://github.com/sampson-chen/sack.git
To see the status of the repo, do:
git status
Example for syncing your local repo to more recent changes on github:
git pull
Example for adding new or modified files to a "stage" for commit
git add /path/file1 /path/file2
Think of the stage as the files that you explicitly tell git to keep track of for revision control. git will see the all the files in the repo (and changes to tracked files), but it will only do work on the files that you add to a stage to be committed.
Example for committing the files in your "stage"
git commit
Example for pushing your local repo (whatever you have committed to your local repo) to github
git push
What you need to do is clone your git repository. From terminal cd to the directory you want the project in and do
git clone https://github.com/[username]/[repository].git
Remember not to use sudo as you will mess up the remote permissions.
You then need to commit any changes locally, i.e your git commit -m and then you can do.
git push
This will update the remote repository.
Lastly if you need to update your local project cd to the required directory and then:
git pull
To start working on the project in linux, clone the repo to linux machine. Add the ssh public key to github. Add your username and email to git-config.
For GUI you can use gitg.
PS : Get used to git cli, It is worth to spend time on it.

Resources