In this section we are going to learn the following
- What is repository and Git Vs SVN
- Key terms to understand about Git
- Installing and documentation
- Basic git command line fundamental
- How to Add,Commit,Push , create Branch and merge with master repository
The purpose of git is to keep/store and manage the set of file or your project as you can modify your project files that can be committed to git and git keep/store the information about the modified,added,deleted,committed and branch information for better tracing this is called Repository
Repository is main place to store your project called (master) form the master you can create number of branches and as many developer can work on different branch and commit and push their changes to master going.
Key Terms
- MASTER – this is the main repository for your project
- BRANCH – this is child branch of the master
- STAGING – Staging is a step before the commit process in git mean if you where create new files that need to be add into staging and then can able to commit.
- ADD – If you are created new files that need to be add before commit
- COMMIT – Commit your changes to local repository not in
- MASTER in order to move to master we need to push
- PUSH – push your changes to local repository to master
- MERGE – AS many developer can work in different branch and that all together or individual branch can be merge to master but once merge the branch we need to push to master.
- CLONE – you can get the local copy of the remote repository by giving the remote repository URL
- FORK – This is not git concept and it’s like social media idea people can simply take the source code and work on it themselves separate from the original developers. That would be considered a fork
- CHECKOUT – Master repository can have multiple branch repository and if you want to switch from one branch to other branch or master you can simply switch the working repository as current working repository
Git vs SVN
Both are version control system
SVN is central version control system where all master repository can have version control all other developer can clone the specific version and can work them self but must have right access to each version.
GIT is distributed version control system which mean when you clone the remote repository you can get all the files available from master repository mean all developer can have whole copy of the master so that it will be better sync we don’t need to wait for the access more..
Installation and document
You can simply download and install the git from official website and get the document too…
okay now let’s assume we are clear on basic idea about git and let see command line fundamentals now
- git –version // check the installed git version
- git config global user.name // basic global configuration for track who done the changes and what
- git config global user.email // basic global configuration for track who done the changes and what
- git config –list // list the global configuration details
- git help // you can see the documentation for each command
- git help <key> // show the documentation for specific command
- git init // If you want to track the project you can use this and this will create .git folder and you can get green or red color icon in each folder green means it’s sync with remote repository and red indicate you there is some difference between your local and remote repository simply can say you have modified,deleted or added new files or folder.
- rm -rf .git // If you don’t want to track the project changes you can remove the .git folder
- git status // show the status of current activity like edit,create,delete and files or commit,push,merge and create branch…etc also be aware that before commit the files we need to run this comment to know is there any changes in the remote repository to avoid conflict
- touch .gitignore // ignore list of files that we don’t want to commit to repository and we can specify the list of files to be ignore in the .gitignore file
- git add -A //add all newly created files to staging then we can commit to local repository then push to remote repository
- git add . // Add all files to staging
- git add <file name> add specific file to staging
- git rm — cached // to revert the added files from staging
- git reset // revert all added files from staging
- git reset <file name> // revert the specific added file from staging
- git commit // commit the changes without giving message(Message about changes you have done)
- git commit -m “Your message goes here” //commit with message
- git log // show the log about the commits
- git clone // Clone the remote repository
- git remote -v // show the information about remote repository
- git branch -a<branch name> //create branch from master repository
- git branch -b // show the list of branch of master
- git branch -merged // merge all the branch to master
- git merge <branch> // merge the specific branch to master
- git branch -d <branch name> //delete the branch from master
- git push origin –delete <branch name> // once delete the branch then push to master to get reflected.
- git diff // show the change difference beet ween your local and remote repository
- git pull origin master // pull the latest code from master repository
- git push origin master // push the changes to master
- git checkout <branch name> switch the working directory
Yeah! let’s assume we have understand the most of things about git Thank you! for reading.