Hi everyone;
So long its been when I lost posted anything on my blog; The reason was again the same, some tight schedules and some other home activities; But Notw I’m back; Say welcome please;
Today’s post is simple; Me and my team is using Git now a days for my code management; So here are some git commands for daily usage; I’m not going to describing their usage in details; This post is for busy developer who just want to know the exact syntax of a command for a particular requirement;
So here we go;
Fetching code from a repository;git clone git@
This command will download all code from a particular git repository to your system; This is equivalence to SVN/CVS checkout;
This command will download all code from a particular git repository to your system; This is equivalence to SVN/CVS checkout;
git pull origin Will fetch updated code from remote repository to your system; Its just like update in SVN/CVS;
Play with branches
git branch Will display all branches of your current repository
git branch dev Will create a new branch named dev, to current repository; Note that this branch is only to your local repository;
git checkout dev You will be switched to dev branch locally;
git checkout -f B2 Forcefully switch to B2, reverting all your changes of current working branch;
git branch dev Will create a new branch named dev, to current repository; Note that this branch is only to your local repository;
git checkout dev You will be switched to dev branch locally;
git checkout -f B2 Forcefully switch to B2, reverting all your changes of current working branch;
To commit your codegit status Will show all your changes for current working branch;
git add Will add a file or directory in commit queue of git; This commit is only to your local repository; You can add one or more files/directories with this command and can your this command multiple times as well;
Tip: If there are more then on file in a directory, then just use the directory name in addcommand and git will all modified files to commit queue;
git add -u will removed deleted files from git status message; Sometimes many deleted files are shown in git status log, so this command will remove those deleted files form git’s logs;
Tip: If there are more then on file in a directory, then just use the directory name in addcommand and git will all modified files to commit queue;
git add -u will removed deleted files from git status message; Sometimes many deleted files are shown in git status log, so this command will remove those deleted files form git’s logs;
git commit -m ‘message” Will commit the previously added files to current local repository;
To merger code from B1 branch to B2 branch
Assuming that you have pushed all your local changes to remote B1 branch ;
git checkout B2 Will switch you from previous branch to B2 branch;
git merge B1 Will merge the code in B2, from B1; (The code of B1 will be merged in B2 and B1 will remain intact) Again note that this change will occur only to your local repository;
git push origin B2 Will push your code to remove B2 branch, from your local repository;
git merge B1 Will merge the code in B2, from B1; (The code of B1 will be merged in B2 and B1 will remain intact) Again note that this change will occur only to your local repository;
git push origin B2 Will push your code to remove B2 branch, from your local repository;
To Revert your changes in local repository
git checkout path/to/file/to/revert This checks out the current index for the current directory, throwing away all changes in files from the current directory downwards.
git reset –hard HEAD Will revert all of your changes in current working branch;
If you know any command for git, just dont’ hesitate to share with us;
Happy Development;
Happy Development;
0 comments:
Post a Comment