“Git基础及常用命令”的版本间的差异
跳到导航
跳到搜索
第68行: | 第68行: | ||
git config --global user.email "[email protected]" | git config --global user.email "[email protected]" | ||
</pre> | </pre> | ||
+ | |||
+ | |||
+ | |||
+ | =git 基础安装使用= | ||
+ | <pre> | ||
+ | |||
+ | 服务器上 | ||
+ | |||
+ | apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \ | ||
+ | libz-dev libssl-dev | ||
+ | |||
+ | apt-get install git | ||
+ | |||
+ | git --version | ||
+ | git version 2.20.1 | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | 使用我们指定目录作为Git仓库。 | ||
+ | |||
+ | git init newrepo | ||
+ | useradd git #也可以让这个用户不可以登录,为了安全嘛 | ||
+ | |||
+ | chown -R git.git /data/newrepo/.git/ | ||
+ | |||
+ | mkdir /home/git/.ssh -p | ||
+ | cp /root/.ssh/authorized_keys /home/git/.ssh/ | ||
+ | |||
+ | chown -R git.git /home/git/.ssh/authorized_keys | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | client | ||
+ | |||
+ | |||
+ | ssh -T git账号名@服务器IP #客户端验证连接 | ||
+ | |||
+ | |||
+ | #可以的 | ||
+ | git clone [email protected]:/data/newrepo/ | ||
+ | 正克隆到 'newrepo'... | ||
+ | warning: 您似乎克隆了一个空仓库。 | ||
+ | |||
+ | |||
+ | #配置 | ||
+ | git config --global user.name "evan886" | ||
+ | git config --global user.email "[email protected]" | ||
+ | |||
+ | |||
+ | |||
+ | git clone [email protected]:/newrepo/git.git | ||
+ | |||
+ | |||
+ | |||
+ | git config --global user.name "evan886" | ||
+ | git config --global user.email "[email protected]" | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | |||
+ | [https://blog.csdn.net/qq_33598419/article/details/94392074?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param | ||
+ | 使用Git搭建自己的私有/个人Git仓库 | ||
+ | ] | ||
+ | |||
+ | http://blog.linuxchina.net/2015/06/18/how-to-use-git-%e8%bd%ac/ | ||
+ | |||
+ | |||
+ | |||
=git usage on win= | =git usage on win= |
2020年9月3日 (四) 12:06的版本
目录
常用命令
日常使用
#日常用得最多就这几个了 git pull origin master git add youfile git commit -m " " git push origin master 有时提交不成 冲突了 请用 git rm -f filename …or create a new repository on the command line echo "# learn-english" >> README.md git init git add README.md git commit -m "first commit" git remote add origin [email protected]:evan886/learn-english.git git push -u origin master …or push an existing repository from the command line git remote add origin [email protected]:evan886/learn-english.git git push -u origin master
打标签
在Git中打标签非常简单,首先,切换到需要打标签的分支上: $ git branch * dev master $ git checkout master Switched to branch 'master' 然后,敲命令git tag <name>就可以打一个新标签: $ git tag v1.0 可以用命令git tag查看所有标签: $ git tag v1.0
git将本地代码提交到远程仓库
#以我的i3wm配置文件作例子 # create a new repository on the command line echo "# myi3" >> README.md git init git add README.md git commit -m "first commit" git remote add origin [email protected]:evan886/myi3.git git push -u origin master
git分支的合并
在git中,可以使用git merge 和git rebase两个命令来进行分支的合并
usage first
添加key后 #配置 git config --global user.name "evan886" git config --global user.email "[email protected]"
git 基础安装使用
服务器上 apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \ libz-dev libssl-dev apt-get install git git --version git version 2.20.1 使用我们指定目录作为Git仓库。 git init newrepo useradd git #也可以让这个用户不可以登录,为了安全嘛 chown -R git.git /data/newrepo/.git/ mkdir /home/git/.ssh -p cp /root/.ssh/authorized_keys /home/git/.ssh/ chown -R git.git /home/git/.ssh/authorized_keys client ssh -T git账号名@服务器IP #客户端验证连接 #可以的 git clone [email protected]:/data/newrepo/ 正克隆到 'newrepo'... warning: 您似乎克隆了一个空仓库。 #配置 git config --global user.name "evan886" git config --global user.email "[email protected]" git clone [email protected]:/newrepo/git.git git config --global user.name "evan886" git config --global user.email "[email protected]"
http://blog.linuxchina.net/2015/06/18/how-to-use-git-%e8%bd%ac/
git usage on win
#git init git config --global --edit 配置为你的用户和用户名 # This is Git's per-user configuration file. [user] # Please adapt and uncomment the following lines: name = evan email = [email protected] After doing this, you may fix the identity used for this commit with: git commit --amend --reset-author 日常用得最多就这几个了 git pull origin master git add youfile git commit -m " " git push origin master [Win-1.lxtx_fengjw] ➤ git push Username for 'http://gitlab.net': Password for 'http://[email protected]': To http://gitlab.net/lxtx-backend-docs/docs.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'http://gitlab.net/lxtx-backend-docs/docs.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Git自动账号密码填充
1、每次操作都需要输入用户名和密码感觉很繁琐,解决方法,在本地的工程文件夹的.git下打开config文件添加: [credential] helper = store或者在git bash 中执行 git config --global credential.helper store再输入一次用户名密码后就可以保存住了。 2、不行就用以下方法: 先用Git拉一次东西,拉的时候会提醒你输入帐号的密码 输入正确的帐号和密码后,等东西拉完以后输入 git config --global credential.helper store #这样只针对单个project [remote "origin"] url = http://huangweiqing:[email protected]/zt_tech/_interface.git