Using Github with Command line Basics
Clone git repository git commands
git clone URL :
It will clone the remote repository in to your local file system. It will create folder with repository Name.
[git clone https://github.com/swdcworld/Salesforce.git]
Check Repository status git commands
git Status
It will show the files which are staged, unstaged and untracked.
[git status]
Checkout the feature branch
[git checkout origin/branchName]
Create a branch and checkout:
Locally create a branch and the same command to checkout the created branch.
[git checkout -b feature/branchName]
Check differences git commands
git diff
To see the unstaged changes in your working tree using command line.
[git diff]
git diff head
To see both staged and unstaged changes in your working tree.
[git diff head]
Stage changes git commands
git stage fileName
If you did changes in two files. but you one file is not yet ready, so you can just stage one file.
[git stage sampleFile.txt]
change sampleFile.txt with your file name. If your file having spaces then wrap it in quotes.
git stage .
If you did changes in 10 files, then you want to stage all of them.
[git stag .]
Unstage files git commands
git restore --staged fileName
If you miss something to add, but staged file can't allow to add changes. so you have to unstage it and add your changes.
[git restore --staged sampleFile.txt]
git restore --staged .
If you want to unstage all the chagnes then use (.).
[git restore --staged .]
Commit staged changes
git commit -m "your commit message"
You can commit your staged changes. always write your commit message, so that other developers know about your commit.
[git commit -m "It is a initial commit"]
Change commit message
git commit --amend -m "your correct message"
Sometimes we do mistakes, right. using this command we can correct most recent commit message.
[git commit --amend -m "your correct message"]
To set the global username and email
To set user email
[git config --global user.email "yourmail@domain.com"]
To set User Name
[git config --global user.name "userName"]
Push changes to remote branch
To push changes to remote branch using following command.
[git push remoteBranch]
Merge develop branch to feature branch locally:
first checkout the feature branch, then run this command
[git merge develop]
Update git password in vs code.
git config --global credential.helper wincred
COMMENTS