20160424 About This Technical Blog
Git Idea And Structure
How To Add Files
How To Commit Files
How To Get The History Of Commits
How To Create A Branch
How To Link A Local Repository With A Remote Server
How To Push Local Commits to The Remote Server
How To Update A Local Branch From The Remote Server
How To Merge A Branch X Into Y
How To Reset Commit/s
20160717 How To Create A Repository On A Synology Station
20160717 How To List The Git config
20160717 How To Auto Rebase Before Pull
To know why I write a blog about using Git, please read my blog post
Git is a version control system.
You have a local git server where you add local files to become git controlled.
Revisions of git controlled files are called commits.
To seperate changes of the same files in different revisions you create branches.
To store changes on a remote git server, the local git branch is updated to its corresponding branch on the remote git server.
Changes from the remote server are pulled, local changes from the local to the remote server are pushed.
Adding a file :
git add filename
Adding all files recursive down from the current directory :
git add .
git commit -m "commit comment"
git log
git checkout -b branchname
git update -u origin branchname
git push
git pull
git checkout X
git pull
git checkout Y
git merge X
git push
To see the commit history :
git log
To set the commit history 1 step back without changing the file content :
git reset HEAD~1
This works for every number of steps, e.g. reset the last 3 steps :
git reset HEAD~3
To reset the file content of a file after a commit has been reset :
git checkout path/filename
To reset the commit history and reset the file content 1 step back :
git reset --hard HEAD~1
Working with Git without a remote server is only half of the fun.
This is how I have set up my repository on my Synology station :
$ ssh 192.168.2.20
$ mkdir gitrepo
$ cd gitrepo
$ mkdir blog.git
$ cd blog.git
$ git init --bare --shared
$ chmod -R o+w blog.git
then I was able to clone it on my netbook :
$ git clone ssh://amos@192.168.2.20/volume1/homes/amos/gitrepo/blog.git
and I have configured a push strategy :
$ git config --global push.default matching
git config --list
There are two ways of how to pull changes from the server :
I prefer the first way.
The blog of Steven Harman explains it very good.
To configure the pull rebase to do it automatically, you have to :
git config --global pull.rebase true
The Blog
|
|
|
|
My Technical Blogs
|
|
|
|
|
|
|
|
|
|
|
|
Projects
|
|
|
|
Blogs Of Friends
|
|
|
|
|
|
CV/About
|
|
|