当一个项目开发时间稍长,可能自己写的代码早都忘记当时为什么要那样写;或者迭代次数太多,忘记上一次都改动到了哪里,想要恢复到过去某个功能时,可能已经无从找起。
也许很多人会像我早期一样,存多个版本,加上日期,加上说明,文件名就一长串。然而时间长了、文件多了问题还是差不多,一样头疼。
版本管理软件正是这种情况的大救星。Git是个著名的分布式版本管理软件,开源免费;作者是大名鼎鼎、写Linux系统的那家伙。前不久被微软75亿美金收购的Github也是基于它建立。
作为TA在公司内部使用,Git其实蛮简单的,哪怕是通过命令行使用。
搭建好后常用的命令也就这么几个(后三个):
git clone, git pull, git status, git add -A, git commit -m “msg”, git push
很少对吧,稍微花点时间大胆试几次就会了,得到的收获却是不小。
也可以跑到github上注册个用户,创建个库,clone到本地练练手。
说到github,前不久发生个有趣的事情:我改了下帐号的个人信息,上传了公众号二维码作为头像,个人说明中也写有公众号等信息...结果第二天别人访问不了了,但我自己能访问,就像免费搞了个私有库一样!后来写邮件询问官方,到底哪里违规了,得到的答复是可能他们的检测系统有bug,然后给我解除了屏蔽^)^
不会使用命令行的话,github有GUI版本,也挺好用的。我一般在命令行下使用,装GUI版本后发现它还是有个方便的点:
就是有多个github帐号的话,命令行下配置挺麻烦,GUI版本就方便多了。
也可以命令行下用一个常用的帐号,GUI下用另一个帐号,二种共存。
git的教程网上很多,入门简单看几页官方那个教程就行。
这里只是做个备忘,简单记录在Linux(CentOS)上创建git server以及建立代码库、命令行下日常怎么使用。
官网软件下载、相关教程文档:https://git-scm.com/
中文教程: https://git-scm.com/book/zh/v2
以下都是实际操作的简单备份:
1. install CentOS-mini (CentOS-7-x86_64-Minimal-1611)
2.ip addr / remote login
3.yum -y update
4.yum -y wget
5.cd /home
6.wget https://github.com/git/git/archive/v2.14.1.tar.gz ; #https://github.com/git/git/releases
7.mv v2.14.1.tar.gz git-v2.14.1.tar.gz
8.tar -zxf git-v2.14.1.tar.gz
9.yum clean all
10.yum -y groupinstall "Development Tools"
11.yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc xmlto docbook2x perl-ExtUtils-MakeMaker
12. make configure
13. ./configure --prefix=/usr/
14.make install install-doc install-html install-info
15.git --version
16.groupadd dev
17.useradd -g dev -G dev liyajun
18.passwd liyajun
19.cd /
20.mkdir git
21.chown -R root:dev git/
22.chmod -R 771 git/
--local prepare
Git Bash:
1.cd /d/git
2.git clone --bare mayaProgramming/ mayaProgramming.git
3.cd /d/software/putty
4. ./pscp.exe -r -v -pw *** /d/git/mayaProgramming.git root@192.168.1.3:/git
--local testing
5. cd /f
6.mkdir git-testing
7.cd git-testing
8.git clone ssh://liyajun@192.168.1.3/git/mayaProgramming.git mayaProgramming
9.cd mayaProgramming/
10.git status
11.git remote -v
#origin ssh://liyajun@192.168.1.3/git/mayaProgramming.git (fetch)
#origin ssh://liyajun@192.168.1.3/git/mayaProgramming.git (push)
1.download, install:
https://git-scm.com/downloads
2.run Git Bash:
git config --global user.name=iJasonLee
git config --global user.email=kingmax_res@163.com
3.make local repository:
cd /d
mkdir -p git/myCode
cd git/myCode
git init
# Initialized empty Git repository in D:/git/myCode/.git/
git status
# On branch master
# Initial commit
# nothing to commit (create/copy files and use "git add" to track)
4.coding, using git:
touch .gitignore
vim .gitignore
#insert *.mse, *.pyc, *.zip, .... :wq!
vim hi.py
#insert print('Hi, Welcome to git ') :wq!
git status
git add -A
git commit -a -m "init repo, very first testing"
git status
git log
5.last, if you have a git server, you can push it:
git remote add <name> <url>
git push <name>
最后顺便在这回复个留言,“没有在PyCharm中找到MayaCharm”的:
按上图箭头所示顺藤摸瓜就行,如果还没找到,这个插件github链接在这里:
https://github.com/cmcpasserby/MayaCharm
不光有这个,for 3dsMax的也有人弄了个,不确定好不好用了: