0% found this document useful (0 votes)
24 views3 pages

Git & GitHub

Uploaded by

antoajpstar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Git & GitHub

Uploaded by

antoajpstar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Git & GitHub

Create a git repository for Production ready code

 Create a private repository


 Create 3 branches (Prod, Staging and Dev)
 Add team as collaborators to this repository.
 Enable SSH based authentication
 Protect Master and staging branches
 1 approval needed to check-in code on staging branch and 2 approvals needed to check-in code
on to Prod branch
 Build and Deploy should be successful before check-in the code onto staging branch as well as
onto Prod branch

Git Commands

 git init .
 git add <file name>
 git commit -m "Commit information"
 git status
 git log
 git remote add "remote_repo" // add remote repo to local system
 git clone <remote_repo> // clone repo into local system
 git pull origin master
 git push origin master
 git checkout --
 git checkout -- .
 git restore <file_name>
 git restore .
 git checkout <branch_name>
 git checkout <commit_id> file // to get a file from previous commit
 git annotate <file-name>
 git branch --set-upstream-to=origin/master master
 git reset HEAD~N (N is number of commits to revert) //revert commits on local repository
 git checkout <branch_name>
 git checkout HEAD~1

 git rebase -i HEAD~N (N is number of commits to squash) // to combain multiple comments as a


single.
 git config --global user.name "USERNAME"
 git config --global user.email "[email protected]"
 git commit -m "COMMIT_ID"
 git push origin master
 git remote add origin "GITHUB_REPO_URL"
 git add "<filename>" / git add .
 git commit -m "<commit info>"
 git push origin <branch>
 git checkout -- <filename> // to revert changes from git working directory area
 git reset HEAD <filename> //unstage a file
 git checkout <commit_id> <filename> // move to previous commit
 git reset HEAD . //unstage all changes
 git checkout -- .
 git show <commit-id>
 git show HEAD
 git show HEAD~1
 git annotate <filename>
 git branch --set-upstream-to=origin/master master
 git branch <branch_name> // to create a new branch
 git checkout -b <branch_name> // to create new branch and switch to branch
 git merge <source_branch> <dest_branch>
 git branch -d <branch_name> // to delete a branch

You might also like