GIT Commands

Generic GIT Commands:
 
For New Repository:
git init
git add README.md or git add .
git commit -m "first commit"
git remote add origin git@github.com:mavrick202/hello123.git
git push -u origin master
 
For existing Repository:
rm -rf .git
git init
git remote add origin git@github.com:mavrick202/hello123.git
git push -u origin master
 
git add . or git reset -- HARD . /git reset HEAD -- testfile4
git commit
git reset --hard HEAD
git reset --hard commitid
git clean -n
git clean -d -f
git commit --amend
git blame filename
git push --force
 
git config --global core.editor "nano"
git branch
git checkout -b branch
git branch -D
git stash
git stash save "add style to our site"
git stash list
git stash pop stash@{2}
git merge
git rebase
git rebase -i HEAD~n
git squash
 
 
git secrets
git tags
git cherry-pick
















































Certainly! Here are some commonly used Git commands and a brief description of each:

1. **git init**: Initializes a new Git repository in the current directory.

2. **git clone [repository_url]**: Creates a copy of a remote Git repository on your local machine.

3. **git add [file(s)]**: Stages changes for commit. You can specify individual files or use `git add .` to stage all changes.

4. **git commit -m "Commit message"**: Records staged changes into the Git history with a descriptive message.

5. **git status**: Shows the status of your working directory, including which files are modified and staged.

6. **git diff**: Displays the differences between the working directory and the last commit.

7. **git log**: Shows a history of commits, including commit hashes, authors, dates, and commit messages.

8. **git branch**: Lists all local branches and indicates the currently active branch with an asterisk.

9. **git checkout [branch_name or commit_hash]**: Switches to a different branch or a specific commit.

10. **git merge [branch_name]**: Merges changes from the specified branch into the current branch.

11. **git pull**: Fetches changes from a remote repository and merges them into the current branch.

12. **git push**: Uploads local commits to a remote repository.

13. **git remote -v**: Lists the remote repositories associated with your local repository.

14. **git fetch [remote_name]**: Fetches changes from a specific remote repository but doesn't merge them.

15. **git reset [file(s)]**: Unstages changes from the staging area. You can also use it to reset to a specific commit.

16. **git stash**: Temporarily saves changes that are not ready to be committed, allowing you to switch branches without committing.

17. **git tag [tag_name]**: Creates a lightweight tag at the current commit, often used for marking release points.

18. **git rm [file(s)]**: Removes files from both the working directory and the Git repository.

19. **git mv [old_path] [new_path]**: Renames or moves files while automatically staging the change.

20. **git remote add [remote_name] [remote_url]**: Adds a new remote repository with a name and URL.

These are just some of the most commonly used Git commands. Git has a rich set of features and commands, so it's recommended to consult the Git documentation or use `git --help` or `git [command] --help` for more details on each command's options and usage.
















 
 
 

No comments:

Post a Comment