Background : To clone a git project Error : Solution :git config --global http.sslVerify false
To start a git project, it is better to know some useful commands in order to understand how it works. This article allows me to memory some useful git commands.
I suppose there is aleready a git remote repository (something like github, bitbuckets, gitlab etc.) and already done “git init” in local directory.
So let’s begin.
Two things we have to consider :
# git branch
* master
another_branch
Git diff command allows to list the different files between the two branchs
# git diff –name-status master..another_branch
Issue when execute git diff command on a file and got :
diff --git a/your_file b/your_file old mode 100644 new mode 100755
If you see this, it is because the permissions of your_file has changed.
For information, the unix file permission mode(644=rw_r__r__ which means read and write for user, only read for group and only read for others, the same for 755=rwxrw_rw_, x for executable).
To disable the comparaison of file mode, the command to execute :
git config core.filemode false
This article is not a tutorial of git command, there are already so many articles explained the usage of git.
So it is only a sticky note for me, only !
To pull a project, the command is pull or fetch, and to override local change, the option is –hard.
Command :
git fetch --all
git reset --hard origin/master
Background : Add an existing local project to github repository.
添加本地项目到github上
Although the github’s helping article Adding an existing project to GitHub using the command line is very complete, but it existing alwarys some errors.
And I will try to add some chinese translation some command just for understanding.
So the mainly procedure is 主要过程:
1. Create a new repository on GitHub.
现在github上创建一个仓库,说白了就是创建一个项目。
2. Initialize the local directory as a Git repository.
初始化本地项目。
git init
3. Add the files in your new local repository.
添加项目到本地仓库里。在没跟github上项目合并之前,本地和远程的算是相对独立的。
git add .
4. Commit the files that you’ve staged in your local repository.
提交项目到本地仓库。
git commit -m 'The comment for your commit'
One thing you have to know here is that, commit is just record your local changes to the project, but the changes hasn’t been combined with your remote project.
就跟刚才强调的一样,我们只是把项目提交到了本地的仓库里,这个时候它还没有被合并到远程项目里,所以如果你试着刷新一下github上的页面,会发现什么都没变。
Continue reading