Git
Git
more_horiz
close

on 18th January 2018 / by akhila.vn
While working on a project using git repository, if you want to create and switch to a new branch, then use: git checkout -b [my-branch-name] To simply checkout a branch, use: git checkout [my-branch-name] If you want to rename a branch when pointed to any other branch, you can type the following command: git branch -m [old-branch-name] [new-branch-name] To rename the current branch, use: git branch -m [new-branch-name] Also to push a branch after adding files and a commit, then type git push origin [branch-name] in your command line. In your current branch, if you want to know who updated the file last, then you can use: git blame [filepath]. To know who updated the line of a file last, use: git blame -L[LINE-NUMBER],+1 [filepath], for example, git blame -L21,+1 myfile.php. For deleting your current branch, first checkout to another branch and type the command, git branch -d [branch]. The above command deletes the branch locally, so for deleting the branch remotely you have to use, git push origin --delete [branch-name]. For deleting a file from current branch, you have to use: git rm [filepath]. For listing all branches that are local and remotely connected, use the command, git branch -al. Hope this helps. Git Leave a reply Your email address will not be published. Required fields are marker *
Git
more_horiz
close

on 06th December 2017 / by akhila.vn
When you want to change from the black and white colors in your git, you can use the default git color configurations using the command: git config --global color.ui trueThe --global is optional, if you want to make the coloring for the current repository, ignore this and type it as: git config color.ui trueTo make it more colorful you can add more configurations in your .gitconfig file. By default, git supports the colors black, red, green, yellow, blue, magenta, cyan and white. To add configurations by yourself, open the Ubuntu terminal and type the command to open git configuration file. Here I have used the vi editor, so you type, vi ~/.gitconfigAdd the following configurations to the file and save. [color] ui = auto [color "branch"] local = yellow current = yellow reverse remote = green [color "diff"] frag = magenta bold meta = yellow bold new = green bold old = red bold [color "status"] changed = green added = yellow untracked = magenta boldThis way you can change the colors of your git status, diff etc as your own idea and make your git beautiful. Have fun and happy coding. Git Leave a reply Your email address will not be published. Required fields are marker *
Git
more_horiz
close

on 18th August 2015 / by Emily Mathew
Git is a free software and distributed version control system. We can simply maintain and track our project files in git repository. It is a GNU version and slightly similar to other versioning system such as CVS, Subversion or Mercurial. We can call Git as a 'social network' for programmers or developers, which gives speed and efficiency in development. Different commands are used to handle the operations in git. Some useful git commands are listed below. Modify the Previous Commit Message. git commit --amendUndo the Previous Commit. git revert HEADUndo a specific Commit. git revert <commit-id>It create a new commit that removes all lines added and adds all lines removed in that commit. Temporarily Stash Changes, Restore the changes later. After changes have been made... git stashDo some other stuff here, like switching branches, merge other changes, etc. Again re-apply the changes. git stash popTagging, Deleting, and Pushing Tags. Create a Tag git tag <tagName>Delete a tag git tag -d <tagName>Push Tags. git push --tagsSearch specific logs grep log --grep="your search word"Merging new branches to the current branch. git merge <newbranch>Graphical interface to a local repository. gitkDelete branch local branch. git branch -D <branchName>Delete remote branch. git push origin --delete <branchName>Search branch by keyword. git branch -a | grep <keyword>Check for difference. Difference between two branches. git diff branch_1..branch_2View changes to a file relative to the index git diff <path/to/modified/file/name>If you use git as your version control system in development, this will definitely help you. You may also look into other solved issues related to Git over here. Please get in touch to know more. Git Leave a reply Your email address will not be published. Required fields are marker *
Git
more_horiz
close

on 26th June 2015 / by arjun.s
Git is a version control system which is distributed and is famous for its speed and efficiency. Git is different from its predecessors in so many ways, it handles the data as snapshots rather than file differences. Also almost all the operations in git is done at the local repository thus called distributed. Since all the operations are local it gives the power of speed to the end user.However more than this git also provides some tools which makes the git usage more easier and also increases the user friendliness. Let us see some tools provided by git. Git stashing You may come across different situations where you have untracked files in your current branch and you have to do some other work in another branch. Since there is untracked files, you can't move to the other branch. Usually we will checkout these changes by copying the files to some temporary location and then move to the other branch. But you can use the git tool "git stash" here. When you try to checkout to other branches a git message itself is displayed which indicates that "You have to either stash or commit the changes you have made". So git stash will stash the changes made in the current branch. This is like saving the changes to a stack. We can then change to any branches and do whatever we want and come back to this branch and regain our changes. This is most helpful if we work in multiple tasks(branches) at the same time. The major options with this tool are, git stash This will stash the current changes which can be used later. You can also use git stash save "message" to stash the changes with a message to identify the changes easier. git stash list This will list all the stash points you have saved in different branches. git stash apply This will apply the top stashed point on the array, ie the last changes you have stashed. You can specify a particular stash by specifying the name of that instance. git stash pop As the name implies this will pop out the top stashed point from the array and apply it to the current branch. It will no longer be available in the stash array of elements. git stash drop This can be used to drop a particular stashed instance, you can specify which one to be dropped by specifying the name of the stashed instance. git stash branch You can create a new branch from a stashed instance which can be used for merging with other branches or resolving any merge conflicts with the modified content of the same branch. Changing the last commit This will be most wanted tweak at all times. You have committed with a wrong commit message, so you need to change the last commit message or you need to change the snapshot just committed. If you only need to change the last commit message, that is very simple. You only have t use, git commit --amend But if you need to change the last recorded snapshot, ie you need t change the files that you have commited or you have add new files or remove existing one. For this you only need to use git add <file> or git rm to stage the changes and the git commit --amend takes the current staging area and record it as your new commit. Do not change the last commit if you have already pushed it. Delete a branch There may be situations when you need to delete a branch on local or on the server. Somehow you have committed wrong files or there were a hilarious mistake you made. If you need to delete a local branch you can do, git branch -d <local-branchname> Sometimes you need to delete a branch on the server, may be you have pushed wrong content to a branch with the ticket name, so you can only have one branch with the same ticket number and also you have to reduce the number of commits to a minimum. Then you can delete the remote branch using, git push repo :remote-branchname These are some tools that can be used to improve our git experience. There are many other tools available, try them and make the git usage more easier. Git Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 01st June 2015 / by arjun.s
Since a long time, I have been using the grep utility to search in code, and I am pretty comfortable with the tool. However, recently I came across git grep. The main advantage of this tool, when compared with the normal grep, is the speed of search. Read on to know how to use git grep to speed up development and coding. There is a huge difference in the search speed when compared to the normal grep utility. Yet another advantage is that you do not have to sort out the data related to the project. As there may be testing files or other untracked files in projects folder, using grep will bring unwanted results in those untracked files too. However, in the case of git grep, since we are only searching in the current code base, results would be completely relevant to the current project you are working on. Here, I will introduce some awesome options provided by the git grep utility. -i or --ignore-case This will perform the search without considering the case of the search keyword. -n or --line-number It will display the line number with the matched line. --break It shows the matched lines from different files with a line break between them. --heading The filename is displayed as a heading for the matches from a single file. -- Indicates the end of the options, preceding will be the <pathspec> limiters, by which we can limit our searches to particular files types -c or --count Instead of showing all the results, it shows the number of lines that match. As you can see the git grep provides enough options and functionalities that will make your code search more easier and faster. Some usage examples are, git grep "string to search" -> Will search the string in the complete code base. git grep -ni "string to search" -> Will list the matches without considering the case of string along with line numbers. git grep --break "search string" -> Will list the matches from different files with a line break in between. git grep "search string" -- *.php -> This will search only the files with extension .php. You can specify multiple file types by using a space in between. Web Development Git Leave a reply Your email address will not be published. Required fields are marker *
Git
more_horiz
close

on 26th March 2015 / by meera.l
Git is very popular guy in the world of version control systems and it is distributed by nature Without using a VCS, handling a project's multiple versions will get you in trouble very often. If multiple people are working on same project, this may be thousand fold. But if your client's service provider only gave you ftp access and it happens quite often, so you have to handle the project without the help of git. But we can track files easily using git-ftp, without having ssh access to the server. Steps to install git-ftp Clone the git repo of git-ftp into your system git clone https://github.com/resmo/git-ftp.gitInstall git-ftp, using the following commands cd git-ftp git checkout master sudo make installAlso make sure that curl is installed in your system. Now let us just walk through the topic how to use git ftp. We can divide the entire scenario into 3, they are initial deployment, maintenance and changes Initial deployment Inialize your git repo amd made your initial commit as usual. Now use the following command to push first time to your server using git-ftp git-ftp init -u username -p - ftp://host.example.com/public_htmlGit ftp is tracking the files by uploading the changed SHA1 name to the file.git-ftp.log. Maintenance If your server has uploaded files already and you have to track it using git-ftp, download all files and inialize git repo. Then use the following command. git-ftp catchup ftp://host.example.com/public_htmlThis will upload .git-ftp.log file into the server and it will help to remember the current state. Changes If you modified the code and to add modified files in to the server, just add and commit those file in git way and run the following command. git ftp push -u username -p - ftp://host.example.com/public_htmlYou can add default using git config as follows git config git-ftp.user ftpusername git config git-ftp.url ftp.hostname git config git-ftp.password ftppassword git config git-ftp.syncroot path/dirAfter setting default, you don't have to bother about anything, simply run as git ftp push. Also you can add scopes and can add the files to be ignored by adding them into .git-ftp-ignore. Reference:https://github.com/resmo/git-ftp/blob/develop/man/git-ftp.1.md Git Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 20th March 2015 / by fazeela.ma
Git is a control system for developing softwares. There are a number of git commands (Git reference). While searching bringing a commit from one branch to another, I came across an interesting topic called cherry picking. Cherry pick a commit? Sounds interesting!!! I have researched a bit to let know whether it would fit my context or not. Git Cherry pick This command is those cases, where we wanted to bring the commits from a particular branch to another. General syntax for cherry picking a particular commit is, git cherry-pick commit_hash_idLet us consider we have 3 branches as A, B, and C along with a master. Suppose, we would like to bring the last commit from branch C to B. In this case, make sure that we are the branch were we would like to bring the commit to. In this scenario, make sure you are on branch B, as we are planning to bring the commit from C to B. Now, a question can arise for those who is not very good with git. Don't we mention the branch from were the git commit to be taken? Nice question!! Why we need to specify that, as the hash code for every commit is unique. So we don't want to mention the branch from where we take commit. Git is an interesting software to explore, every day we see new commands to get the new functionalities integrated to it. Git Commands Leave a reply Your email address will not be published. Required fields are marker *
more_horiz
close

on 11th March 2015 / by deepa.n
At times we would want to clone a local git repository from one computer to another. Suppose, a developer uses git for his local project in Ubuntu. He would like to share his project with another developer who is working on another machine. Then how could he do that? Here is what they can use git clone with IP address. The steps to clone git for two developers are the following: $ git clone user-name@your.ip.add.ress:/home/myuser/projects/myproject $ cd myprojectThings to note: You'll need to know the password for the user -'user-name' Hope this helps! Ubuntu Git Leave a reply Your email address will not be published. Required fields are marker *
Git
more_horiz
close

on 02nd January 2015 / by hariram.s
Ignoring files:From time to time there are files you don't want git to track. There are a few methods of telling git what files to ignore. In which .gitignore file method is one of the popular method # Files to be ignored by Git # Ignore configuration files that may contain sensitive information. sites/*/settings*.php # Ignore paths that contain user-generated content. sites/*/files sites/*/private This is a code written in one site where they mentioned the files which they want to ignore. Here they mentioned settings.php and the user changing files which is not needed to add in the git repository since it is a changeable If you create a file in your repository named .gitignore, git will use its rules when looking at files to commit. Note that git will not ignore a file that was already tracked before a rule was added to this file to ignore it. So once the repository is created you have to add the .gitignore file or else you have to remove the files which you added before you adding the gitignore file This file can be committed into the repository, thus sharing the rule list with any other users that clone the repository. Sometimes an empty .gitignore file is used as a placeholder for an empty path Git Leave a reply Your email address will not be published. Required fields are marker *
Git
more_horiz
close

on 19th December 2014 / by sandeep.sasikumar
Most of us must be familiar with this message. After making the necessary changes to file and after going through the steps like git add, git commit, I tried git pull from server and got the following error message. "Auto-merging 'filename' CONFLICT (content): Merge conflict in 'filename' Automatic merge failed; fix conflicts and then commit the result." The 'filename' is the name of the file that the changes are made. The reason for this error is git was not able to auto-merge. To fix this or to revert the changes made follow the below mentioned two steps. git fetch origin git reset --hard origin Git Leave a reply Your email address will not be published. Required fields are marker *