CREATING A GITHUB REPOSITORY :-
-
Creating a New Repository
- `git init name_of_repository`
-
Make a Existing Folder Repository
- Step 1 -> `cd into the Folder`
- Step 2 -> `run git init`
CHECKING THE STATUS OF THE REPOSITORY :-
ADDING FILES TO THE STAGING AREA :-
-
Adding all files in single Step(use any one of these)
git add --all
git add "*"
-
-
Adding files more than one but selected
git add file_name1 file_name2
-
With the commiting message in one line
git commit -m "commit message"
-
Write the commiting message in the Git Default editor
-
Dropping all teh changes done after a pull. :-
-
Make Branch/Reset/Checkout
-
git branch new_branch_name
-
Git checkout to new branch
git checkout new_branch_name
-
Check in which branch you are in now type->
git branch
-
Reset Commit //this can be used to a previous commit in your history
git reset SHA
git clone remote_location clone_name
-
List of Git's project's remote->
git remote -v
-
git fetch
-
After Git Fetch we merge local master to remote master
git merge origin/master
-
git remote set-url <url>
git config --get remote.origin.url
Get just one file from different Branch
git checkout experiment -- app.js
Replace master with a branch
-
git checkout feature_branch
git merge -s ours --no-commit master
git commit # Add a message regarding the replacement that you just did
git checkout master
git merge feature_branch
-
git branch -f master dev_branch
-
git push remote +dev_branch:master
git push --delete origin <branch_name>
git branch -d <branch_name>
Adding the description to a git branch
git config branch.<branch-name>.description
""
How to keep a forked branch update to date as original branch
`git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git`
2. Add remote from original repository in your forked repository:
`cd into/cloned/fork-repo`
`git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git`
`git fetch upstream`
3. Updating your fork from original repo to keep up with their changes:
`git pull upstream master`
If a folder turns Grey i.e not being tracked
View the description of a branch
git config branch.<branch-name>.description
List all the information of the remote
git remote <remote-name> show
List info of all the branches
List all the remote branches
- If the branch is in remote branches but you are not able to checkout, then it means that it is not added in Local refs
- Solution: Add the remote branch in local refs using this command:
git branch <branch-name> <remote-name>/<branch-name>