GitHub for Mac : https://mac.github.com
Git for All Platforms : htp://git-scm.com
GITHB most used command:-
git pull origin branchname
git add .
git commit -m "changes"
git push origin branchname
CONFIGURE TOOLING
$ git config --global user.name "shashikant"
Sets the name you want attached to your commit transactions
$ git config --global user.email "shashikant@gmailcom"
Sets the email you want attached to your commit transactions
$ git config --global color.ui auto
Enables helpful colorization of command line output
CREATE REPOSITORIES
$ git init [project-name]
Creates a new local repository with the specified name
$ git clone [url]
Downloads a project and its entire version history
MAKE CHANGES
$ git status
Lists all new or modified files to be committed
$ git add [file]
Snapshots the file in preparation for versioning
$ git reset [file]
Unstages the file, but preserve its contents
MAKE CHANGES
$ git diff
Shows file differences not yet staged
$ git diff --staged
Shows file differences between staging and the last file version
$ git commit -m "[descriptive message]"
Records file snapshots permanently in version history
REVIEW HISTORY
$ git log
Lists version history for the current branch
$ git log --follow [file]
Lists version history for a file, including renames
$ git diff [first-branch]...[second-branch]
Shows content differences between two branches
$ git show [commit]
Outputs metadata and content changes of the specific commit
REDO COMMITS
$ git reset [commit]
Undoes all commits after [commit], preserve changes locally
$ git reset --hard [commit]
Discards all history and changes back to the specified commit
SAVE FRAGMENTS
$ git stash
Temporarily stores all modified tracked files
$ git stash list
Lists all stashed changesets
$ git stash pop
Restores the most recently stashed files
$ git stash drop
Discards the most recently stashed changeset
SYNCHRONIZE CHANGES
$ git fetch [bookmark]
Downloads all history from the repository bookmark
$ git merge [bookmark]/[branch]
Combines bookmark’s branch into current local branch
$ git push [bookmark] [branch]
Uploads all local branch commits to GitHub
$ git pull [bookmark] [branch]
Downloads bookmark history and incorporates changes
Git Branch
$ git checkout -b hotfix
Creates a new branch with name hotfix from current branch.
$ git commit -a -m 'fixed the issue'
Commits the changes after making the required changes.
Git Merging
$ git checkout <base-branch>
$ git merge --no-ff hotfix
The --no-ff flag prevents git merge from executing a "fast-forward" if it detects that your current HEAD is an ancestor of the commit you're trying to merge.
$ git push origin <base-branch>
$ git branch -d hotfix
PR = Pull Request
●Every PR is a request from one branch to another for merging code.
●Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before the changes are merged into the repository.
PR on Github
Every PR has a unique number and permanent URL.
https://github.com/shashi1028/drupalMigrate/pull/1
How to create a PR
1.Go to Repo landing page on github.
2.Click the New Pull Request button.
3.On the compare changes screen,
a.Base branch = upstream branch
b.Head branch = your task/bug branch
4. Upon choosing the two branches you should be able to see the changes and review them.
How to create a PR
5. Upon personal review, you can decide to raise a PR by clicking the Create PR button.
6. Share the URL of the PR with your peers for peer review.
** You can select default branch on github, so that the base branch is always selected to development.
Create a PR
How to merge a PR
-Code review
-Manual Test.
-Run Automated Tests*
-Check for syntax and coding standards.
-Check for sanity of other components of the system.
-Merge with the base branch using --no-ff to preserve history.
1.Go to the PR URL.
2.You can click on any of the lines to give any feedback or request changes.
3.Upon satisfactory review, you can merge the PR using the git merge command.
4.Remember PR is just a github convention, you always merge branches and not PRs.
$> git checkout <base-branch>
$> git merge --no-ff <branch-in-PR>
$> git push origin <base-branch>
Git Tagging
●Like most VCSs, Git has the ability to tag specific points in history as being important.
●Typically people use this functionality to mark release points (v1.0, and so on).
Git Tagging
$ git tag
# list available tags
$ git tag -l "v1.8.5*"
# search for specific tags
$ git show <tag-name>
# shows the tag data of a specific tag
Types of Tags
1. Annotated Tags
$ git tag -a <tag-name> -m '<message>'
$ git tag -a v1.4 -m 'version 1.4'
# creates an annotated tag. It’s generally recommended that you create annotated tags.
2. Lightweight Tags
$ git tag <tag-name>
$ git tag v1.4-lw
# creates a lightweight tag
Sharing Tags & Checkout
$ git push origin <tag-name>
# By default, the git push command doesn’t transfer tags to remote servers. You will have to explicitly push tags to a shared server after you have created them.
$ git push origin --tags
# This will transfer all of your tags to the remote server that are not already there.
CONFIGURE TOOLING
$ git config --global user.name "shashikant"
Sets the name you want attached to your commit transactions
$ git config --global user.email "shashikant@gmailcom"
Sets the email you want attached to your commit transactions
$ git config --global color.ui auto
Enables helpful colorization of command line output
CREATE REPOSITORIES
$ git init [project-name]
Creates a new local repository with the specified name
$ git clone [url]
Downloads a project and its entire version history
MAKE CHANGES
$ git status
Lists all new or modified files to be committed
$ git add [file]
Snapshots the file in preparation for versioning
$ git reset [file]
Unstages the file, but preserve its contents
MAKE CHANGES
$ git diff
Shows file differences not yet staged
$ git diff --staged
Shows file differences between staging and the last file version
$ git commit -m "[descriptive message]"
Records file snapshots permanently in version history
REVIEW HISTORY
$ git log
Lists version history for the current branch
$ git log --follow [file]
Lists version history for a file, including renames
$ git diff [first-branch]...[second-branch]
Shows content differences between two branches
$ git show [commit]
Outputs metadata and content changes of the specific commit
REDO COMMITS
$ git reset [commit]
Undoes all commits after [commit], preserve changes locally
$ git reset --hard [commit]
Discards all history and changes back to the specified commit
SAVE FRAGMENTS
$ git stash
Temporarily stores all modified tracked files
$ git stash list
Lists all stashed changesets
$ git stash pop
Restores the most recently stashed files
$ git stash drop
Discards the most recently stashed changeset
SYNCHRONIZE CHANGES
$ git fetch [bookmark]
Downloads all history from the repository bookmark
$ git merge [bookmark]/[branch]
Combines bookmark’s branch into current local branch
$ git push [bookmark] [branch]
Uploads all local branch commits to GitHub
$ git pull [bookmark] [branch]
Downloads bookmark history and incorporates changes
Git Branch
$ git checkout -b hotfix
Creates a new branch with name hotfix from current branch.
$ git commit -a -m 'fixed the issue'
Commits the changes after making the required changes.
Git Merging
$ git checkout <base-branch>
$ git merge --no-ff hotfix
The --no-ff flag prevents git merge from executing a "fast-forward" if it detects that your current HEAD is an ancestor of the commit you're trying to merge.
$ git push origin <base-branch>
$ git branch -d hotfix
PR = Pull Request
●Every PR is a request from one branch to another for merging code.
●Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before the changes are merged into the repository.
PR on Github
Every PR has a unique number and permanent URL.
https://github.com/shashi1028/drupalMigrate/pull/1
How to create a PR
1.Go to Repo landing page on github.
2.Click the New Pull Request button.
3.On the compare changes screen,
a.Base branch = upstream branch
b.Head branch = your task/bug branch
4. Upon choosing the two branches you should be able to see the changes and review them.
How to create a PR
5. Upon personal review, you can decide to raise a PR by clicking the Create PR button.
6. Share the URL of the PR with your peers for peer review.
** You can select default branch on github, so that the base branch is always selected to development.
Create a PR
How to merge a PR
-Code review
-Manual Test.
-Run Automated Tests*
-Check for syntax and coding standards.
-Check for sanity of other components of the system.
-Merge with the base branch using --no-ff to preserve history.
1.Go to the PR URL.
2.You can click on any of the lines to give any feedback or request changes.
3.Upon satisfactory review, you can merge the PR using the git merge command.
4.Remember PR is just a github convention, you always merge branches and not PRs.
$> git checkout <base-branch>
$> git merge --no-ff <branch-in-PR>
$> git push origin <base-branch>
Git Tagging
●Like most VCSs, Git has the ability to tag specific points in history as being important.
●Typically people use this functionality to mark release points (v1.0, and so on).
Git Tagging
$ git tag
# list available tags
$ git tag -l "v1.8.5*"
# search for specific tags
$ git show <tag-name>
# shows the tag data of a specific tag
Types of Tags
1. Annotated Tags
$ git tag -a <tag-name> -m '<message>'
$ git tag -a v1.4 -m 'version 1.4'
# creates an annotated tag. It’s generally recommended that you create annotated tags.
2. Lightweight Tags
$ git tag <tag-name>
$ git tag v1.4-lw
# creates a lightweight tag
Sharing Tags & Checkout
$ git push origin <tag-name>
# By default, the git push command doesn’t transfer tags to remote servers. You will have to explicitly push tags to a shared server after you have created them.
$ git push origin --tags
# This will transfer all of your tags to the remote server that are not already there.