This is a bare bones quick hack tutorial for git.
Checking current system configuration
$ git config --list
This will show:-
user.name=ABCSmith
user.email=abcsmith@gmail.com
Setting configuration on current system
git config --global user.name "XYZ John"
git config --global user.email "johnxyz@gmail.com"
Quick tip
To avoid filling password, write the information in .netrc file on Linux and Mac systems, for windows, use cygwin for this.
Sample of .netrc is as follows:-
machine bitbucket.org
login ABCSmith
password mypass1234
Checking server url
git remote -v
Branching
- Show list of all branches
git branch -a
- Create a feature branch named feature1 from development branch
first checku development branch, then create the feature1 branch.
git checkout development
git branch feature1
- Create a local branch in develop
$ git checkout develop
$ git branch -b develop_navjot develop (will create develop_navjot branch in develop)
$ git checkout develop_navjot
- Merge the branch locally
$ git checkout develop
$ git merge develop_navjot (will merge develop_navjot into develop)
- Push local branch to remote/server
$ git checkout develop
$ git push origin develop_navjot (will push develop_navjot into develop onto remote/server)
UNDOING
- undo last push
$ git -f push origin 9fed600afffca7a4df15c84dcdda44b154dc4f8a:master
- undo last push
git reset --hard HEAD@{1}
git push -f
- undo last Commit
$ git reset --soft HEAD^
or
$ git reset --soft HEAD~1
More Tips
- list all files under version control:-
git ls-files
- list all deleted files that are in version control:-
git ls-files --deleted
- removed all deleted files in version control from version control:-
(for git rm)
git ls-files --deleted | xargs git rm
- add all modified files in version control (for git add ...)
git ls-files --modified | xargs git add
- delete a branch
git push origin --delete <branchName>
Checking current system configuration
$ git config --list
This will show:-
user.name=ABCSmith
user.email=abcsmith@gmail.com
Setting configuration on current system
git config --global user.name "XYZ John"
git config --global user.email "johnxyz@gmail.com"
Quick tip
To avoid filling password, write the information in .netrc file on Linux and Mac systems, for windows, use cygwin for this.
Sample of .netrc is as follows:-
machine bitbucket.org
login ABCSmith
password mypass1234
Checking server url
git remote -v
Branching
- Show list of all branches
git branch -a
- Create a feature branch named feature1 from development branch
first checku development branch, then create the feature1 branch.
git checkout development
git branch feature1
- Create a local branch in develop
$ git checkout develop
$ git branch -b develop_navjot develop (will create develop_navjot branch in develop)
$ git checkout develop_navjot
- Merge the branch locally
$ git checkout develop
$ git merge develop_navjot (will merge develop_navjot into develop)
- Push local branch to remote/server
$ git checkout develop
$ git push origin develop_navjot (will push develop_navjot into develop onto remote/server)
UNDOING
- undo last push
$ git -f push origin 9fed600afffca7a4df15c84dcdda44b154dc4f8a:master
- undo last push
git reset --hard HEAD@{1}
git push -f
- undo last Commit
$ git reset --soft HEAD^
or
$ git reset --soft HEAD~1
More Tips
- list all files under version control:-
git ls-files
- list all deleted files that are in version control:-
git ls-files --deleted
- removed all deleted files in version control from version control:-
(for git rm)
git ls-files --deleted | xargs git rm
- add all modified files in version control (for git add ...)
git ls-files --modified | xargs git add
- delete a branch
git push origin --delete <branchName>
No comments:
Post a Comment