• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

aboelkassem/Git: explaintion and summery for fundamentals git and how it's w ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

aboelkassem/Git

开源软件地址:

https://github.com/aboelkassem/Git

开源编程语言:


开源软件介绍:

Git

Build Status

The Content

What is Git?

Version Control System
  • Software designed to record changes to files over time
  • Ability to revert back to previous file version or project version
  • Compare changes made to files from one version to another
  • Version control any plain text file not just source code

Three Stages of a File

  • Committed mean that files is stored safely in repo of the project
  • Modified when make changes in last commit, just introduced new changes but has committed them yet
  • Staged when changes finished and ready to commit.

Three States of git project

Command Line

github-git-cheat-sheet.pdf

git-docs-all-commends

Tracked files by git has three stages

  • Committed Unmodified changes from the last commit snapshot, when make changes to these files content then moved to modified stage
  • Modified Changes made to files since last commit snapshot, when you satisfied with changes and stage them for commit will move to staged area
  • Staged Changes marked to be added into the next commit snapshot, now can commit it to origin repositories

Untracked Files

mean that git sees a new file that didn't exist in her last commit. and add them to stage are to be ready to commit

$ git status
$ git status --short

This commend show the status of tracked and untracked files for your local and remote origin repository

$ git diff
$ git diff --staged

this commend answer the following two questions

1- What changes have I staged that are ready to be committed?

2- What changes have I made but not yet staged?

Push committed changes to Origin Master branch

After Commit push these files from local project to remote origin repository on github

$ git push origin master
$ touch <file_name> # create a new file

Track commits and see the history of previous commits

$ git log
$ git log -1
$ git log --oneline
$ git log --stat
$ git log --patch

Commit Message

There are guidelines are followed to commit message to be useful and helpful to other contributors there are blog that had a lot of information about these seven rules in this blog

1- Separate subject from body with a blank line 2- Limit the subject line to 50 characters 3- Capitalize the subject line 4- Do not end the subject line with a period 5- Use the imperative mood in the subject line 6- Wrap the body at 72 characters 7- Use the body to explain what and why vs. how

Remove and Move Files

$ git rm <file-name> # remove file from project and git untracks it
$ git rm --cached <file-name> # only git untracks it but keeping in local repo
$ git mv <old-file-name> <new-name> # to rename file
$ git reset head <file-name> # to stop tracking this file

Branches

branches to organize your code to adding new features or working separately from base code and merge this after finishing or creating pull request. especially working with multiple collaborators to get a copy of version and work in it and merge it This tool is animate to understanding branching in git

$ git checkout <name-of-new-branche> # working/switching on new_branch and commit to it
$ git checkout -b <name-of-new-branch> # creating and working/switching on new_branch and commit to it
$ git checkout master # working/switching in master brance
$ git branch # list of branches do you have
$ git branch <name-of-branche> # create new branch but don't switch to it (checkout)
$ git branch -m <old-name> <new-name> # rename a branch
$ git branch -d <branch-name> # delete a branch
$ git branch -D <branch-name> # Force delete a branch if this branch have commits do not merged yet

Merge

merge command it to merge branches with all it's commits and working files to master branch. if you are contributor you can make branches and working at them and merge them as pull request to your master branch and send it to origin master branch as also pull request to be merged

Git stash

git stash temporarily shelves (or stashes) changes you've made to your working copy. The git stash command takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy

$ git stash # saving our working directory and staging area as a secert box
$ git stash list # get list a stashes or progress chages that we've stashed
$ git stash pop # get the chages/files from stash to dropped back into his working directory

Git reset

git reset allow us move commits from history back into our working or staging area

$ git reset --soft <head-of-commit>
$ git reset --mixed <head-of-commit>
$ git reset --hard <head-of-commit>



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap