Nethence Newdoc Olddoc Lab Your IP BBDock  

setting up & operating GIT repositories

basic setup

cd git_repo/
git config
git config "your name"
git config
git config "your@email"
git config --global push.default simple
git config --global core.editor vim


alternate way,

git config --global --edit
#git commit --amend --reset-author

create simple local repo

    cd somefolder/
    git init

basic usage

review the files that have been changed and commit,

git status
git commit -a

review what is going to be pushed and push,

git diff --stat --cached origin/master
git push

create real (bare) repo that will be used remotely only

as git user on the GIT server,

    mkdir project.git/
    cd project.git/
    git init --bare

using Github

Quoting Github’s repo startup doc,

echo "# doc" >>
git init
git add
git commit -m "first commit"
git remote add origin
git push -u origin master

…or push an existing repository from the command line

git remote add origin
git push -u origin master

Once your repo is up and running you can then fetch it using git-clone e.g.,

#git clone
git clone ssh://
#git clone

fetch a remote repo

from a workstation or some server,

    git clone ssh://git@gitsrv/home/git/project.git

and if you are using Github or Gitlab, HTTP(S) is also available,

git clone
    git clone http://git@gitsrv/home/git/project.git

fix commit message(s)


push to a remote repo after you started already

you can also create your own,

    cd project/
    git init
    git add *
    #git add --all
    git commit -m MESSAGE

and sync with the remote repo afterwards,

    git remote add origin ssh://git@gitsrv/home/git/project.git
    #git config --global push.default simple
    git push
    #git push --set-upstream origin master

create your own branch

first, choose the branch you want to pick from,

    git checkout release-1

then create yours,

    git branch release-1-with-my-feature
    git checkout release-1-with-my-feature

finally commit and eventually push your changes.

merge changes

create a minor branch against release v1 for you and others to commit,

    git checkout release-1
    git branch release-1.1.0
    git checkout release-1.1.0

merge your changes into the new minor branch,

    git merge release-1-with-my-feature

Note. merge --no-ff if you like.

deploy apps

update the list of branches and switch to the new minor branch,

    git fetch -a
    git checkout release-1.1.0
    #git pull

and restart the application.


to loose track of a git folder and work on it without commiting the changes,

cd git_repo/
git rm -r --cached folder/
git commit -m "Removed folder from repository"
git push origin master


on Github you may check your SSH keys' by fingerprint,

ssh-keygen -E md5 -lf ~/.ssh/

handy tweaks

for docs, scripts & configs you do not want to track like hell,

    git config --global 'commit -a --allow-empty-message -m ""'


If you got this error,

error: Pull is not possible because you have unmerged files.

==> edit the file to proceed with the manual merge (see >>>>> lines…) and then,

git add merged_manually_file
git commit -m "manually merged"


Home | GitHub | Donate | Feedback