Introduction & Working Directory :
Basically GIT is a remote repository which stored in a server and local repositories on the local system of each and every developer. We can say in the easy words the code is not just stored in a central server, but the full copy of code is available on the developer’s system.
Working Directory –
The working directory is the root directory where you have entire code that you want to manage with
A commit is set a message about the changes you have done in working directory, and it’s kept track of using a unique alphanumeric character. The commit also saves a revision of the code and you can revert the code to any version anytime.
The index is used as a staging area between your working branch to your repository. You can use index to build a set of code / changes into your file and further track them and commit all of them into the master.
A branch is the basic routine of your every day development. Git Branch always had a pointer or snapshot of your current changes. When you will create a new feature or fixing your bugs, you must need to create a new branch to push your code in the master branch.
Git Commands :
Execute Git Commands :
Set User Identity :
$ git config –global user.name “John Doe”
$ git config –global user.email email@example.com
Creating a repository :
$ git init
Cloning repository :
$ GIT CLONE HTTPS://GITHUB.COM/DBRGN/FAHRPLAN
Git Commands :
Add a new file - $ git add <File Path> Remove a new file - $ git rm <File Path> Commit file or code changes from local to stage - $ git commit -m 'Meaning Full Commit Message' Commit message change after commit and before push into the branch - $ git commit --amend Show logs / history of commits - $ git log Show commit - $ git show Show code changes in file - $ git diff <File Path>
How to Create Branch in Git ?
$ git checkout master $ git reset --hard origin/master ( Git Head set on the updated last commit ) $ git pull origin master $ git checkout -b ext_discriptive_name_of_the_card $ git push --set-upstream origin ext_discriptive_name_of_the_card Switch to a new branch - $ git checkout demo_new_branch Delete branch - $ git branch -d demo_new_branch
Code Merge & Resolve Conflicts –
git checkout <master Branch> git reset --hard HEAD^ git pull origin <master brach> git checkout <Into your working branch> git merge --no-ff origin/master git status git diff < File Name > git add < File Name > ( For Checking Auto Generated Commit Message ) git merge --continue git commit
( Without commit message “NOTE: While resolving conflict we will not use git commit -m “Commit Message”Standard resolved conflict message like –
** Merging remote-tracking branch ‘origin/master’ into < Branch Name > **
git push origin < Branch Name >
These are the basic commands to understand GIT, we will update some more tutorials and advanced GIT practices into our new blog. Please use this on your daily routine to avoid the basic mistakes on code deployment.