https://github.com/puneethkumarck/git-command-tips
This project contains git command tips
https://github.com/puneethkumarck/git-command-tips
Last synced: 4 months ago
JSON representation
This project contains git command tips
- Host: GitHub
- URL: https://github.com/puneethkumarck/git-command-tips
- Owner: Puneethkumarck
- Created: 2017-12-27T13:49:00.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-01T08:21:41.000Z (almost 8 years ago)
- Last Synced: 2025-03-24T18:14:13.081Z (about 1 year ago)
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# git-command-tips
This project contains git command tips
### Create a new repository on the command line
```
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/Puneethkumarck/spring-cloud-microservice-playground (eg remote git repo url)
git push -u origin master
```
### Push an existing repository from the command line
```
git remote add origin https://github.com/Puneethkumarck/spring-cloud-microservice-playground (eg remotegit repo url)
git push -u origin master
```
### Issues
fatal: refusing to merge unrelated histories
```
git pull origin master --allow-unrelated-histories
```
### To remove git history from github
```
Checkout
git checkout --orphan latest_branch
Add all the files
git add -A
Commit the changes
git commit -am "commit message"
Delete the branch
git branch -D master
Rename the current branch to master
git branch -m master
Finally, force update your repository
git push -f origin master
```
### specify author while commiting
```
git commit --author 'username ' -am "commit message"
```
### adding files to stage for commit
```
git add -A stages All
git add . stages new and modified, without deleted
git add -u stages modified and deleted, without new
```
### Undo Commit and untrack the file
```
undo the latest commit
git reset --soft HEAD^1
remove file from staging area
git rm --cached
```
### Using multiple git accounts
## local config
+ git config user.name "**************"
+ git config user.email "*************"