“Git基础及常用命令”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
docker>Evan
 
(导入1个版本)

2019年10月14日 (一) 13:48的版本

常用命令

日常使用

#日常用得最多就这几个了
git pull origin master
git add youfile 
git commit -m " "
git push origin master

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 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 


see also

GitLab使用教程

GIT 常用命令

Git & Gitlab 使用指南

GitLab的简单使用

Git完成HTTPS的自动账号密码填充

git clone代码提示需要输入密码

删除git中缓存的用户名和密码