We Make your Working Easy.
Usefull git and github commands
To find out the version of git installed:git –version
To set the name:git config –global user.name “Mehdi Raeisi”
To set the email:git config –global user.email firstname.lastname@example.org
To see the configured name:git config –global user.name
To see the configured email:git config –global user.email
To see all settings:git config –list
To create an empty repository(The current folder is considered as repository.)
To create an empty repository with the chosen name:(The folder with the selected name is considered as repository.)
git init myRepositoryName
To transfer the repository from github to the system:git clone https://github.com/mehdira/git-crash-course.git
To transfer the repository from github to the system, by specifying a new name:git clone https://github.com/mehdira/git-crash-course.git newRepositoryName
To add a new or changed file to the stage:git add myFileName.format
To add all the files that have changed in the project to the stage:git add . git add * git add -A
To delete the selected file in the stage:git rm myFileName.format
To return the changed file from stage to the state before git add or git rm:git reset HEAD myFileName.format
To confirm the changes in the stage:git commit -m “my about text”
To change and edit the message of the last commit:git ommit –amend -m “new my about text”
To display the files being changed and the files in the stage area that have not been committed yet:git status
To display git status in summary:git status -s
To create a new branch:git branch -M myBranchName
To display branches in a repository:git branch
To delete an existing branch:git branch -D myBranchName
To switch between branches:git checkout myBranchName
To create a new branch and move to it:git checkout -b myNewBranchName
To revert to the original state in files that were merged by mistake:git checkout -m fileName.format
To see a list of remotes related to the repository:git remote
To remove a remote from the repository:git remote rm remoteName
To access the repository in github, remote is used:git remote add remoteName url
- origin: is the alias of the link. It means the original remote. (is a common name)
- http://github.com/… .git: URL copied to github.com site
To transfer the project (repository) from the computer to github (using the remote command):git push -u remoteName myBranchName
To transfer the project (repository) from the computer to github (without using the remote command):git push https://github.com/mehdira3000/myRepositoryName.git master
The source and git header must be set before using the git push command:git push –set-upstream shortName branchName
To get the changes from the repository in github:git pull remoteName
To download changes from other team members from github:git fetch git fetch origin main
This command downloads information about all commits, references, etc. Therefore, before applying these changes to your computer’s repository, you can review them.
To temporarily save uncommitted edited files:git stash
To see the list of stash files:git stash list
To add a stash to a branch:git stash apply
With the git stash apply and git stash pop commands, saved changes can be reapplied. Both commands will reapply the changes saved in the last stash. A stash apply re-applies the changes, while a stash pop removes the changes from the stash and re-applies them to the working version.
To see all the previous commits of the current branch (starting from the last commit):git log
To see all the previous commits of the desired branch (starting from the last commit):git log branchName
To see all previous commits from all branches (starting from the last commit):git log –all
To see all the previous commits resulting from merging branches (starting from the last commit):git log –merges
To view the commit logs, it is recommended to use the git log command instead of this command:git whatchanged
To see a summary of the git log command: and to know who worked on what:git shortlog
To view the details of a specific commit:git show commitHashCode
Compared to the git log command, the git show command displays details about a specific commit.git show
To merge the selected branch into the current branch:git merge branchName
To merge or merge the selected branch in the current branch, with the condition that the commit history of the selected branch is not entered in the main branch:git merge branchName –squash
To merge two branches into one branch (its function is similar to git merge)git rebase base
Rebasing is the process of combining or moving a sequence of commits on top of a new base commit. git rebase is a linear merge process.
To find bad commits:
Step 1- Start workgit bisect start
Step 2- Introducing a good commit to git:git bisect good a123
Step 3- Introducing a bad commit to git:git bisect bad z123
To select a commit from a branch and apply it to other branches:git cherry-pick commitHashCode
To combine multiple files into a single file:git archive –format zip HEAD > archive-HEAD.zip
The git archive command combines multiple files into a single file. It is like the zip tool, that is, it can decompress files and give access to each file separately. Creates a zip file of the current revision.
When getting the codes with the git pull command, we usually have to run rebase (and not merge). This prevents multiple merges.git pull –rebase
To examine the contents of a file line by line and determine who made each change:git blame myFileName.format
To create a new tag:git tag -a tagName
Tags are useful in git and can be used for release management. tag can be considered like a branch without change. Its importance is much greater when it is published publicly.
To check the gpg signature of commits: (GPG or GNU Privacy Guard)git verify-commit
To confirm the tag:git verify-tag
To compare the working file with its version in git:git diff HEAD filename.format
To compare two branches:git diff branch1 branch2
To have a graphical program to run git commands:git citool
To rename a file in git:git mv oldFileName.format newFileName.format
For information and guidance on git commands:git help gitCommand
To remove files that have not yet been added to the repository with git add:git clean
To set the default git ide:git config –global core.editor myIDE
To create aliases for commonly used git commands:git config –global alias.myAlias myGitCommand
By alias, we can define alias names for our frequently used commands and execute our commands with them.
To view Persian documents correctly in the git status command:git config –global core.quotepath false
Have your Mobile Application
It has never been easier to have your mobile application by us.
We are proud of all our work yet these deserve a spot up-front.
Our hope is to asist you to achieve value through our producted softwares and applications.
We are expert technology and you are expert in your business, so we can help togheter by useing the knowledg of both fields to having the best product.
Together with you, we find the proper solution for our problem.