Git is the most useful tool for developers but if someone does not use it for a while, it all seems confusing. Git is tricky. Here are some of the most commonly used command.
$sudo apt-get install git
Create new git repository
Create git repository on server
$git init --bare
Please note the difference : A bare repository is a git repository without a working copy, therefore the content of .git is top-level for that directory.
Use a non-bare repository to work locally and a bare repository as a central server/hub For example, when you create a repository on github.com, it is created as a bare repository.
To conclude, the repository on the server side is going to get commits via pull and push, and not by you editing files and then committing them in the server machine, therefore it is a bare repository.
You can push your changes from local to remote by using following command
$git remote add live ssh://firstname.lastname@example.org/var/www/foldername
once this is added you can check all remotes using following command
$ git remote -v live ssh://email@example.com/var/www/foldername (fetch) live ssh://firstname.lastname@example.org/var/www/foldername (push)
Deploying the changes.
Once your changes are ready, you can deploy it using following commands
git add . git commit -m "commit comment" git push live master
Copy remote repository to your local folder.
$git clone ssh://abc...xyz.git/
To get list of files changed in directory
$ git status On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: MySQL/MySQL_Select.py Untracked files: (use "git add <file>..." to include in what will be committed) MS Excels/xlsx_read_into_pandas.py MySQL/MySQL_update.py image/ no changes added to commit (use "git add" and/or "git commit -a")
Get commit history