It creates a new way of adressing complexties on a OpenSource Project, where earlier developers had to wait for days to checkin their code and deal with complex merging issues.
With GIT, all those are things of the past, we can focus on pure business logic or the code we are concerned. We just have to merge the changes with trusted resources and not get bothered by tons of other people changes.
There are very excellent articles and videos which Cover GIT in detail, My goal here is to display those commands which our team has been using more often
Initialization Commands
- git config --global github.user <
> git config --global user.email <> - git config --global color.branch "auto"
- git config --global color.status "auto"
- git config --global color.diff "auto"
- git clone
- git log
- git status
- git diff
, shows the difference between curret and head version - git diff "@{yesterday}" , shows changes since yesterday
- dit whatchanged --since="2 weeks ago"
- gitk, to open the git GUI
- git checkout -b $samplebranch , Creates a branch named samplebranch and switches to it
- git checkout $samplebranch, Just switches to a new branch
- git branch -d $branch, deletes the branch
- git branch -a : shows all branches local and remote
- git branch -r : show all remote branches
git remote add < remoterepo> git@github.com: >/ >.git , Adds a remote repository (e.g forked one from the main) to your machine - git remote rm
deletes the remote directory git remote -v : displays all the remote repositories
- git add . , adds all the changed /new files to the repo
- git reset --hard HEAD , Reverts all uncommited changes
- git clean -df , Remove any files in your working directory that were not added to git e.g autogenerated files.
- git revert , Reverts to previous commit.
- git commit -m "my first commit" to commit the files
- git checkout <
>, to revert a individual file
Its good to add tags lets say at different phases of project or while branching out,
- git tag -a -m "branched out version1" version1 , this will tag the last commit with the tag version1
- git tag , will display the tags
- git push origin --tags , will push the tags to the remote origin
The following steps summarize the commads need to pull changes from other forked branches to your local branch and push it to your remote github repo
git remote add auserepogit@github.com:auser/arepo.git
- git remove -v
- git checkout -b auser/master
- git branch
- git pull auserrepo master
- git checkout master
- git merge auser/master ,Note: if there are any conflicts open the files and resolve them
- git add . , This step is need to add any resolved conflict files
- git commit -m "your commits about successful merge"
- git push origin master , to push your changes to the github origin repo
To create a remote branch, there are many ways to approach
- Create a local branch
- git push origin master:refs/heads/R1.2 : to create a branch name R1.2 on remote origin
- git checkout -b R1.2
- git pull origin R1.2 : to pull changes from remote R1.2 branch
echo stacktrace.log >> .gitignore , adds stacktrace.log to .gitignore directory
Note: I haven't seen this working yet, hopefully soon it should work
Some Good Articles on GIT
- Do You want to get started with setting up a GitHub account and windows developer machine , read this blog Getting started with GIT and GITHub on Windows Kyle Cordes Blog
- Dr. Nic Blog on Working In a Team with different branches , forking , pulling changes
- Pulling changes from other people to your repot, Very good blog by Patric Reagon of Viget
No comments:
Post a Comment