Setting up git for a project

Sat, 09/29/2018 - 13:19

Configure Git for local projects

First your info:

git config --global user.name "First Name Middle Name"
git config --global user.email "user.email@domain.com"

 

Change "Origin" of your git Repo

git remote rm origin
git remote add origin git@github.com:aplikacjainfo/proj1.git 
git config master.remote origin
git config master.merge refs/heads/master

 

Create a new repository

git clone git@gitlab.com:kowalick/personal-budget.git
cd personal-budget
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

 

How to delete multiples files in a repo

The way for editing or deleting multiple files is by working with a local repository. You would then be able to delete the files in your local clone, commit that change to your local repository, and then push that change to the remote repository.

git checkout master
git rm -r folder-name
git commit -m "Remove duplicated directory"
git push origin master

 

Existing folder

cd existing_folder
git init
git remote add origin git@gitlab.com:kowalick/personal-budget.git
git add .
git commit -m "Initial commit"
git push -u origin master

 

Existing Git repository

cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.com:kowalick/personal-budget.git
git push -u origin --all
git push -u origin --tags

 

Cloning an existing repo

When a repo is cloned it is not necessary to execute the command "git init", the git files come inside the folder that creates the command when you are cloning the repo. The ".git" folder exists inside the project folder

 

Errors in Git

Sometimes errors just happens, you really can't do anything for avoid it, here a list of common error and how you can fix it:

 

No Error Message Error Solution
1 error: Your local changes to the following files would be overwritten by checkout:
        docroot/.htaccess
Please commit your changes or stash them before you switch branches.

Reset the git repo with this command: 

using git reset --hard
 

     

https://stackoverflow.com/questions/15745045/how-do-i-resolve-git-saying...

using git reset --hard
 

Mexico City

Today, November 20, 2018
Sunrise: 06:48
Sunset: 17:57
06:00-12:00

Partly cloudy

Partly cloudy
48 °F / 9 °C

QR CODE

QR CODE