This blog is about the workflow of Git version control
You are welcomed to chat about it and if you like this blog, do not forget to give me a like.
Welcome to see my homepage and contact me: NicholasYe’s Homepage.
git clone {repo link} to download repo into local file, there are two kinds of links:
git@github.com:NicholasYe/xxxxxxxx.githttps://github.com/NicholasYe/xxxxxxxx.gitmastergit checkout -b {Branch_Name} to create a new branch
git checkout -b {Branch_Name} origin/{Branch_Name} to copy others branchgit add . to temporarily store your changesgit commit -m "{Comment}" to store your changes with some commentsgit push --set-upstream origin {Branch_Name} to push your local branch into remote branch origin/{Branch_Name}git push to push your branch into remote branchgithub.com and you can create your new branch into PRgit checkout master to change to your master branchgit pull to update your master branchgit checkout {Branch_Name} to change to your branchgit merge master to merge master branchgit add . and git commit -m "{Comment}" and git push to push your branchgit log to check your working historygit log --oneline to check your commit’s and comments in one linegit log --author={Author_Name} to check commit with specific authorgit log -p to see detail changes of each commitgit log --stat to see summary of each commitgit branch to check your local branchgit branch -r to check remote branchgit branch -a to check all the branchgit branch -D {Branch_Name} to delete one branchNotice: REVERT and RESET is totally different thing, be careful!
revert:
git revertwill only undo only changes associated with a specific commit.
reset:git resetwill undo every changes since a given commit occurred.
git revert {Commit_id} to revert changes of one commitgit revert HEAD~{Number} to revert to previous {number} commit. (I recommend you to use git log before to check where is HEAD now)git reset HEAD~{Number} to reset to previous {number} commit. (I recommend you to use git log before to check where is HEAD now)git reset --soft {Commit_id} to reset all to this commit, and all the changes is stored in staged changes, use git commit -m "{comment}"git reset --mixed {Commit_id} to reset all to this commit, and all the changes isn’t stored, use git add . and git commit -m "{comment}"git reset --hard {Commit_id} to reset all to this commit. (Be careful when you use this)Notice: With the
cherry-pickcommand, Git allows you to integrate selected, individual commits from any branch into your current HEAD branch.
git cherry-pick {Commit_id} to cherry-pick specific commit in your current HEAD branch.git cherry-pick {Commit_id} --no-commit to cherry-pick specific commit, then you need to use git commit -m {Comment} to commitPlease clearly mark the source of the article in the process of reproducing it! Respect for originality and intellectual property rights, thanks!