All cases
Configuring git user name of the mail
Simply download a warehouse
Will update the remote pulled local repository (does not affect the existing local submission)
The local modifications uploaded to the remote repository
Upload the local changes to remote repository, remote and local agreement
And initialize a new warehouse with native code
I do not want to sync certain files / folders
Create a temporary branch modification from the master, and then merged into the master branch
Delete all history warehouse, retaining only the current file
n times the information submitted commit before the amendment
Configuring git user name of the mail
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Simply download a warehouse
The most commonly used method
git clone https://github.com/xxx/xxx.git
Project too, I would like to quickly download, no history
git clone --depth 1 https://github.com/xxx/xxx.git
I want to quickly download a non-master branch
git clone --depth 1 https://github.com/xxx/xxx.git
cd xxx
git remote set-branches origin 'remote_branch_name'
git fetch --depth 1 origin remote_branch_name
git checkout remote_branch_name
Will update the remote pulled local repository (does not affect the existing local submission)
git pull origin master
The local modifications uploaded to the remote repository
git add .
git commit -m "提交说明"
git push origin master
Upload the local changes to remote repository, remote and local agreement
git add .
git commit -m "提交说明"
git pull origin master
git push origin master
And initialize a new warehouse with native code
First to github or other sites to create a new git repository, access to new warehouse address, similar to https://github.com/xxx/xxx.git
git init
git add -A
git commit -m "初始化代码"
git remote add origin https://github.com/xxx/xxx.git
git push -u origin master
I do not want to sync certain files / folders
Under the new root of the repository .gitignore
file
in which you want to ignore the written content, support files, folders, wildcards
target/
.idea/
*.log
somefile.txt
Create a temporary branch modification from the master, and then merged into the master branch
- Create a temporary branch
git checkout master git pull origin master git checkout -b tmp git push origin tmp # 在远程也创建临时分支 git branch --set-upstream-to=origin/tmp git pull origin tmp
- Use your favorite way to make modify the code in the process to commit code
git add . git commit -m "提交说明" git push origin tmp
- Finally merge branches tmp to master, and then delete the tmp
git checkout master git merge tmp git push origin master git branch -d tmp git push origin --delete tmp
Delete all history warehouse, retaining only the current file
git checkout --orphan lastest # 从0新建分支
git add -A # 添加所有当前文件到分支
git commit -m "init信息"
git branch -D master # 删除master分支
git branch -m master # 重命名当前分支为master
git push -f origin master # 强制提交到远程
n times the information submitted commit before the amendment
git rebase -i HEAD~n # 这里查看最近n次commit提交信息
# 然后进入编辑模式,将需要修改的commit那一行的pick修改为edit,保存退出
git commit --amend # 这会进入上面修改对应的commit提交信息
git rebase --continue # 回到正常状态