-
-
Save viswanath11/ee99937307bb7fef3b0348dc998ce0fd to your computer and use it in GitHub Desktop.
GIT #git #gitflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> the installed direction of my git | |
$ which git | |
> version of git | |
$ git --version | |
> Ignore list is a file in the base folder | |
.gitignore | |
> initialize a git project | |
$ git init | |
> Checkout a project into local repository from git repository | |
$ git clone <projecturl> | |
> remove added files to commit | |
$ git reset | |
> see added files to commit | |
$ git status | |
> Add all even deleted files | |
$ git add -u | |
> add all changes to git | |
$ git add . | |
> Rename directory or file | |
$ git mv <old name> <new name> | |
> Remove all changes from git | |
$ git rm (remove phisically all files inside the current directory from the file system) | |
$ git rm <filename> (remove phisically the file from the file system) | |
$ git rm --cached <filename> (remove the file from repository, but it keeps it in your filesystem) | |
> Reset specific file already added to stage for commit | |
$ git reset -- <filename> | |
> list my directories and files included hidden | |
$ git ls -la | |
> now that you have added files let’s put git changes inside repository (committing) | |
$ git commit -m "My commit message" | |
> update last commit message of a pushed branch | |
$ git commit --amend -m "My new commit message" | |
$ git push --force origin <BRANCH> | |
> Add the remote repository to your existing local one | |
$ git remote add origin [email protected]:<user>/<repo>.git | |
> Rename the remote repository | |
$ git remote set-url origin [email protected]:<user>/<repo>.git | |
> Show the remote repository | |
$ git remote -v | |
> Push files inside remote repository | |
$ git push origin <BRANCH> | |
> Pull files and merge repositories | |
$ git pull origin <BRANCH> | |
> list local branches | |
$ git branch | |
> switch (checkout) to a branch | |
git checkout master | |
> create a branch || if cms_bf_imagesized does not exist | |
git checkout <BRANCH> | |
> create and switch to a new branch | |
git checkout -b <NEW-BRANCH> <OLD-BRANCH> | |
> create a remote branch from local branch | |
git push origin -u cms_bf_imagesize | |
> push files to branches | |
git push origin cms_bf_imagesize | |
> switch to existing branch not at the moment in local | |
git checkout -b <existingbranch> | |
git pull origin <existingbranch> | |
> merge the <branch> to the current branch | |
git merge <BRANCH> | |
> delete local branch | |
git branch -d <BRANCH> | |
> delete remote branch | |
git push origin :<BRANCH> | |
> stash files | |
git stash | |
> list of the stashed states | |
git stash list | |
> show a specific state (changed filenames) | |
git stash show stash@{INDEX} | |
> show a specific state (changed code) | |
git stash show -p stash@{INDEX} | |
> apply last stashed state | |
git stash pop | |
> apply specific stashed state | |
git stash apply stash@{INDEX} | |
> rebase master into a BRANCH | |
git checkout <BRANCH> | |
git pull origin master --rebase | |
git push origin <BRANCH> --force | |
> rebase from head of a BRANCH til the INDEX previous commit | |
git checkout <BRANCH> | |
git rebase -i HEAD~<INDEX> | |
git push origin <BRANCH> --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> git user configuration | |
$ git config --global | |
For example: | |
If you want to change your username, email, text editor app or colors write down these actions | |
git config --global user.name “your name” | |
git config --global user.email “[email protected]” | |
git config --global core.editor “notepad.exe -wl1” (-w goes for waits for complete operations and then launch editor and l1 goes for to start on line 1 of editor) | |
git config --global color.ui true (this will help you to illustrate your git operations) | |
> git system configuration | |
$ git config --system | |
> git project configuration | |
$ git config | |
> check git configuration | |
$ git config --list | |
> add cached password on your windows | |
$ git config --global credential.helper wincred | |
> add cached password on your unix | |
$ git config credential.helper store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://help.github.com/articles/creating-a-pull-request/ | |
Fork | |
Create your feature branch: git checkout -b my-new-feature | |
Commit your changes: git commit -am 'Add some feature' | |
Push to the branch: git push origin my-new-feature | |
Submit a pull request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> see git log to look for changes made | |
$ git log | |
> see git log for a specific author | |
$ git log --author= "Name" | |
> see git log for a specific date | |
$ git log --since= 2012-06-14 | |
$ git log --until= 2012-06-14 | |
> see git log for a global regular expression | |
$ git log --grep= “your word” |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> init gitflow into a project | |
$ git flow init | |
> start and finish a feature (based on DEVELOP) | |
$ git flow feature start <MYFEATURE> | |
$ git flow feature finish <MYFEATURE> | |
> start and finish a release (based on DEVELOP, to execute in DEVELOP) | |
$ git flow release start <MYRELEASE> <BASE> // <BASE> is a sha-1 hash and is not mandatory | |
$ git flow release finish <MYRELEASE> | |
Merge workflow: | |
1. git flow feature start <branchname> | |
2. Adjust some code | |
3. Commit the code (not all code 1 one commit, unless its small) | |
4. git flow feature finish <branchname> | |
In some cases, when finishing the feature, an error pops up. (something with deverged) | |
Probably there are some conflicts. Then you should do the following: | |
1. git checkout develop | |
2. git pull (origin develop) | |
3. git checkout feature/<branchname> | |
4. git merge develop (keep conflicts in the feature branch) | |
5. Solve the conflicts if they occure | |
To set conflicts as resolve do | |
- git add . | |
- git commit | |
- VI will open | |
- :wq | |
6. git flow feature finish <branchname> | |
7. You will switch to develop, where you can push the code | |
You just finished a sprint and want to release your code: | |
1. Determine if everything on the develop is done and can be released. | |
2. Create a release branch, name it with a version name (v0.1.2) | |
3. Deploy the code of the release branch to the staging environment. | |
4. Let the client test the code (the release branch is not finished) | |
5. Solve bugs found in the release, in the release branch. (single commit per bugfix) | |
6. The release has been accepted by the client | |
7. Deploy the code of the release branch to the production environment. | |
8. Do a final test | |
9. Finish the release branch (will merge to master and develop) | |
10. The tag name will be the same as the release branch name (so that's the reason for the version) | |
11. Push the develop and master to remote. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// generate SSH keys into $HOME/.ssh/ folder | |
$ ssh-keygen -t rsa -C "[email protected]" -f id_rsa_name | |
output => | |
id_rsa_name | |
id_rsa_name.pub | |
// add your SSH key to the ssh-agent | |
$ ssh-add id_rsa_name | |
// copy publi SSH key | |
$ cat id_rsa_name.pub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment