GIT Basics

0 comments

                                          GIT Basics



Git  is a widely used source code management system for software development. It is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows.

Today I will provide you some handful commands that will
help you to work faster. I will also explain the workflow of GIT architecture and some useful diagram which may help you.




Git Architecture 

Follow the diagram along with the details given below

working directory -----staging area -----.git directory ----Remote repository.
  
when you add file it will be in the staging area but after commit it will move to remote repository.

GIT Commands

01. git status               :-- to track the changed file

02. git checkout -- filename :-- To clear your change and last file will remain to the build 

03. git clean  -fdx          :-- if checkout wont work then user this command .

04. gitk                     :-- to check the UI part it will provide you UI to check the branches and its modification

05. git clone <url>          :-- open cmd and got to the path where we want crm code and type this command.

06. git branch               :-- will give a list of all branches that have been checked you locally before.

07. git branch -a            :-- will give you a list of branches.

08. git checkout -b <topicBranchName> :- to create a topic branch, first go to parent branch 

09. git add <file>    :- include that file (stage) but not to git repository

10. git add .         :- include all the changes, but does not remove deleted files 

11. git add -u .      :- include only modified files 

12. git add --all     :- include both deletions and additions 

13. git rm <file>     :- remove a file 

14. git reset <file>  :- unstage that file 

15. git checkout -- <file> :-revert file to the version as of the current commit(undoes changes to the file)

16. Your changes are now in the staging area, which means they will be part of your next commit,To create a commit, run git commit -m "Meaningful commit message"
Your work is local until you push it to the remote repository. This is required to launch buddy builds and submit pull-request. 

17. git push -u origin <branchname>   :- to push your data on remote repository

18. buildreq -d or buildreq --default to launch the default buddy build job for the current branch.

19. buildreq --status <JobID>  :- Get the status of a build

20. git stash:- If the work is not ready for a commit yet and you want to preserve it for later while checking out from branch.It is a temporary place to save the current state of the working directory, which can be restored whenever you want with git stash apply / pop.

Notes*
1. If you haven’t committed anything yet, you can run git stash to save the repository state, create and checkout the topic branch, then run git stash pop to reapply your changes. When running git stash, your working directory is reverted to the currently checked out commit.
 
2. If you have already committed something, first run git reset origin/<branch> to reset the index entry back to the last public branch commit. This will not modify the working directory and previously committed files will now show up as unstaged. You can now create the topic branch and commit to it. 

3. If you want to keep the commits history, create a new topic branch for your work first from the branch you mistakenly updated (git checkout -b <newtopic>). Then checkout the wrong branch (git checkout <branch>) and reset it to a previous state using git reset --hard origin/<branch> 

                                             
                                                             for u ....

Kindly Bookmark this Post using your favorite Bookmarking service:


Post a Comment

Note: only a member of this blog may post a comment.