git-rebase
reapply all commits from your branch to the TOP of another branch. It will sequentially take all the commmits from the branch you're in, and reapply them to the destination branch. Git-rebase does not destroy the old ones.
read more git-rebase golden rule
- https://github.com/webpro/awesome-dotfiles
- https://github.com/twpayne/chezmoi
- https://github.com/robbyrussell/oh-my-zsh
user]
name = Xun Zhou
email = xun.zhou@lidl.com
[core]
autocrlf = input
excludesfile = ~/.gitignore
[diff]
tool = icdiff
[difftool]
prompt = false
[difftool "icdiff"]
cmd = /usr/local/bin/icdiff --line-numbers $LOCAL $REMOTE
[icdiff]
options = --highlight --line-numbers
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
git rebase origin/develop
# in the branch which you wanna rename
git branch -m new_branch_name
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:alexpchin/<reponame>.git
git push -u origin master
git remote add origin git@github.com:alexpchin/<reponame>.git
git push -u origin master
Use git rebase
- Use
git stash
to store the changes you want to add. - Use
git rebase -i HEAD~10
(or whatever you need to see far enough back). - Mark the commit for
edit
by changing the wordpick
at the start of the line into edit. Don't delete the other lines as that would delete the commits. - Save the rebase file, and git will drop back to the shell and wait for you to fix that commit.
- Pop the stash by using
git stash pop
- Add your file with
git add .
- Amend the commit with
git commit --amend
- Do a
git rebase --continue
which will rewrite the rest of your commits against the new one
- project: Project configs are only available for the current project and stored in .git/config in the project's directory.
- global: Global configs are available for all projects for the current user and stored in ~/.gitconfig.
- system: System configs are available for all the users/projects and stored in /etc/gitconfig.
Create a project specific config, you have to execute this under the project's directory.
$ git config user.name "John Doe"
Create a global config
$ git config --global user.name "John Doe"
Create a system config
$ git config --system user.name "John Doe"`
# git Vim conflict
git config --global core.editor /usr/bin/vim
# updated local branches with remote branches
git remote prune origin
# push local feature/ci to remote server
git push -u origin feature/ci
# replace master with develop
git checkout develop && git pull
git merge -s ours master
git checkout master
git merge develop && git push
# ammend commit without edit msg
git commit --amend --no-edit
也就是把所有的改动都重新放回工作区,并清空所有的commit,这样就可以重新提交第一个commit了
git update-ref -d HEAD
git checkout -
git checkout A
git add foo.txt
git commit -m 'added foo.txt' # c8cad1e21f54a2dd3efaae4a92c8affd8aa99999
git checkout develop
git cherry-pick c8cad1e21f54a2dd3efaae4a92c8affd8aa99999